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