Changeset 1780d59 in sasmodels
- Timestamp:
- Aug 24, 2014 10:27:38 PM (10 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:
- 1f21edf
- Parents:
- ce27e21
- Location:
- sasmodels
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/gpu.py
rce27e21 r1780d59 270 270 loops_N = [np.uint32(len(p[0])) for p in pd_pars] 271 271 272 #import sys; print >>sys.stderr,"opencl eval",pars 272 273 #print "opencl eval",pars 273 274 if len(loops) > MAX_LOOPS: -
sasmodels/models/cylinder_clone.c
rce27e21 r1780d59 209 209 // The additional volume factor is for polydisperse volume normalization. 210 210 const real s = (sldCyl - sldSolv) * form_volume(radius, length); 211 return REAL( 1.0e8) * form * s * s; // * correction;212 } 211 return REAL(4.0e8) * form * s * s; // * correction; 212 } -
sasmodels/sasview_model.py
rce27e21 r1780d59 4 4 import numpy as np 5 5 6 def make_class(name, class_name=None ):6 def make_class(name, class_name=None, dtype='single'): 7 7 from .core import opencl_model 8 8 if class_name is None: 9 9 class_name = "".join(part.capitalize() for part in name.split('_')+['model']) 10 model = opencl_model(name )10 model = opencl_model(name, dtype=dtype) 11 11 class ConstructedModel(SasviewModel): 12 12 kernel = model 13 13 def __init__(self, multfactor=1): 14 if self.kernel is None:15 self.__class__.kernel = opencl_model(name)16 14 SasviewModel.__init__(self, self.kernel) 17 15 ConstructedModel.__name__ = class_name … … 46 44 'width': 0, 47 45 'npts': 35, 48 'nsigma ': 3,46 'nsigmas': 3, 49 47 'type': 'gaussian', 50 48 } … … 160 158 Return a list of all available parameters for the model 161 159 """ 162 list = [] 163 164 for item in self.dispersion.keys(): 165 for p in self.dispersion[item].keys(): 166 if p not in ['type']: 167 list.append('%s.%s' % (item.lower(), p.lower())) 168 169 return list 160 # TODO: fix test so that parameter order doesn't matter 161 ret = ['%s.%s'%(d.lower(), p) 162 for d in self._model.info['partype']['pd-2d'] 163 for p in ('npts', 'nsigmas', 'width')] 164 #print ret 165 return ret 170 166 171 167 def clone(self): … … 295 291 :param dispersion: dispersion object of type Dispersion 296 292 """ 297 if parameter.lower() in (s.name.lower() for s in self.params.keys()): 293 if parameter.lower() in (s.lower() for s in self.params.keys()): 294 # TODO: Store the disperser object directly in the model. 295 # The current method of creating one on the fly whenever it is 296 # needed is kind of funky. 297 # Note: can't seem to get disperser parameters from sasview 298 # (1) Could create a sasview model that has not yet # been 299 # converted, assign the disperser to one of its polydisperse 300 # parameters, then retrieve the disperser parameters from the 301 # sasview model. (2) Could write a disperser parameter retriever 302 # in sasview. (3) Could modify sasview to use sasmodels.weights 303 # dispersers. 304 # For now, rely on the fact that the sasview only ever uses 305 # new dispersers in the set_dispersion call and create a new 306 # one instead of trying to assign parameters. 307 from . import weights 308 disperser = weights.dispersers[dispersion.__class__.__name__] 309 dispersion = weights.models[disperser]() 298 310 self.dispersion[parameter] = dispersion.get_pars() 299 311 else: … … 321 333 dis = self.dispersion[par] 322 334 v,w = weights.get_weights( 323 dis['type'], dis['npts'], dis['width'], dis['nsigma '],335 dis['type'], dis['npts'], dis['width'], dis['nsigmas'], 324 336 self.params[par], limits[par], par in relative) 325 337 return v,w/w.max() 338 -
sasmodels/weights.py
rce27e21 r1780d59 38 38 For orientation parameters use absolute. 39 39 """ 40 npts, width, nsigmas = self.npts, self.width, self.nsigmas41 40 sigma = self.width * center if relative else self.width 42 41 if sigma == 0: … … 122 121 )) 123 122 124 def get_weights(disperser, n, width, nsigma, value, limits, relative): 123 124 def get_weights(disperser, n, width, nsigmas, value, limits, relative): 125 125 cls = models[disperser] 126 obj = cls(n, width, nsigma )126 obj = cls(n, width, nsigmas) 127 127 v,w = obj.get_weights(value, limits[0], limits[1], relative) 128 128 return v,w 129 130 # Hack to allow sasview dispersion objects to interoperate with sasmodels 131 dispersers = dict((v.__name__,k) for k,v in models.items()) 132 dispersers['DispersionModel'] = RectangleDispersion.type 133
Note: See TracChangeset
for help on using the changeset viewer.