Changeset 4bd557d in sasview for park_integration/ScipyFitting.py
- Timestamp:
- Apr 24, 2009 4:34:48 PM (16 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:
- ad6dd4c
- Parents:
- 813334e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
park_integration/ScipyFitting.py
reef2e0ed r4bd557d 10 10 from scipy import optimize 11 11 12 from AbstractFitEngine import FitEngine, sansAssembly 12 from AbstractFitEngine import FitEngine, sansAssembly,FitAbort 13 print "in ScipyFitting fitabort",id(FitAbort),FitAbort.__class__.__module__ 13 14 14 15 class fitresult: … … 27 28 parameters= None 28 29 30 class old_FitAbort(Exception): 31 """ 32 Exception raise to stop the fit 33 """ 29 34 class ScipyFit(FitEngine): 30 35 """ … … 62 67 # return profile(self._fit, *args, **kw) 63 68 64 def fit(self ,handler=None ):69 def fit(self ,handler=None,curr_thread= None): 65 70 66 71 fitproblem=[] … … 81 86 #data=self._concatenateData( listdata) 82 87 data=listdata 83 functor= sansAssembly(self.paramList,model,data)88 self.curr_thread= curr_thread 84 89 85 out, cov_x, info, mesg, success = optimize.leastsq(functor,model.getParams(self.paramList), full_output=1, warning=True) 86 chisqr = functor.chisq(out) 90 try: 91 functor= sansAssembly(self.paramList,model,data, curr_thread= self.curr_thread) 92 out, cov_x, info, mesg, success = optimize.leastsq(functor,model.getParams(self.paramList), full_output=1, warning=True) 93 94 chisqr = functor.chisq(out) 95 96 if cov_x is not None and numpy.isfinite(cov_x).all(): 97 stderr = numpy.sqrt(numpy.diag(cov_x)) 98 else: 99 stderr=None 100 if not (numpy.isnan(out).any()) or ( cov_x !=None) : 101 result = fitresult() 102 result.fitness = chisqr 103 result.stderr = stderr 104 result.pvec = out 105 result.success =success 106 return result 107 else: 108 raise ValueError, "SVD did not converge"+str(success) 109 except FitAbort: 110 ## fit engine is stop 111 print "fitabort====>" 112 return None 87 113 88 if cov_x is not None and numpy.isfinite(cov_x).all(): 89 stderr = numpy.sqrt(numpy.diag(cov_x)) 90 else: 91 stderr=None 92 if not (numpy.isnan(out).any()) or ( cov_x !=None) : 93 result = fitresult() 94 result.fitness = chisqr 95 result.stderr = stderr 96 result.pvec = out 97 result.success =success 98 99 return result 100 else: 101 raise ValueError, "SVD did not converge"+str(success) 102 114 except: 115 return Fitresult() 103 116 104 117 def profile(fn, *args, **kw):
Note: See TracChangeset
for help on using the changeset viewer.