1 | ############################################################################## |
---|
2 | # This software was developed by the University of Tennessee as part of the |
---|
3 | # Distributed Data Analysis of Neutron Scattering Experiments (DANSE) |
---|
4 | # project funded by the US National Science Foundation. |
---|
5 | # |
---|
6 | # If you use DANSE applications to do scientific research that leads to |
---|
7 | # publication, we ask that you acknowledge the use of the software with the |
---|
8 | # following sentence: |
---|
9 | # |
---|
10 | # This work benefited from DANSE software developed under NSF award DMR-0520547 |
---|
11 | # |
---|
12 | # Copyright 2008-2011, University of Tennessee |
---|
13 | ############################################################################## |
---|
14 | |
---|
15 | """ |
---|
16 | Provide functionality for a C extension model |
---|
17 | |
---|
18 | .. WARNING:: |
---|
19 | |
---|
20 | THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY |
---|
21 | DO NOT MODIFY THIS FILE, MODIFY |
---|
22 | src\sans\models\include\logNormal.h |
---|
23 | AND RE-RUN THE GENERATOR SCRIPT |
---|
24 | """ |
---|
25 | |
---|
26 | from sans.models.BaseComponent import BaseComponent |
---|
27 | from sans.models.sans_extension.c_models import CLogNormal |
---|
28 | |
---|
29 | def create_LogNormal(): |
---|
30 | """ |
---|
31 | Create a model instance |
---|
32 | """ |
---|
33 | obj = LogNormal() |
---|
34 | # CLogNormal.__init__(obj) is called by |
---|
35 | # the LogNormal constructor |
---|
36 | return obj |
---|
37 | |
---|
38 | class LogNormal(CLogNormal, BaseComponent): |
---|
39 | """ |
---|
40 | Class that evaluates a LogNormal model. |
---|
41 | This file was auto-generated from src\sans\models\include\logNormal.h. |
---|
42 | Refer to that file and the structure it contains |
---|
43 | for details of the model. |
---|
44 | |
---|
45 | List of default parameters: |
---|
46 | |
---|
47 | * scale = 1.0 |
---|
48 | * sigma = 1.0 |
---|
49 | * center = 0.0 |
---|
50 | |
---|
51 | """ |
---|
52 | |
---|
53 | def __init__(self, multfactor=1): |
---|
54 | """ Initialization """ |
---|
55 | self.__dict__ = {} |
---|
56 | |
---|
57 | # Initialize BaseComponent first, then sphere |
---|
58 | BaseComponent.__init__(self) |
---|
59 | #apply(CLogNormal.__init__, (self,)) |
---|
60 | |
---|
61 | CLogNormal.__init__(self) |
---|
62 | self.is_multifunc = False |
---|
63 | |
---|
64 | ## Name of the model |
---|
65 | self.name = "LogNormal" |
---|
66 | ## Model description |
---|
67 | self.description = """ |
---|
68 | f(x)=scale * 1/(sigma*math.sqrt(2pi))e^(-1/2*((math.log(x)-mu)/sigma)^2) |
---|
69 | """ |
---|
70 | |
---|
71 | ## Parameter details [units, min, max] |
---|
72 | self.details = {} |
---|
73 | self.details['scale'] = ['', None, None] |
---|
74 | self.details['sigma'] = ['', None, None] |
---|
75 | self.details['center'] = ['', None, None] |
---|
76 | |
---|
77 | ## fittable parameters |
---|
78 | self.fixed = [] |
---|
79 | |
---|
80 | ## non-fittable parameters |
---|
81 | self.non_fittable = [] |
---|
82 | |
---|
83 | ## parameters with orientation |
---|
84 | self.orientation_params = [] |
---|
85 | |
---|
86 | ## parameters with magnetism |
---|
87 | self.magnetic_params = [] |
---|
88 | |
---|
89 | self.category = None |
---|
90 | self.multiplicity_info = None |
---|
91 | |
---|
92 | def __setstate__(self, state): |
---|
93 | """ |
---|
94 | restore the state of a model from pickle |
---|
95 | """ |
---|
96 | self.__dict__, self.params, self.dispersion = state |
---|
97 | |
---|
98 | def __reduce_ex__(self, proto): |
---|
99 | """ |
---|
100 | Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of |
---|
101 | c model. |
---|
102 | """ |
---|
103 | state = (self.__dict__, self.params, self.dispersion) |
---|
104 | return (create_LogNormal, tuple(), state, None, None) |
---|
105 | |
---|
106 | def clone(self): |
---|
107 | """ Return a identical copy of self """ |
---|
108 | return self._clone(LogNormal()) |
---|
109 | |
---|
110 | def run(self, x=0.0): |
---|
111 | """ |
---|
112 | Evaluate the model |
---|
113 | |
---|
114 | :param x: input q, or [q,phi] |
---|
115 | |
---|
116 | :return: scattering function P(q) |
---|
117 | |
---|
118 | """ |
---|
119 | return CLogNormal.run(self, x) |
---|
120 | |
---|
121 | def runXY(self, x=0.0): |
---|
122 | """ |
---|
123 | Evaluate the model in cartesian coordinates |
---|
124 | |
---|
125 | :param x: input q, or [qx, qy] |
---|
126 | |
---|
127 | :return: scattering function P(q) |
---|
128 | |
---|
129 | """ |
---|
130 | return CLogNormal.runXY(self, x) |
---|
131 | |
---|
132 | def evalDistribution(self, x): |
---|
133 | """ |
---|
134 | Evaluate the model in cartesian coordinates |
---|
135 | |
---|
136 | :param x: input q[], or [qx[], qy[]] |
---|
137 | |
---|
138 | :return: scattering function P(q[]) |
---|
139 | |
---|
140 | """ |
---|
141 | return CLogNormal.evalDistribution(self, x) |
---|
142 | |
---|
143 | def calculate_ER(self): |
---|
144 | """ |
---|
145 | Calculate the effective radius for P(q)*S(q) |
---|
146 | |
---|
147 | :return: the value of the effective radius |
---|
148 | |
---|
149 | """ |
---|
150 | return CLogNormal.calculate_ER(self) |
---|
151 | |
---|
152 | def calculate_VR(self): |
---|
153 | """ |
---|
154 | Calculate the volf ratio for P(q)*S(q) |
---|
155 | |
---|
156 | :return: the value of the volf ratio |
---|
157 | |
---|
158 | """ |
---|
159 | return CLogNormal.calculate_VR(self) |
---|
160 | |
---|
161 | def set_dispersion(self, parameter, dispersion): |
---|
162 | """ |
---|
163 | Set the dispersion object for a model parameter |
---|
164 | |
---|
165 | :param parameter: name of the parameter [string] |
---|
166 | :param dispersion: dispersion object of type DispersionModel |
---|
167 | |
---|
168 | """ |
---|
169 | return CLogNormal.set_dispersion(self, |
---|
170 | parameter, dispersion.cdisp) |
---|
171 | |
---|
172 | |
---|
173 | # End of file |
---|
174 | |
---|