Changeset abb22f4 in sasmodels
- Timestamp:
- Sep 3, 2014 3:40:58 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:
- 0496031
- Parents:
- 1c7ffdc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
fit.py
r87985ca rabb22f4 20 20 data = radial_data if section is not "tangent" else tan_data 21 21 kernel = sas.load_model(name, dtype="single") 22 cutoff = 1e-3 22 23 23 24 if name == "ellipsoid": … … 40 41 #model.theta_pd.range(0, 360) 41 42 #model.background.range(0,1000) 42 model.scale.range(0, 1 )43 model.scale.range(0, 10) 43 44 44 45 … … 71 72 """ 72 73 pars = dict( 73 scale=.01, radius=64.1, length=66.96, sld=.291, solvent_sld=5.77, background=.1, 74 scale=.01, background=35, 75 sld=.291, solvent_sld=5.77, 76 radius=250, length=178, 74 77 theta=90, phi=0, 75 radius_pd=0.1, radius_pd_n= 10, radius_pd_nsigma=3,78 radius_pd=0.1, radius_pd_n=5, radius_pd_nsigma=3, 76 79 length_pd=0.1,length_pd_n=5, length_pd_nsigma=3, 77 theta_pd= 0.1, theta_pd_n=5, theta_pd_nsigma=3,78 phi_pd=0 .1, phi_pd_n=10, phi_pd_nsigma=3)80 theta_pd=10, theta_pd_n=50, theta_pd_nsigma=3, 81 phi_pd=0, phi_pd_n=10, phi_pd_nsigma=3) 79 82 model = sas.BumpsModel(data, kernel, **pars) 80 81 82 83 83 84 # SET THE FITTING PARAMETERS 84 85 model.radius.range(1, 500) 85 86 model.length.range(1, 5000) 86 #model.theta.range(-90,100) 87 #model.theta_pd.range(0, 90) 88 #model.theta_pd_n = model.theta_pd + 5 89 #model.radius_pd.range(0, 90) 90 #model.length_pd.range(0, 90) 91 model.scale.range(0, 1) 92 #model.background.range(0, 100) 93 #model.sld.range(0, 1) 87 model.theta.range(-90,100) 88 model.theta_pd.range(0, 30) 89 model.theta_pd_n = model.theta_pd + 5 90 model.radius_pd.range(0, 1) 91 model.length_pd.range(0, 2) 92 model.scale.range(0, 10) 93 model.background.range(0, 100) 94 94 95 95 … … 161 161 sys.exit(1) 162 162 163 model.cutoff = cutoff 163 164 if section is "both": 164 165 tan_model = sas.BumpsModel(tan_data, model.model, model.parameters()) … … 167 168 else: 168 169 problem = FitProblem(model) 169 -
sasmodels/bumps_model.py
r87985ca rabb22f4 249 249 def __init__(self, data, model, cutoff=1e-5, **kw): 250 250 from bumps.names import Parameter 251 partype = model.info['partype']252 251 253 252 # remember inputs so we can inspect from outside 254 253 self.data = data 255 254 self.model = model 255 self.cutoff = cutoff 256 257 partype = model.info['partype'] 256 258 257 259 # interpret data … … 271 273 self._theory = np.zeros_like(data.y) 272 274 q_vectors = [data.x] 273 #input = model.make_input(q_vectors) 274 input = model.make_input([v[self.index] for v in q_vectors]) 275 276 # create model 277 self.fn = model(input) 278 self.cutoff = cutoff 275 276 # Remember function inputs so we can delay loading the function and 277 # so we can save/restore state 278 self._fn_inputs = [v[self.index] for v in q_vectors] 279 self._fn = None 279 280 280 281 # define bumps parameters 281 282 pars = [] 282 extras = []283 283 for p in model.info['parameters']: 284 284 name, default, limits, ptype = p[0], p[2], p[3], p[4] … … 315 315 def theory(self): 316 316 if 'theory' not in self._cache: 317 pars = [getattr(self,p).value for p in self.fn.fixed_pars] 318 pd_pars = [self._get_weights(p) for p in self.fn.pd_pars] 317 if self._fn is None: 318 input = self.model.make_input(self._fn_inputs) 319 self._fn = self.model(input) 320 321 pars = [getattr(self,p).value for p in self._fn.fixed_pars] 322 pd_pars = [self._get_weights(p) for p in self._fn.pd_pars] 319 323 #print pars 320 self._theory[self.index] = self. fn(pars, pd_pars, self.cutoff)321 #self._theory[:] = self. fn.eval(pars, pd_pars)324 self._theory[self.index] = self._fn(pars, pd_pars, self.cutoff) 325 #self._theory[:] = self._fn.eval(pars, pd_pars) 322 326 self._cache['theory'] = self._theory 323 327 return self._cache['theory'] … … 344 348 from . import weights 345 349 346 relative = self. fn.info['partype']['pd-rel']347 limits = self. fn.info['limits']350 relative = self.model.info['partype']['pd-rel'] 351 limits = self.model.info['limits'] 348 352 disperser,value,npts,width,nsigma = [getattr(self, par+ext) 349 353 for ext in ('_pd_type','','_pd_n','_pd','_pd_nsigma')] … … 353 357 return v,w/w.max() 354 358 359 def __getstate__(self): 360 # Can't pickle gpu functions, so instead make them lazy 361 state = self.__dict__.copy() 362 state['_fn'] = None 363 return state 364 365 def __setstate__(self, state): 366 self.__dict__ = state 367 355 368 356 369 def demo():
Note: See TracChangeset
for help on using the changeset viewer.