Changeset 95d58d3 in sasview for src/sans/fit/AbstractFitEngine.py
- Timestamp:
- Apr 10, 2014 8:05:28 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:
- 90f49a8
- Parents:
- 6fe5100
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sans/fit/AbstractFitEngine.py
r6fe5100 r95d58d3 58 58 Fit was aborted. 59 59 """ 60 61 # TODO: not sure how these are used, but they are needed for running the fit 62 def update_fit(self, last=False): pass 63 def set_result(self, result=None): self.result = result 60 64 61 65 class Model: … … 217 221 """ 218 222 return self.qmin, self.qmax 219 223 224 def size(self): 225 """ 226 Number of measurement points in data set after masking, etc. 227 """ 228 return len(self.x) 229 220 230 def residuals(self, fn): 221 231 """ … … 259 269 def __init__(self, sans_data2d, data=None, err_data=None): 260 270 Data2D.__init__(self, data=data, err_data=err_data) 261 """ 262 Data can be initital with a data (sans plottable) 263 or with vectors. 264 """ 271 # Data can be initialized with a sans plottable or with vectors. 265 272 self.res_err_image = [] 266 self.num_points = data.size273 self.num_points = 0 # will be set by set_data 267 274 self.idx = [] 268 275 self.qmin = None … … 306 313 self.idx = (self.idx) & (self.mask) 307 314 self.idx = (self.idx) & (numpy.isfinite(self.data)) 315 self.num_points = numpy.sum(self.idx) 308 316 309 317 def set_smearer(self, smearer): … … 339 347 """ 340 348 return self.qmin, self.qmax 341 349 350 def size(self): 351 """ 352 Number of measurement points in data set after masking, etc. 353 """ 354 return numpy.sum(self.idx) 355 342 356 def residuals(self, fn): 343 357 """ … … 410 424 raise ValueError, "AbstractFitEngine: Need to set model to fit" 411 425 412 new_model = model413 426 if not issubclass(model.__class__, Model): 414 new_model = Model(model, data) 415 427 model = Model(model, data) 428 429 sasmodel = model.model 416 430 if len(constraints) > 0: 417 431 for constraint in constraints: 418 432 name, value = constraint 419 433 try: 420 new_model.parameterset[str(name)].set(str(value))434 model.parameterset[str(name)].set(str(value)) 421 435 except: 422 436 msg = "Fit Engine: Error occurs when setting the constraint" … … 427 441 temp = [] 428 442 for item in pars: 429 if item in new_model.model.getParamList():443 if item in sasmodel.getParamList(): 430 444 temp.append(item) 431 445 self.param_list.append(item) … … 433 447 434 448 msg = "wrong parameter %s used " % str(item) 435 msg += "to set model %s. Choose " % str( new_model.model.name)449 msg += "to set model %s. Choose " % str(sasmodel.name) 436 450 msg += "parameter name within %s" % \ 437 str( new_model.model.getParamList())451 str(sasmodel.getParamList()) 438 452 raise ValueError, msg 439 453 440 454 #A fitArrange is already created but contains data_list only at id 441 455 if self.fit_arrange_dict.has_key(id): 442 self.fit_arrange_dict[id].set_model( new_model)456 self.fit_arrange_dict[id].set_model(model) 443 457 self.fit_arrange_dict[id].pars = pars 444 458 else: 445 459 #no fitArrange object has been create with this id 446 460 fitproblem = FitArrange() 447 fitproblem.set_model( new_model)461 fitproblem.set_model(model) 448 462 fitproblem.pars = pars 449 463 self.fit_arrange_dict[id] = fitproblem 450 464 vals = [] 451 465 for name in pars: 452 vals.append( new_model.model.getParam(name))466 vals.append(sasmodel.getParam(name)) 453 467 self.fit_arrange_dict[id].vals = vals 454 468 else: … … 634 648 return "No results" 635 649 636 pars = enumerate(self.model.model.getParamList()) 650 sasmodel = self.model.model 651 pars = enumerate(sasmodel.getParamList()) 637 652 msg1 = "[Iteration #: %s ]" % self.iterations 638 653 msg3 = "=== goodness of fit: %s ===" % (str(self.fitness)) 639 msg2 = ["P%-3d %s......|.....%s" % (i, v, s elf.model.model.getParam(v))654 msg2 = ["P%-3d %s......|.....%s" % (i, v, sasmodel.getParam(v)) 640 655 for i,v in pars if v in self.param_list] 641 656 msg = [msg1, msg3] + msg2 … … 645 660 """ 646 661 """ 647 print s elf662 print str(self)
Note: See TracChangeset
for help on using the changeset viewer.