[2eaae42] | 1 | r""" |
---|
[9d76d29] | 2 | |
---|
| 3 | Definition |
---|
| 4 | ---------- |
---|
| 5 | |
---|
[4c8f9cd] | 6 | This model describes a Gaussian shaped peak on a flat background |
---|
[2eaae42] | 7 | |
---|
[9d76d29] | 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 |
---|
[2eaae42] | 18 | |
---|
[9d76d29] | 19 | .. math:: |
---|
[2eaae42] | 20 | |
---|
[9d76d29] | 21 | q = \sqrt{q_x^2 + q_y^2} |
---|
[2eaae42] | 22 | |
---|
| 23 | |
---|
[eb69cce] | 24 | References |
---|
| 25 | ---------- |
---|
[2eaae42] | 26 | |
---|
[4c8f9cd] | 27 | None. |
---|
[2eaae42] | 28 | """ |
---|
| 29 | |
---|
[3c56da87] | 30 | from numpy import inf |
---|
[2eaae42] | 31 | |
---|
[4c8f9cd] | 32 | name = "gaussian_peak" |
---|
| 33 | title = "Gaussian shaped peak" |
---|
| 34 | description = """ |
---|
| 35 | Model describes a Gaussian shaped peak including a flat background |
---|
[a807206] | 36 | Provide F(q) = scale*exp( -1/2 *[(q-peak_pos)/sigma]^2 )+ background |
---|
[2eaae42] | 37 | """ |
---|
[a5d0d00] | 38 | category = "shape-independent" |
---|
[2eaae42] | 39 | |
---|
[3e428ec] | 40 | # ["name", "units", default, [lower, upper], "type","description"], |
---|
[a807206] | 41 | parameters = [["peak_pos", "1/Ang", 0.05, [-inf, inf], "", "Peak position"], |
---|
[9d76d29] | 42 | ["sigma", "1/Ang", 0.005, [0, inf], "", |
---|
[3e428ec] | 43 | "Peak width (standard deviation)"], |
---|
| 44 | ] |
---|
[2eaae42] | 45 | |
---|
| 46 | Iq = """ |
---|
[a807206] | 47 | double scaled_dq = (q - peak_pos)/sigma; |
---|
[677ccf1] | 48 | return exp(-0.5*scaled_dq*scaled_dq); //sqrt(2*M_PI*sigma*sigma); |
---|
[2eaae42] | 49 | """ |
---|
| 50 | |
---|
| 51 | # VR defaults to 1.0 |
---|
| 52 | |
---|
[48462b0] | 53 | def random(): |
---|
| 54 | import numpy as np |
---|
| 55 | peak_pos = 10**np.random.uniform(-3, -1) |
---|
| 56 | sigma = 10**np.random.uniform(-1.3, -0.3)*peak_pos |
---|
| 57 | scale = 10**np.random.uniform(0, 4) |
---|
| 58 | pars = dict( |
---|
| 59 | #background=1e-8, |
---|
| 60 | scale=scale, |
---|
| 61 | peak_pos=peak_pos, |
---|
| 62 | sigam=sigma, |
---|
| 63 | ) |
---|
| 64 | return pars |
---|