Changeset e71440c in sasview for park_integration
- Timestamp:
- Sep 23, 2008 3:11:08 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:
- 442895f
- Parents:
- 5f96484
- Location:
- park_integration
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
park_integration/AbstractFitEngine.py
rca6d914 re71440c 86 86 87 87 88 def setParams(self, params):88 def setParams(self,paramlist, params): 89 89 """ 90 90 Set value for parameters to fit 91 91 @param params: list of value for parameters to fit 92 92 """ 93 list=[]94 for item in self.parkp:95 list.append(item.name)96 list.sort()97 for i in range(len(params)):98 self.parkp[i].value = params[i]99 self.model.setParam(list[i],params[i])100 93 try: 94 for i in range(len(self.parkp)): 95 for j in range(len(paramlist)): 96 if self.parkp[i].name==paramlist[j]: 97 self.parkp[i].value = params[j] 98 self.model.setParam(self.parkp[i].name,params[j]) 99 except: 100 raise 101 101 102 102 def eval(self,x): … … 158 158 fx = numpy.asarray([fn(item)for item in x[idx ]]) 159 159 return (y[idx] - fx)/dy[idx] 160 161 162 160 163 161 def residuals_deriv(self, model, pars=[]): 164 162 """ … … 172 170 Sans Assembly class a class wrapper to be call in optimizer.leastsq method 173 171 """ 174 def __init__(self, Model=None , Data=None):172 def __init__(self,paramlist,Model=None , Data=None): 175 173 """ 176 174 @param Model: the model wrapper fro sans -model … … 179 177 self.model = Model 180 178 self.data = Data 179 self.paramlist=paramlist 181 180 self.res=[] 182 181 def chisq(self, params): … … 195 194 @param params: value of parameters to fit 196 195 """ 197 self.model.setParams( params)196 self.model.setParams(self.paramlist,params) 198 197 self.res= self.data.residuals(self.model.eval) 199 198 return self.res -
park_integration/ScipyFitting.py
rca6d914 re71440c 76 76 if qmax==None: 77 77 qmax= max(data.x) 78 functor= sansAssembly(model,data) 79 78 functor= sansAssembly(self.paramList,model,data) 80 79 out, cov_x, info, mesg, success = optimize.leastsq(functor,model.getParams(self.paramList), full_output=1, warning=True) 81 80 chisqr = functor.chisq(out) 81 82 82 if cov_x is not None and numpy.isfinite(cov_x).all(): 83 83 stderr = numpy.sqrt(numpy.diag(cov_x)) 84 84 else: 85 stderr=None 85 86 if not (numpy.isnan(out).any()) or ( cov_x !=None) : 86 87 result = fitresult() -
park_integration/test/testdata_line1.txt
r6b126e8 re71440c 1 #y=A *x+B2 # A=2.53 # B=41 #y=A+x*B 2 #B=2.5 3 #A=4 4 4 0 2.83954 0.6 5 5 0.204082 3.44938 0.6
Note: See TracChangeset
for help on using the changeset viewer.