[eba9885] | 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 | ############################################################################## |
---|
[eba9885] | 16 | |
---|
| 17 | |
---|
[79ac6f8] | 18 | """ |
---|
| 19 | Provide functionality for a C extension model |
---|
[eba9885] | 20 | |
---|
[79ac6f8] | 21 | :WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY |
---|
| 22 | DO NOT MODIFY THIS FILE, MODIFY ..\c_extensions\schulz.h |
---|
| 23 | AND RE-RUN THE GENERATOR SCRIPT |
---|
[eba9885] | 24 | |
---|
| 25 | """ |
---|
| 26 | |
---|
| 27 | from sans.models.BaseComponent import BaseComponent |
---|
| 28 | from sans_extension.c_models import CSchulz |
---|
| 29 | import copy |
---|
| 30 | |
---|
| 31 | class Schulz(CSchulz, BaseComponent): |
---|
[79ac6f8] | 32 | """ |
---|
| 33 | Class that evaluates a Schulz model. |
---|
| 34 | This file was auto-generated from ..\c_extensions\schulz.h. |
---|
| 35 | Refer to that file and the structure it contains |
---|
| 36 | for details of the model. |
---|
| 37 | List of default parameters: |
---|
[eba9885] | 38 | scale = 1.0 |
---|
| 39 | sigma = 1.0 |
---|
| 40 | center = 0.0 |
---|
| 41 | |
---|
| 42 | """ |
---|
| 43 | |
---|
| 44 | def __init__(self): |
---|
| 45 | """ Initialization """ |
---|
| 46 | |
---|
| 47 | # Initialize BaseComponent first, then sphere |
---|
| 48 | BaseComponent.__init__(self) |
---|
| 49 | CSchulz.__init__(self) |
---|
| 50 | |
---|
| 51 | ## Name of the model |
---|
| 52 | self.name = "Schulz" |
---|
| 53 | ## Model description |
---|
| 54 | self.description =""" f(x)=scale * math.pow(z+1, z+1)*math.pow((R), z)* |
---|
| 55 | math.exp(-R*(z+1))/(center*gamma(z+1) |
---|
| 56 | z= math.pow[(1/(sigma/center),2]-1""" |
---|
| 57 | |
---|
[fe9c19b4] | 58 | ## Parameter details [units, min, max] |
---|
[eba9885] | 59 | self.details = {} |
---|
| 60 | self.details['scale'] = ['', None, None] |
---|
| 61 | self.details['sigma'] = ['', None, None] |
---|
| 62 | self.details['center'] = ['', None, None] |
---|
| 63 | |
---|
[fe9c19b4] | 64 | ## fittable parameters |
---|
[eba9885] | 65 | self.fixed=[] |
---|
| 66 | |
---|
| 67 | ## parameters with orientation |
---|
| 68 | self.orientation_params =[] |
---|
| 69 | |
---|
| 70 | def clone(self): |
---|
| 71 | """ Return a identical copy of self """ |
---|
| 72 | return self._clone(Schulz()) |
---|
[fe9c19b4] | 73 | |
---|
| 74 | def __getstate__(self): |
---|
[79ac6f8] | 75 | """ |
---|
| 76 | return object state for pickling and copying |
---|
| 77 | """ |
---|
[fe9c19b4] | 78 | model_state = {'params': self.params, 'dispersion': self.dispersion, 'log': self.log} |
---|
| 79 | |
---|
| 80 | return self.__dict__, model_state |
---|
| 81 | |
---|
| 82 | def __setstate__(self, state): |
---|
[79ac6f8] | 83 | """ |
---|
| 84 | create object from pickled state |
---|
| 85 | |
---|
| 86 | :param state: the state of the current model |
---|
| 87 | |
---|
| 88 | """ |
---|
[fe9c19b4] | 89 | |
---|
| 90 | self.__dict__, model_state = state |
---|
| 91 | self.params = model_state['params'] |
---|
| 92 | self.dispersion = model_state['dispersion'] |
---|
| 93 | self.log = model_state['log'] |
---|
| 94 | |
---|
[eba9885] | 95 | |
---|
[79ac6f8] | 96 | def run(self, x=0.0): |
---|
| 97 | """ |
---|
| 98 | Evaluate the model |
---|
| 99 | |
---|
| 100 | :param x: input q, or [q,phi] |
---|
| 101 | |
---|
| 102 | :return: scattering function P(q) |
---|
| 103 | |
---|
[eba9885] | 104 | """ |
---|
| 105 | |
---|
| 106 | return CSchulz.run(self, x) |
---|
| 107 | |
---|
[79ac6f8] | 108 | def runXY(self, x=0.0): |
---|
| 109 | """ |
---|
| 110 | Evaluate the model in cartesian coordinates |
---|
| 111 | |
---|
| 112 | :param x: input q, or [qx, qy] |
---|
| 113 | |
---|
| 114 | :return: scattering function P(q) |
---|
| 115 | |
---|
[eba9885] | 116 | """ |
---|
| 117 | |
---|
| 118 | return CSchulz.runXY(self, x) |
---|
| 119 | |
---|
[79ac6f8] | 120 | def evalDistribution(self, x=[]): |
---|
| 121 | """ |
---|
| 122 | Evaluate the model in cartesian coordinates |
---|
| 123 | |
---|
| 124 | :param x: input q[], or [qx[], qy[]] |
---|
| 125 | |
---|
| 126 | :return: scattering function P(q[]) |
---|
| 127 | |
---|
[eba9885] | 128 | """ |
---|
[f9a1279] | 129 | return CSchulz.evalDistribution(self, x) |
---|
[eba9885] | 130 | |
---|
[5eb9154] | 131 | def calculate_ER(self): |
---|
[79ac6f8] | 132 | """ |
---|
| 133 | Calculate the effective radius for P(q)*S(q) |
---|
| 134 | |
---|
| 135 | :return: the value of the effective radius |
---|
| 136 | |
---|
[5eb9154] | 137 | """ |
---|
| 138 | return CSchulz.calculate_ER(self) |
---|
| 139 | |
---|
[eba9885] | 140 | def set_dispersion(self, parameter, dispersion): |
---|
| 141 | """ |
---|
[79ac6f8] | 142 | Set the dispersion object for a model parameter |
---|
| 143 | |
---|
| 144 | :param parameter: name of the parameter [string] |
---|
| 145 | :param dispersion: dispersion object of type DispersionModel |
---|
| 146 | |
---|
[eba9885] | 147 | """ |
---|
| 148 | return CSchulz.set_dispersion(self, parameter, dispersion.cdisp) |
---|
| 149 | |
---|
| 150 | |
---|
| 151 | # End of file |
---|