Changeset fb7180c in sasview
- Timestamp:
- May 7, 2014 6:50:18 PM (11 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- e544c84
- Parents:
- f121904
- Files:
-
- 5 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
park-1.2.1/park/parameter.py
r3570545 rfb7180c 15 15 __all__ = ['Parameter', 'ParameterSet'] 16 16 17 import math 17 18 import numpy 18 19 import expression … … 162 163 """ 163 164 range = ['.']*10 164 lo,hi = p.range165 portion = ( p.value-lo)/(hi-lo)165 lo,hi = self.range 166 portion = (self.value-lo)/(hi-lo) 166 167 if portion < 0: portion = 0. 167 168 elif portion >= 1: portion = 0.99999999 … … 169 170 range[bar] = '|' 170 171 range = "".join(range) 171 return "%25s %s %g in [%g,%g]" % ( p.name,range,p.value,lo,hi)172 return "%25s %s %g in [%g,%g]" % (self.name,range,self.value,lo,hi) 172 173 173 174 def isfitted(self): return self.status == 'fitted' … … 273 274 for p in self: 274 275 if parts[1] == p.name: 275 if len(par s) == 2:276 if len(parts) == 2: 276 277 return p 277 278 elif isinstance(p, ParameterSet): 278 279 return p._byname(parts[1:]) 280 else: 281 raise 279 282 return None 280 283 … … 283 286 parts = name.split('.') 284 287 if parts[0] == self.name: 285 p = _byname(self,name.split('.'))288 p = self._byname(name.split('.')) 286 289 if p: return p 287 290 raise KeyError("parameter %s not in parameter set"%name) -
src/sans/fit/AbstractFitEngine.py
r95d58d3 rfb7180c 428 428 429 429 sasmodel = model.model 430 if len(constraints) > 0: 431 for constraint in constraints: 432 name, value = constraint 433 try: 434 model.parameterset[str(name)].set(str(value)) 435 except: 436 msg = "Fit Engine: Error occurs when setting the constraint" 437 msg += " %s for parameter %s " % (value, name) 438 raise ValueError, msg 439 430 model.constraints = constraints 431 440 432 if len(pars) > 0: 441 433 temp = [] … … 610 602 def __init__(self, model=None, param_list=None, data=None): 611 603 self.calls = None 612 self.pars = []613 604 self.fitness = None 614 605 self.chisqr = None … … 621 612 self.residuals = [] 622 613 self.index = [] 623 self.parameters = None624 614 self.model = model 625 615 self.data = data -
src/sans/fit/BumpsFitting.py
red4aef2 rfb7180c 182 182 """ 183 183 # Note: technically, unbounded fitters and unmonitored fitters are 184 self.setp( x)184 self.setp(p) 185 185 186 186 # Compute penalty for being out of bounds which increases the farther -
src/sans/fit/ParkFitting.py
r95d58d3 rfb7180c 122 122 """ 123 123 list_params = [] 124 self.pars = []125 124 self.pars = fitparams 126 125 for item in fitparams: … … 501 500 if fproblem.get_to_fit() == 1: 502 501 fitproblems.append(fproblem) 503 if len(fitproblems) == 0: 502 if len(fitproblems) == 0: 504 503 raise RuntimeError, "No Assembly scheduled for Park fitting." 505 return506 504 for item in fitproblems: 507 505 model = item.get_model() … … 512 510 ind = item.pars.index(name) 513 511 parkmodel.model.setParam(name, item.vals[ind]) 512 513 # set the constraints into the model 514 for p,v in model.constraints: 515 parkmodel.parameterset[str(p)].set(str(v)) 514 516 515 517 for p in parkmodel.parameterset: 516 518 ## does not allow status change for constraint parameters 517 519 if p.status != 'computed': 518 if p.get_name() in item.pars:520 if p.get_name() in item.pars: 519 521 ## make parameters selected for 520 522 #fit will be between boundaries … … 583 585 if result is not None: 584 586 for p in result.parameters: 585 if p.data.name == small_result.data.name and \586 587 #if p.data.name == small_result.data.name and 588 if p.model.name == small_result.model.name: 587 589 small_result.index = m.data.idx 588 590 small_result.fitness = result.fitness -
src/sans/perspectives/fitting/simfitpage.py
r5777106 rfb7180c 378 378 box_description = wx.StaticBox(self, -1,"Easy Setup ") 379 379 boxsizer = wx.StaticBoxSizer(box_description, wx.HORIZONTAL) 380 sizer_constraint = wx.BoxSizer(wx.HORIZONTAL |wx.LEFT|wx.RIGHT|wx.EXPAND)380 sizer_constraint = wx.BoxSizer(wx.HORIZONTAL) 381 381 self.model_cbox_left = wx.ComboBox(self, -1, style=wx.CB_READONLY) 382 382 self.model_cbox_left.Clear() -
test/park_integration/test/utest_fit_cylinder.py
rda5d8e8 rfb7180c 100 100 fitter.set_data(self.data1,1) 101 101 fitter.set_model(self.model1, 1, ['length','radius','scale']) 102 102 103 103 fitter.set_data(self.data2,2) 104 104 fitter.set_model(self.model2, 2, ['radius','scale']) … … 110 110 def test_park2(self): 111 111 """ Simultaneous cylinder model fit (park) """ 112 raise NotImplementedError() 113 result1,= self._fit('park') 112 result1, result2 = self._fit('park') 114 113 self.assert_(result1) 115 self.assertTrue(len(result1.pvec)>=0 ) 116 self.assertTrue(len(result1.stderr)>= 0) 117 118 for par in result1.parameters: 119 if par.name=='C1.length': 120 print par.name, par.value 121 self.assertTrue( math.fabs(par.value-400.0)/3.0 < par.stderr ) 122 elif par.name=='C1.radius': 123 print par.name, par.value 124 self.assertTrue( math.fabs(par.value-20.0)/3.0 < par.stderr ) 125 elif par.name=='C2.radius': 126 print par.name, par.value 127 self.assertTrue( math.fabs(par.value-40.0)/3.0 < par.stderr ) 128 elif par.name=='C1.scale': 129 print par.name, par.value 130 self.assertTrue( math.fabs(par.value-1.0)/3.0 < par.stderr ) 131 elif par.name=='C2.scale': 132 print par.name, par.value 133 self.assertTrue( math.fabs(par.value-1.0)/3.0 < par.stderr ) 134 114 self.assertTrue(len(result1.pvec)>0) 115 self.assertTrue(len(result1.stderr)>0) 116 117 for n, v, dv in zip(result1.param_list, result1.pvec, result1.stderr): 118 print "M1.%s = %s +/- %s"%(n,v,dv) 119 if n == "length": 120 self.assertTrue( math.fabs(v-400.0)/3.0 < dv ) 121 elif n=='radius': 122 self.assertTrue( math.fabs(v-20.0)/3.0 < dv ) 123 elif n=='scale': 124 self.assertTrue( math.fabs(v-1.0)/3.0 < dv ) 125 for n, v, dv in zip(result2.param_list, result2.pvec, result2.stderr): 126 print "M2.%s = %s +/- %s"%(n,v,dv) 127 if n=='radius': 128 self.assertTrue( math.fabs(v-40.0)/3.0 < dv ) 129 elif n=='scale': 130 self.assertTrue( math.fabs(v-1.0)/3.0 < dv ) 131 135 132 136 133 if __name__ == '__main__':
Note: See TracChangeset
for help on using the changeset viewer.