source: sasmodels/sasmodels/models/line.py @ 0cb1c7a

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 0cb1c7a was 0cb1c7a, checked in by Wojciech Potrzebowski <potrezebowski@…>, 8 years ago

Line model conversion initial attempt

  • Property mode set to 100644
File size: 1.8 KB
Line 
1r"""
2This model calculates intensity using simple linear function
3Definition
4----------
5
6The scattering intensity $I(q)$ is calculated as
7
8.. math::
9
10    I(q) = A + B*q
11
12.. figure:: img/broad_peak_1d.jpg
13
14    1D plot using the default values (w/200 data point).
15
16References
17----------
18
19None.
20
21"""
22
23from numpy import vectorize
24from numpy import inf
25
26name = "line"
27title = "Line model"
28description = """\
29      I(q) = A + B*q
30
31      List of default parameters:
32      A = intercept
33      B = slope
34      """
35category = "shape-independent"
36
37# pylint: disable=bad-whitespace, line-too-long
38#             ["name", "units", default, [lower, upper], "type", "description"],
39parameters = [["intercept",     "cm^-1",        1.0, [-inf, inf], "", "intercept in linear model"],
40              ["slope",     "Ang*cm^-1",    1.0, [-inf, inf], "", "slope in linear model"],
41              ]
42
43def Iq(q, intercept, slope):
44    """
45    :param q:           Input q-value
46    :param intercept:   Intrecept in linear model
47    :param slope:       Slope in linear model
48    :return:            Calculated Intensity
49    """
50
51    inten = intercept + slope*q
52    return inten
53
54Iq.vectorized = True # Iq accepts an array of q values
55
56def Iqxy(qx, qy, *args):
57    """
58    :param qx:   Input q_x-value
59    :param qy:   Input q_y-value
60    :param args: Remaining arguments
61    :return:     2D-Intensity
62    """
63    #TODO: Instrcution tels 2D has different deffinition than oher models
64    #return Iq(sqrt(qx ** 2 + qy ** 2), *args)
65    return  Iq(qx,*args)*Iq(qy,*args)
66
67Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values
68
69demo = dict(scale=1, background=0.1,
70            intercept=1.0, slope=1.0)
71
72oldname = "LineModel"
73oldpars = dict(intercept='A', slope='B', scale=None)
Note: See TracBrowser for help on using the repository browser.