1 | r""" |
---|
2 | This model describes a Lorentzian shaped peak on a flat background. |
---|
3 | |
---|
4 | Definition |
---|
5 | ---------- |
---|
6 | |
---|
7 | The scattering intensity $I(q)$ is calculated as |
---|
8 | |
---|
9 | .. math:: |
---|
10 | |
---|
11 | I(q) = \frac{scale}{\bigl(1+\bigl(\frac{q-q_0}{B}\bigr)^2\bigr)} + background |
---|
12 | |
---|
13 | with the peak having height of $I_0$ centered at $q_0$ and having a HWHM (half-width half-maximum) of B. |
---|
14 | |
---|
15 | For 2D data the scattering intensity is calculated in the same way as 1D, |
---|
16 | where the $q$ vector is defined as |
---|
17 | |
---|
18 | .. math:: |
---|
19 | |
---|
20 | q = \sqrt{q_x^2 + q_y^2} |
---|
21 | |
---|
22 | |
---|
23 | .. figure:: img/peak_lorentz_1d.jpg |
---|
24 | |
---|
25 | 1D plot using the default values (w/200 data point). |
---|
26 | |
---|
27 | References |
---|
28 | ---------- |
---|
29 | |
---|
30 | None. |
---|
31 | |
---|
32 | """ |
---|
33 | |
---|
34 | from numpy import inf, sqrt |
---|
35 | |
---|
36 | name = "peak_lorentz" |
---|
37 | title = "A Lorentzian peak on a flat background" |
---|
38 | description = """\ |
---|
39 | Class that evaluates a lorentzian shaped peak. |
---|
40 | |
---|
41 | F(q) = scale/(1+[(q-q0)/B]^2 ) + background |
---|
42 | |
---|
43 | The model has three parameters: |
---|
44 | scale = scale |
---|
45 | peak_pos = peak position |
---|
46 | peak_hwhm = half-width-half-maximum of peak |
---|
47 | background= incoherent background""" |
---|
48 | |
---|
49 | category = "shape-independent" |
---|
50 | |
---|
51 | # ["name", "units", default, [lower, upper], "type", "description"], |
---|
52 | parameters = [["peak_pos", "1/Ang", 0.05, [-inf, inf], "", "Peak postion in q"], |
---|
53 | ["peak_hwhm", "1/Ang", 0.005, [-inf, inf], "", "HWHM of peak"], |
---|
54 | ] |
---|
55 | |
---|
56 | def Iq(q, peak_pos, peak_hwhm): |
---|
57 | inten = (1/(1+((q-peak_pos)/peak_hwhm)**2)) |
---|
58 | return inten |
---|
59 | Iq.vectorized = True # Iq accepts an array of q values |
---|
60 | |
---|
61 | def Iqxy(qx, qy, *args): |
---|
62 | return Iq(sqrt(qx ** 2 + qy ** 2), *args) |
---|
63 | Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values |
---|
64 | |
---|
65 | |
---|
66 | demo = dict(scale=100, background=1.0, |
---|
67 | peak_pos=0.05, peak_hwhm=0.005) |
---|
68 | |
---|
69 | oldname = "PeakLorentzModel" |
---|
70 | oldpars = dict(peak_pos='q0', peak_hwhm='B') |
---|
71 | |
---|
72 | tests = [[{'scale':100.0, 'background':1.0}, 0.001, 2.0305]] |
---|