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

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 0a4628d was 0a4628d, checked in by wojciech, 8 years ago

Scale and background paramters frozen in line model

  • Property mode set to 100644
File size: 2.2 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:: None
13
14References
15----------
16
17None.
18
19"""
20from numpy import inf
21from numpy import cos
22from numpy import sin
23
24name = "line"
25title = "Line model"
26description = """\
27      I(q) = A + B*q
28
29      List of default parameters:
30      A = intercept
31      B = slope
32      """
33category = "shape-independent"
34
35# pylint: disable=bad-whitespace, line-too-long
36#             ["name", "units", default, [lower, upper], "type", "description"],
37parameters = [["intercept",     "1/cm",        1.0, [-inf, inf], "", "intercept in linear model"],
38              ["slope",     "Ang/cm",    1.0, [-inf, inf], "", "slope in linear model"],
39              ]
40# pylint: enable=bad-whitespace, line-too-long
41
42def Iq(q, intercept, slope):
43    """
44    :param q:           Input q-value
45    :param intercept:   Intrecept in linear model
46    :param slope:       Slope in linear model
47    :return:            Calculated Intensity
48    """
49    inten = intercept + slope*q
50    return inten
51
52Iq.vectorized = True # Iq accepts an array of q values
53
54def Iqxy(qx, qy, *args):
55    """
56    :param qx:   Input q_x-value
57    :param qy:   Input q_y-value
58    :param args: Remaining arguments
59    :return:     2D-Intensity
60    """
61    #TODO: Instrcution tels 2D has different deffinition than oher models
62    #Iq(qx*cos(qy), *args)*Iq(qy, *args
63    return  Iq(qx*cos(qy), *args)*Iq(qx*sin(qy), *args)
64
65Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values
66
67demo = dict(scale=1.0, background=0, intercept=1.0, slope=1.0)
68
69oldname = "LineModel"
70oldpars = dict(intercept='A', slope='B', background=None, scale=None)
71
72tests = [
73    # Accuracy tests based on content in test/utest_other_models.py
74    [{'intercept':   1.0,
75      'slope': 1.0,
76     }, 0.4, 1.4],
77
78    [{'intercept':   1.0,
79      'slope': 1.0,
80     }, 1.3, 2.3],
81
82    [{'intercept':   1.0,
83      'slope': 1.0,
84     }, 0.5, 1.5],
85
86    [{'intercept':   1.0,
87      'slope': 1.0,
88     }, [0.4, 0.5], [1.4, 1.5]],
89
90    [{'intercept':   1.0,
91      'slope': 1.0,
92     }, [1.3, 1.57], [2.3, 2.57]],
93]
Note: See TracBrowser for help on using the repository browser.