[af03ddd] | 1 | #!/usr/bin/env python |
---|
| 2 | |
---|
[79ac6f8] | 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 | ############################################################################## |
---|
[af03ddd] | 16 | |
---|
| 17 | |
---|
[79ac6f8] | 18 | """ |
---|
| 19 | Provide functionality for a C extension model |
---|
[af03ddd] | 20 | |
---|
[79ac6f8] | 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 |
---|
[af03ddd] | 24 | |
---|
| 25 | """ |
---|
| 26 | |
---|
| 27 | from sans.models.BaseComponent import BaseComponent |
---|
| 28 | from sans_extension.c_models import [CPYTHONCLASS] |
---|
| 29 | import copy |
---|
[5650ebf] | 30 | |
---|
| 31 | def create_[PYTHONCLASS](): |
---|
| 32 | obj = [PYTHONCLASS]() |
---|
| 33 | #[CPYTHONCLASS].__init__(obj) is called by [PYTHONCLASS] constructor |
---|
| 34 | return obj |
---|
| 35 | |
---|
[af03ddd] | 36 | class [PYTHONCLASS]([CPYTHONCLASS], BaseComponent): |
---|
[79ac6f8] | 37 | """ |
---|
| 38 | Class that evaluates a [PYTHONCLASS] model. |
---|
| 39 | This file was auto-generated from [INCLUDE_FILE]. |
---|
| 40 | Refer to that file and the structure it contains |
---|
| 41 | for details of the model. |
---|
| 42 | [DEFAULT_LIST] |
---|
[af03ddd] | 43 | """ |
---|
| 44 | |
---|
| 45 | def __init__(self): |
---|
| 46 | """ Initialization """ |
---|
| 47 | |
---|
| 48 | # Initialize BaseComponent first, then sphere |
---|
| 49 | BaseComponent.__init__(self) |
---|
[5650ebf] | 50 | #apply([CPYTHONCLASS].__init__, (self,)) |
---|
[af03ddd] | 51 | [CPYTHONCLASS].__init__(self) |
---|
| 52 | |
---|
| 53 | ## Name of the model |
---|
| 54 | self.name = "[PYTHONCLASS]" |
---|
[836fe6e] | 55 | ## Model description |
---|
[9316609] | 56 | self.description ="""[DESCRIPTION]""" |
---|
[836fe6e] | 57 | |
---|
[fe9c19b4] | 58 | [PAR_DETAILS] |
---|
| 59 | ## fittable parameters |
---|
[836fe6e] | 60 | self.fixed=[FIXED] |
---|
[25a608f5] | 61 | |
---|
[8622241] | 62 | ## non-fittable parameters |
---|
| 63 | self.non_fittable = [NON_FITTABLE_PARAMS] |
---|
| 64 | |
---|
[25a608f5] | 65 | ## parameters with orientation |
---|
[8622241] | 66 | self.orientation_params = [ORIENTATION_PARAMS] |
---|
[af03ddd] | 67 | |
---|
[5650ebf] | 68 | def __reduce_ex__(self, proto): |
---|
[79ac6f8] | 69 | """ |
---|
[5650ebf] | 70 | Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of |
---|
| 71 | c model. |
---|
[79ac6f8] | 72 | """ |
---|
[5650ebf] | 73 | return (create_[PYTHONCLASS],tuple()) |
---|
[fe9c19b4] | 74 | |
---|
[5650ebf] | 75 | def clone(self): |
---|
| 76 | """ Return a identical copy of self """ |
---|
| 77 | return self._clone([PYTHONCLASS]()) |
---|
[fe9c19b4] | 78 | |
---|
[af03ddd] | 79 | |
---|
[79ac6f8] | 80 | def run(self, x=0.0): |
---|
| 81 | """ |
---|
| 82 | Evaluate the model |
---|
| 83 | |
---|
| 84 | :param x: input q, or [q,phi] |
---|
| 85 | |
---|
| 86 | :return: scattering function P(q) |
---|
| 87 | |
---|
[af03ddd] | 88 | """ |
---|
| 89 | |
---|
| 90 | return [CPYTHONCLASS].run(self, x) |
---|
| 91 | |
---|
[79ac6f8] | 92 | def runXY(self, x=0.0): |
---|
| 93 | """ |
---|
| 94 | Evaluate the model in cartesian coordinates |
---|
| 95 | |
---|
| 96 | :param x: input q, or [qx, qy] |
---|
| 97 | |
---|
| 98 | :return: scattering function P(q) |
---|
| 99 | |
---|
[af03ddd] | 100 | """ |
---|
| 101 | |
---|
| 102 | return [CPYTHONCLASS].runXY(self, x) |
---|
| 103 | |
---|
[79ac6f8] | 104 | def evalDistribution(self, x=[]): |
---|
| 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 | |
---|
[5b56b7a] | 112 | """ |
---|
[f9a1279] | 113 | return [CPYTHONCLASS].evalDistribution(self, x) |
---|
[5b56b7a] | 114 | |
---|
[5eb9154] | 115 | def calculate_ER(self): |
---|
[79ac6f8] | 116 | """ |
---|
| 117 | Calculate the effective radius for P(q)*S(q) |
---|
| 118 | |
---|
| 119 | :return: the value of the effective radius |
---|
| 120 | |
---|
[5eb9154] | 121 | """ |
---|
| 122 | return [CPYTHONCLASS].calculate_ER(self) |
---|
| 123 | |
---|
[af03ddd] | 124 | def set_dispersion(self, parameter, dispersion): |
---|
| 125 | """ |
---|
[79ac6f8] | 126 | Set the dispersion object for a model parameter |
---|
| 127 | |
---|
| 128 | :param parameter: name of the parameter [string] |
---|
| 129 | :param dispersion: dispersion object of type DispersionModel |
---|
| 130 | |
---|
[af03ddd] | 131 | """ |
---|
| 132 | return [CPYTHONCLASS].set_dispersion(self, parameter, dispersion.cdisp) |
---|
| 133 | |
---|
| 134 | |
---|
| 135 | # End of file |
---|