Changeset 511c6810 in sasview for park_integration
- Timestamp:
- Mar 18, 2011 6:20:07 PM (14 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:
- 66ff250
- Parents:
- 5080cda
- Location:
- park_integration
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
park_integration/AbstractFitEngine.py
rc4d6900 r511c6810 403 403 Exception raise to stop the fit 404 404 """ 405 #print"Creating fit abort Exception"406 405 407 406 … … 450 449 451 450 """ 452 #import thread453 451 self.model.set_params(self.paramlist,params) 454 452 self.res = self.data.residuals(self.model.eval) 455 453 if self.fitresult is not None and self.handler is not None: 456 454 self.fitresult.set_model(model=self.model) 457 #fitness = self.chisq(params=params)458 455 fitness = self.chisq() 456 self.fitresult.pvec = params 459 457 self.fitresult.set_fitness(fitness=fitness) 460 458 self.handler.set_result(result=self.fitresult) 461 self.handler.update_fit() 462 463 #if self.curr_thread != None : 464 # try: 465 # self.curr_thread.isquit() 466 # except: 467 # raise FitAbort,"stop leastsqr optimizer" 459 #self.handler.update_fit() 460 if self.curr_thread != None : 461 try: 462 self.curr_thread.isquit() 463 except: 464 raise FitAbort,"stop leastsqr optimizer" 468 465 return self.res 469 466 -
park_integration/Fitting.py
rc4d6900 r511c6810 52 52 def fit(self, q=None, handler=None, curr_thread=None): 53 53 """Perform the fit """ 54 #try:55 54 return self._engine.fit(q, handler, curr_thread=curr_thread) 56 #except: 57 # raise 58 55 59 56 def set_model(self, model, id, pars=[], constraints=[]): 60 57 """ -
park_integration/ScipyFitting.py
r3ab116f r511c6810 8 8 9 9 import numpy 10 import sys 10 11 from scipy import optimize 11 12 12 13 from sans.fit.AbstractFitEngine import FitEngine 13 14 from sans.fit.AbstractFitEngine import SansAssembly 14 #from sans.fit.AbstractFitEngine import FitAbort 15 from sans.fit.AbstractFitEngine import FitAbort 16 15 17 16 18 class fitresult(object): … … 98 100 self.param_list = [] 99 101 self.curr_thread = None 102 self.result = None 100 103 #def fit(self, *args, **kw): 101 104 # return profile(self._fit, *args, **kw) … … 122 125 data = listdata 123 126 self.curr_thread = curr_thread 124 result = fitresult(model=model, param_list=self.param_list) 125 if handler is not None: 126 handler.set_result(result=result) 127 self.result = fitresult(model=model, param_list=self.param_list) 128 self.handler = handler 129 if self.handler is not None: 130 self.handler.set_result(result=self.result) 127 131 #try: 128 functor = SansAssembly(self.param_list, model, data, handler=handler, 129 fitresult=result, curr_thread= self.curr_thread) 130 out, cov_x, _, mesg, success = optimize.leastsq(functor, 132 functor = SansAssembly(self.param_list, model, data, handler=self.handler, 133 fitresult=self.result, curr_thread= self.curr_thread) 134 135 try: 136 out, cov_x, _, mesg, success = optimize.leastsq(functor, 131 137 model.get_params(self.param_list), 132 138 ftol = 0.001, 133 139 full_output=1, 134 140 warning=True) 135 141 except: 142 if sys.last_type == FitAbort: 143 if self.handler is not None: 144 msg = "Fit Stop!" 145 #self.handler.error(msg) 146 self.result = self.handler.get_result() 147 return self.result 148 else: 149 raise 150 136 151 chisqr = functor.chisq() 137 152 if cov_x is not None and numpy.isfinite(cov_x).all(): … … 139 154 else: 140 155 stderr = None 156 157 if (out is not None) and not (numpy.isnan(out).any()) \ 158 and (cov_x != None): 159 self.result.fitness = chisqr 160 self.result.stderr = stderr 161 self.result.pvec = out 162 self.result.success = success 163 else: 164 msg = "SVD did not converge " + str(mesg) 165 #handler.error(msg) 166 return self.result 141 167 142 if not (numpy.isnan(out).any()) and (cov_x != None): 143 result.fitness = chisqr 144 result.stderr = stderr 145 result.pvec = out 146 result.success = success 147 if q is not None: 148 q.put(result) 149 return q 150 return result 151 else: 152 raise ValueError, "SVD did not converge" + str(mesg) 168 153 169 154 170
Note: See TracChangeset
for help on using the changeset viewer.