source: sasmodels/sasmodels/models/gaussian_peak.py @ 0507e09

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 0507e09 was 0507e09, checked in by smk78, 5 years ago

Added link to source code to each model. Closes #883

  • Property mode set to 100644
File size: 1.9 KB
Line 
1r"""
2
3Definition
4----------
5
6This 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
13with the peak having height of *scale* centered at $q_0$ and having a standard
14deviation of $\sigma$. The FWHM (full-width half-maximum) is $2.354 \sigma$.
15
16For 2D data, scattering intensity is calculated in the same way as 1D,
17where the $q$ vector is defined as
18
19.. math::
20
21    q = \sqrt{q_x^2 + q_y^2}
22
23
24References
25----------
26
27None.
28
29Source
30------
31
32`gaussian_peak.py <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/gaussian_peak.py>`_
33
34Authorship and Verification
35----------------------------
36
37* **Author:**
38* **Last Modified by:**
39* **Last Reviewed by:**
40* **Source added by :** Steve King **Date:** March 25, 2019
41"""
42
43import numpy as np
44from numpy import inf
45
46name = "gaussian_peak"
47title = "Gaussian shaped peak"
48description = """
49    Model describes a Gaussian shaped peak including a flat background
50    Provide F(q) = scale*exp( -1/2 *[(q-peak_pos)/sigma]^2 )+ background
51"""
52category = "shape-independent"
53
54#             ["name", "units", default, [lower, upper], "type","description"],
55parameters = [["peak_pos", "1/Ang", 0.05, [-inf, inf], "", "Peak position"],
56              ["sigma", "1/Ang", 0.005, [0, inf], "",
57               "Peak width (standard deviation)"],
58             ]
59
60Iq = """
61    double scaled_dq = (q - peak_pos)/sigma;
62    return exp(-0.5*scaled_dq*scaled_dq); //sqrt(2*M_PI*sigma*sigma);
63    """
64
65def random():
66    """Return a random parameter set for the model."""
67    peak_pos = 10**np.random.uniform(-3, -1)
68    sigma = 10**np.random.uniform(-1.3, -0.3)*peak_pos
69    scale = 10**np.random.uniform(0, 4)
70    pars = dict(
71        #background=1e-8,
72        scale=scale,
73        peak_pos=peak_pos,
74        sigam=sigma,
75    )
76    return pars
Note: See TracBrowser for help on using the repository browser.