Changeset ca6d914 in sasview for park_integration/ScipyFitting.py
- Timestamp:
- Sep 16, 2008 4:34:55 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:
- fadea71
- Parents:
- 3b19ac9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
park_integration/ScipyFitting.py
r48882d1 rca6d914 35 35 Use a sans model 36 36 37 Add data with a dictionnary of FitArrange List where Uid is a key and data37 Add data with a dictionnary of FitArrangeDict where Uid is a key and data 38 38 is saved in FitArrange object. 39 39 engine.set_data(data,Uid) … … 45 45 engine.set_param( model,"M1", {'A':2,'B':4}) 46 46 47 Add model with a dictionnary of FitArrange List{} where Uid is a key and model47 Add model with a dictionnary of FitArrangeDict{} where Uid is a key and model 48 48 is save in FitArrange object. 49 49 engine.set_model(model,Uid) … … 54 54 def __init__(self): 55 55 """ 56 Creates a dictionary (self.fitArrange List={})of FitArrange elements56 Creates a dictionary (self.fitArrangeDict={})of FitArrange elements 57 57 with Uid as keys 58 58 """ 59 self.fitArrange List={}59 self.fitArrangeDict={} 60 60 self.paramList=[] 61 61 def fit(self,qmin=None, qmax=None): 62 62 # Protect against simultanous fitting attempts 63 if len(self.fitArrange List)>1:63 if len(self.fitArrangeDict)>1: 64 64 raise RuntimeError, "Scipy can't fit more than a single fit problem at a time." 65 65 66 66 # fitproblem contains first fitArrange object(one model and a list of data) 67 fitproblem=self.fitArrange List.values()[0]67 fitproblem=self.fitArrangeDict.values()[0] 68 68 listdata=[] 69 69 model = fitproblem.get_model() … … 77 77 qmax= max(data.x) 78 78 functor= sansAssembly(model,data) 79 print "scipyfitting:param list",model.getParams(self.paramList) 80 print "scipyfitting:functor",functor(model.getParams(self.paramList)) 81 79 82 80 out, cov_x, info, mesg, success = optimize.leastsq(functor,model.getParams(self.paramList), full_output=1, warning=True) 83 81 chisqr = functor.chisq(out) 82 if cov_x is not None and numpy.isfinite(cov_x).all(): 83 stderr = numpy.sqrt(numpy.diag(cov_x)) 84 84 85 print "scipyfitting: info",mesg 86 print"scipyfitting : success",success 87 print "scipyfitting: out", out 88 print "scipyfitting: cov_x", cov_x 89 print "scipyfitting: chisqr", chisqr 90 91 if not (numpy.isnan(out).any()): 85 if not (numpy.isnan(out).any()) or ( cov_x !=None) : 92 86 result = fitresult() 93 87 result.fitness = chisqr 94 result.cov = cov_x 95 88 result.stderr = stderr 96 89 result.pvec = out 97 90 result.success =success … … 99 92 return result 100 93 else: 101 raise ValueError, "SVD did not converge" 94 raise ValueError, "SVD did not converge"+str(success) 102 95 103 96
Note: See TracChangeset
for help on using the changeset viewer.