source: sasmodels/sasmodels/models/gaussian_peak.py @ 304c775

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 304c775 was 304c775, checked in by Paul Kienzle <pkienzle@…>, 6 years ago

provide method for testing Fq results. Refs #1202.

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