1 | r""" |
---|
2 | |
---|
3 | Definition |
---|
4 | ---------- |
---|
5 | |
---|
6 | This model describes a Gaussian shaped peak on a flat background |
---|
7 | |
---|
8 | .. math:: |
---|
9 | |
---|
10 | I(q) = (\text{scale}) \exp\left[ -\tfrac12 (q-q_0)^2 / \sigma^2 \right] |
---|
11 | + \text{background} |
---|
12 | |
---|
13 | with the peak having height of *scale* centered at $q_0$ and having a standard |
---|
14 | deviation of $\sigma$. The FWHM (full-width half-maximum) is $2.354 \sigma$. |
---|
15 | |
---|
16 | For 2D data, scattering intensity is calculated in the same way as 1D, |
---|
17 | where the $q$ vector is defined as |
---|
18 | |
---|
19 | .. math:: |
---|
20 | |
---|
21 | q = \sqrt{q_x^2 + q_y^2} |
---|
22 | |
---|
23 | |
---|
24 | References |
---|
25 | ---------- |
---|
26 | |
---|
27 | None. |
---|
28 | """ |
---|
29 | |
---|
30 | from numpy import inf |
---|
31 | |
---|
32 | name = "gaussian_peak" |
---|
33 | title = "Gaussian shaped peak" |
---|
34 | description = """ |
---|
35 | Model describes a Gaussian shaped peak including a flat background |
---|
36 | Provide F(q) = scale*exp( -1/2 *[(q-q0)/sigma]^2 )+ background |
---|
37 | """ |
---|
38 | category = "shape-independent" |
---|
39 | |
---|
40 | single = False |
---|
41 | # ["name", "units", default, [lower, upper], "type","description"], |
---|
42 | parameters = [["q0", "1/Ang", 0.05, [-inf, inf], "", "Peak position"], |
---|
43 | ["sigma", "1/Ang", 0.005, [0, inf], "", |
---|
44 | "Peak width (standard deviation)"], |
---|
45 | ] |
---|
46 | |
---|
47 | # No volume normalization despite having a volume parameter |
---|
48 | # This should perhaps be volume normalized? |
---|
49 | form_volume = """ |
---|
50 | return 1.0; |
---|
51 | """ |
---|
52 | |
---|
53 | Iq = """ |
---|
54 | double scaled_dq = (q - q0)/sigma; |
---|
55 | return exp(-0.5*scaled_dq*scaled_dq); //sqrt(2*M_PI*sigma*sigma); |
---|
56 | """ |
---|
57 | |
---|
58 | |
---|
59 | Iqxy = """ |
---|
60 | // never called since no orientation or magnetic parameters. |
---|
61 | //return -1.0; |
---|
62 | return Iq(sqrt(qx*qx + qy*qy), q0, sigma); |
---|
63 | """ |
---|
64 | |
---|
65 | |
---|
66 | # VR defaults to 1.0 |
---|
67 | |
---|
68 | demo = dict(scale=1, background=0, q0=0.05, sigma=0.005) |
---|
69 | oldname = "PeakGaussModel" |
---|
70 | oldpars = dict(sigma='B') |
---|