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 | .. image:: img/gaussian_peak_1d.jpg |
---|
25 | |
---|
26 | 1D plot using the default values (w/500 data points). |
---|
27 | |
---|
28 | Reference |
---|
29 | --------- |
---|
30 | |
---|
31 | None. |
---|
32 | """ |
---|
33 | |
---|
34 | from numpy import inf |
---|
35 | |
---|
36 | name = "gaussian_peak" |
---|
37 | title = "Gaussian shaped peak" |
---|
38 | description = """ |
---|
39 | Model describes a Gaussian shaped peak including a flat background |
---|
40 | Provide F(q) = scale*exp( -1/2 *[(q-q0)/sigma]^2 )+ background |
---|
41 | """ |
---|
42 | category = "shape-independent" |
---|
43 | |
---|
44 | # ["name", "units", default, [lower, upper], "type","description"], |
---|
45 | parameters = [["q0", "1/Ang", 0.05, [-inf, inf], "", "Peak position"], |
---|
46 | ["sigma", "1/Ang", 0.005, [0, inf], "", |
---|
47 | "Peak width (standard deviation)"], |
---|
48 | ] |
---|
49 | |
---|
50 | # No volume normalization despite having a volume parameter |
---|
51 | # This should perhaps be volume normalized? |
---|
52 | form_volume = """ |
---|
53 | return 1.0; |
---|
54 | """ |
---|
55 | |
---|
56 | Iq = """ |
---|
57 | return exp(-0.5*pow((q - q0)/sigma,2.0)); |
---|
58 | """ |
---|
59 | |
---|
60 | |
---|
61 | Iqxy = """ |
---|
62 | // never called since no orientation or magnetic parameters. |
---|
63 | //return -1.0; |
---|
64 | return Iq(sqrt(qx*qx + qy*qy), q0, sigma); |
---|
65 | """ |
---|
66 | |
---|
67 | |
---|
68 | # VR defaults to 1.0 |
---|
69 | |
---|
70 | demo = dict(scale=1, background=0, q0=0.05, sigma=0.005) |
---|
71 | oldname = "PeakGaussModel" |
---|
72 | oldpars = dict(sigma='B') |
---|