Changeset 388309d in sasview for park_integration
- Timestamp:
- Sep 12, 2008 12:05:19 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:
- e7430b6
- Parents:
- 49b7efa
- Location:
- park_integration
- Files:
-
- 1 added
- 3 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
park_integration/AbstractFitEngine.py
rd831626 r388309d 34 34 PARK wrapper for SANS models. 35 35 """ 36 def __init__(self, sans_model ):36 def __init__(self, sans_model, **kw): 37 37 self.model = sans_model 38 38 self.name=sans_model.name … … 44 44 self.parameterset = park.ParameterSet(sans_model.name,pars=self.parkp) 45 45 self.pars=[] 46 46 47 #def __call__(self, x, pars=[]): 48 # return self.eval(x) 47 49 def getParams(self,fitparams): 48 50 list=[] … … 62 64 list.sort() 63 65 for i in range(len(params)): 64 #self.parkp[i].value = params[i]65 #print "abstractfitengine: set-params",list[i],params[i]66 self.parkp[i].value = params[i] 67 print "abstractfitengine: set-params",list[i],params[i] 66 68 67 69 self.model.setParam(list[i],params[i]) … … 70 72 71 73 return self.model.runXY(x) 72 73 74 75 #def set(self, **kw): 76 #""" 77 #Set the initial value for a set of parameters. 78 #E.g., model.set(width=3,center=5) 79 #""" 80 #print "Abstractfitting : set called" 81 # This is a convenience funciton for the user. 82 # 83 #for k,v in kw.items(): 84 # self.parameterset[k].set(v) 85 74 86 class Data(object): 75 87 """ Wrapper class for SANS data """ -
park_integration/ParkFitting.py
r48882d1 r388309d 68 68 #if p.isfixed(): 69 69 #print 'parameters',p.name 70 print "parkfitting: self.paramList",self.paramList70 #print "parkfitting: self.paramList",self.paramList 71 71 if p.isfixed() and p._getname()in self.paramList: 72 #if p.isfixed(): 72 73 p.set([-numpy.inf,numpy.inf]) 73 74 i+=1 … … 108 109 localfit = FitSimplex() 109 110 localfit.ftol = 1e-8 111 #localfit.ftol = 1e-6 110 112 fitter = FitMC(localfit=localfit) 111 print "ParkFitting: result1" 113 print "ParkFitting: result1",pars 114 print "Parkfitting: in fit function fitness resid",self.problem[0].residuals() 115 116 list=self.problem[0]._parameterset() 117 print "Parkfitting: in fit function fitness paramset",list 118 for item in list: 119 print "Parkfitting: in fit function fitness",item.name, item.value,item.path,item.range 112 120 result = fit.fit(self.problem, 113 121 fitter=fitter, 114 122 handler= fitresult.ConsoleUpdate(improvement_delta=0.1)) 115 print "ParkFitting: result",result 123 #result = fit.fit(self.problem) 124 print "ParkFitting: result",result.fitness,result.pvec,result.cov 116 125 if result !=None: 117 126 #for p in result.parameters: -
park_integration/test/testnewscipy.py
r48882d1 r388309d 22 22 #Importing the Fit module 23 23 from sans.fit.Fitting import Fit 24 fitter= Fit(' scipy')24 fitter= Fit('park') 25 25 26 26 # Receives the type of model for the fitting … … 31 31 #Do the fit SCIPY 32 32 33 fitter.set_data _assembly(data1,1)34 fitter.set_model _assembly(model,"M1",1,['A','B'])33 fitter.set_data(data1,1) 34 fitter.set_model(model,"M1",1,['A','B']) 35 35 36 36 result=fitter.fit() 37 print "scipy",result.pvec, 38 chisqr1, out1, cov1=fitter.fit() 39 """ testing SCIPy results""" 40 self.assert_(math.fabs(out1[1]-2.5)/math.sqrt(cov1[1][1]) < 2) 41 self.assert_(math.fabs(out1[0]-4.0)/math.sqrt(cov1[0][0]) < 2) 42 self.assert_(chisqr1/len(data1.x) < 2) 43 37 print "park",result.pvec, 38 39 self.assert_(result) 44 40 41 def test_cylinder_scipy(self): 42 """ test fitting large model with scipy""" 43 #load data 44 from sans.fit.Loader import Load 45 load= Load() 46 load.set_filename("cyl_testdata.txt") 47 load.set_values() 48 data11 = Data1D(x=[], y=[],dx=None, dy=None) 49 load.load_data(data11) 50 data1=Data(sans_data=data11) 51 52 53 #Importing the Fit module 54 from sans.fit.Fitting import Fit 55 fitter= Fit('park') 56 57 # Receives the type of model for the fitting 58 from sans.models.CylinderModel import CylinderModel 59 model1 = CylinderModel() 60 model =Model(model1) 61 62 #Do the fit SCIPY 63 fitter.set_data(data1,1) 64 import math 65 pars1=['background','contrast', 'length'] 66 #pars1=['background','contrast',\ 67 # 'cyl_phi','cyl_theta','length','radius','scale'] 68 pars1.sort() 69 fitter.set_model(model,"M1",1,pars1) 70 fitter.set_data(data1,1) 71 72 result=fitter.fit() 73 print "park",result.fitness,result.cov, result.pvec 74 self.assert_(result.fitness) 75 76 77
Note: See TracChangeset
for help on using the changeset viewer.