Changeset 823e620 in sasmodels for sasmodels/weights.py
- Timestamp:
- Jan 29, 2016 10:46:54 PM (8 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- eafc9fa
- Parents:
- 803f835
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/weights.py
r3c56da87 r823e620 36 36 *center* is the center of the distribution 37 37 38 *lb*, *ub* are the min and max allowed values38 *lb*, *ub* are the min and max allowed values 39 39 40 40 *relative* is True if the distribution width is proportional to the … … 84 84 default = dict(npts=80, width=0, nsigmas=8) 85 85 def _weights(self, center, sigma, lb, ub): 86 x = self._linspace(center, sigma, max(lb, 1e-8), max(ub,1e-8))86 x = self._linspace(center, sigma, max(lb, 1e-8), max(ub, 1e-8)) 87 87 px = np.exp(-0.5*(np.log(x)-center)**2)/sigma**2/(x*sigma) 88 88 return x, px … … 93 93 default = dict(npts=80, width=0, nsigmas=8) 94 94 def _weights(self, center, sigma, lb, ub): 95 x = self._linspace(center, sigma, max(lb, 1e-8), max(ub,1e-8))96 R = x/center95 x = self._linspace(center, sigma, max(lb, 1e-8), max(ub, 1e-8)) 96 R = x/center 97 97 z = (center/sigma)**2 98 98 arg = z*np.log(z) + (z-1)*np.log(R) - R*z - np.log(center) - gammaln(z) … … 117 117 # TODO: interpolate into the array dispersion using npts 118 118 x = center + self.values*sigma 119 idx = (x >=lb)&(x<=ub)119 idx = (x >= lb) & (x <= ub) 120 120 x = x[idx] 121 121 px = self.weights[idx] … … 124 124 125 125 # dispersion name -> disperser lookup table. 126 models = dict((d.type, d) for d in (126 models = dict((d.type, d) for d in ( 127 127 GaussianDispersion, RectangleDispersion, 128 128 ArrayDispersion, SchulzDispersion, LogNormalDispersion … … 149 149 of the parameter, and false if it is an absolute width. 150 150 151 Returns *(value, weight)*, where *value* and *weight* are vectors.151 Returns *(value, weight)*, where *value* and *weight* are vectors. 152 152 """ 153 153 cls = models[disperser] 154 154 obj = cls(n, width, nsigmas) 155 v, w = obj.get_weights(value, limits[0], limits[1], relative)156 return v, w155 v, w = obj.get_weights(value, limits[0], limits[1], relative) 156 return v, w 157 157 158 158 # Hack to allow sasview dispersion objects to interoperate with sasmodels 159 dispersers = dict((v.__name__, k) for k,v in models.items())159 dispersers = dict((v.__name__, k) for k, v in models.items()) 160 160 dispersers['DispersionModel'] = RectangleDispersion.type 161 161
Note: See TracChangeset
for help on using the changeset viewer.