[fd5ac0d] | 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 | |
---|
[c93122e] | 15 | """ |
---|
[fd5ac0d] | 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 | [INCLUDE_FILE] |
---|
| 23 | AND RE-RUN THE GENERATOR SCRIPT |
---|
| 24 | """ |
---|
| 25 | |
---|
| 26 | from sas.models.BaseComponent import BaseComponent |
---|
| 27 | from sas.models.sas_extension.c_models import [CPYTHONCLASS] |
---|
[8836849] | 28 | from numpy import inf |
---|
[fd5ac0d] | 29 | |
---|
| 30 | def create_[PYTHONCLASS](): |
---|
| 31 | """ |
---|
| 32 | Create a model instance |
---|
| 33 | """ |
---|
| 34 | obj = [PYTHONCLASS]() |
---|
| 35 | # [CPYTHONCLASS].__init__(obj) is called by |
---|
| 36 | # the [PYTHONCLASS] constructor |
---|
| 37 | return obj |
---|
| 38 | |
---|
| 39 | class [PYTHONCLASS]([CPYTHONCLASS], BaseComponent): |
---|
[c93122e] | 40 | """ |
---|
| 41 | Class that evaluates a [PYTHONCLASS] model. |
---|
[fd5ac0d] | 42 | This file was auto-generated from [INCLUDE_FILE]. |
---|
| 43 | Refer to that file and the structure it contains |
---|
| 44 | for details of the model. |
---|
| 45 | [DEFAULT_LIST] |
---|
| 46 | """ |
---|
[c93122e] | 47 | |
---|
[fd5ac0d] | 48 | def __init__(self, multfactor=1): |
---|
| 49 | """ Initialization """ |
---|
| 50 | self.__dict__ = {} |
---|
[c93122e] | 51 | |
---|
[fd5ac0d] | 52 | # Initialize BaseComponent first, then sphere |
---|
| 53 | BaseComponent.__init__(self) |
---|
| 54 | #apply([CPYTHONCLASS].__init__, (self,)) |
---|
| 55 | |
---|
| 56 | [CALL_CPYTHON_INIT] |
---|
[c93122e] | 57 | |
---|
[fd5ac0d] | 58 | ## Name of the model |
---|
| 59 | self.name = "[PYTHONCLASS]" |
---|
| 60 | ## Model description |
---|
| 61 | self.description = """ |
---|
| 62 | [DESCRIPTION] |
---|
| 63 | """ |
---|
[c93122e] | 64 | |
---|
[fd5ac0d] | 65 | [PAR_DETAILS] |
---|
| 66 | ## fittable parameters |
---|
| 67 | self.fixed = [FIXED] |
---|
[c93122e] | 68 | |
---|
[fd5ac0d] | 69 | ## non-fittable parameters |
---|
| 70 | self.non_fittable = [NON_FITTABLE_PARAMS] |
---|
[c93122e] | 71 | |
---|
[fd5ac0d] | 72 | ## parameters with orientation |
---|
| 73 | self.orientation_params = [ORIENTATION_PARAMS] |
---|
| 74 | |
---|
| 75 | ## parameters with magnetism |
---|
| 76 | self.magnetic_params = [MAGNETIC_PARAMS] |
---|
| 77 | |
---|
| 78 | self.category = [CATEGORY] |
---|
| 79 | self.multiplicity_info = [MULTIPLICITY_INFO] |
---|
[c93122e] | 80 | |
---|
[fd5ac0d] | 81 | def __setstate__(self, state): |
---|
| 82 | """ |
---|
| 83 | restore the state of a model from pickle |
---|
| 84 | """ |
---|
| 85 | self.__dict__, self.params, self.dispersion = state |
---|
[c93122e] | 86 | |
---|
[fd5ac0d] | 87 | def __reduce_ex__(self, proto): |
---|
| 88 | """ |
---|
[c93122e] | 89 | Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of |
---|
[fd5ac0d] | 90 | c model. |
---|
| 91 | """ |
---|
| 92 | state = (self.__dict__, self.params, self.dispersion) |
---|
| 93 | return (create_[PYTHONCLASS], tuple(), state, None, None) |
---|
[c93122e] | 94 | |
---|
[fd5ac0d] | 95 | def clone(self): |
---|
| 96 | """ Return a identical copy of self """ |
---|
[c93122e] | 97 | return self._clone([PYTHONCLASS]()) |
---|
| 98 | |
---|
[fd5ac0d] | 99 | def run(self, x=0.0): |
---|
[c93122e] | 100 | """ |
---|
[fd5ac0d] | 101 | Evaluate the model |
---|
| 102 | :param x: input q, or [q,phi] |
---|
| 103 | :return: scattering function P(q) |
---|
| 104 | """ |
---|
| 105 | return [CPYTHONCLASS].run(self, x) |
---|
[c93122e] | 106 | |
---|
[fd5ac0d] | 107 | def runXY(self, x=0.0): |
---|
[c93122e] | 108 | """ |
---|
[fd5ac0d] | 109 | Evaluate the model in cartesian coordinates |
---|
| 110 | :param x: input q, or [qx, qy] |
---|
| 111 | :return: scattering function P(q) |
---|
| 112 | """ |
---|
| 113 | return [CPYTHONCLASS].runXY(self, x) |
---|
[c93122e] | 114 | |
---|
[fd5ac0d] | 115 | def evalDistribution(self, x): |
---|
[c93122e] | 116 | """ |
---|
[fd5ac0d] | 117 | Evaluate the model in cartesian coordinates |
---|
| 118 | :param x: input q[], or [qx[], qy[]] |
---|
| 119 | :return: scattering function P(q[]) |
---|
| 120 | """ |
---|
| 121 | return [CPYTHONCLASS].evalDistribution(self, x) |
---|
[c93122e] | 122 | |
---|
[fd5ac0d] | 123 | def calculate_ER(self): |
---|
[c93122e] | 124 | """ |
---|
[fd5ac0d] | 125 | Calculate the effective radius for P(q)*S(q) |
---|
| 126 | :return: the value of the effective radius |
---|
[c93122e] | 127 | """ |
---|
[fd5ac0d] | 128 | return [CPYTHONCLASS].calculate_ER(self) |
---|
[c93122e] | 129 | |
---|
[fd5ac0d] | 130 | def calculate_VR(self): |
---|
[c93122e] | 131 | """ |
---|
[fd5ac0d] | 132 | Calculate the volf ratio for P(q)*S(q) |
---|
| 133 | :return: the value of the volf ratio |
---|
[c93122e] | 134 | """ |
---|
[fd5ac0d] | 135 | return [CPYTHONCLASS].calculate_VR(self) |
---|
[c93122e] | 136 | |
---|
[fd5ac0d] | 137 | def set_dispersion(self, parameter, dispersion): |
---|
| 138 | """ |
---|
| 139 | Set the dispersion object for a model parameter |
---|
| 140 | :param parameter: name of the parameter [string] |
---|
| 141 | :param dispersion: dispersion object of type DispersionModel |
---|
| 142 | """ |
---|
| 143 | return [CPYTHONCLASS].set_dispersion(self, |
---|
| 144 | parameter, dispersion.cdisp) |
---|
[c93122e] | 145 | |
---|
[fd5ac0d] | 146 | # End of file |
---|