Changeset f24b8f4 in sasview for park_integration/docs
- Timestamp:
- May 23, 2008 9:10:39 AM (17 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:
- a1718df
- Parents:
- dfb58f8
- Location:
- park_integration/docs
- Files:
-
- 1 added
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
park_integration/docs/FittingModule.py
reb06cbe rf24b8f4 8 8 def __init__(self): 9 9 """ 10 Store a set of data for a given model to perform the Fit 10 11 @param model: the model selected by the user 11 12 @param Ldata: a list of data what the user want to fit … … 47 48 """ 48 49 def __init__(self,data=[]): 49 #self.model is a list of all models to fit 50 #self.model={} 50 #this is a dictionary of FitArrange elements 51 51 self.fitArrangeList={} 52 #the list of all data to fit 53 self.data = data 54 #list of models parameters 55 self.parameters=[] 56 52 #the constraint of the Fit 57 53 self.constraint =None 54 #Specify the use of scipy or park fit 58 55 self.fitType =None 59 56 … … 73 70 fitproblem=self.fitArrangeList.values()[0] 74 71 listdata=[] 75 model =fitproblem.get_model() 76 listdata= fitproblem.get_data() 77 self.set_param(model, pars) 72 model = fitproblem.get_model() 73 listdata = fitproblem.get_data() 74 75 parameters = self.set_param(model,pars) 78 76 if listdata==[]: 79 77 raise ValueError, " data list missing" … … 83 81 ytemp=[] 84 82 dytemp=[] 85 86 83 87 84 for data in listdata: 88 85 for i in range(len(data.x)): … … 99 96 if qmax==None: 100 97 qmax= max(xtemp) 101 chisqr, out, cov = fitHelper(model, self.parameters, xtemp,ytemp, dytemp ,qmin,qmax)98 chisqr, out, cov = fitHelper(model,parameters, xtemp,ytemp, dytemp ,qmin,qmax) 102 99 return chisqr, out, cov 103 100 104 101 def set_model(self,model,Uid): 105 102 """ Set model """ 106 #self.model[Uid] = model 107 fitproblem= FitArrange() 108 fitproblem.set_model(model) 109 self.fitArrangeList[Uid]=fitproblem 103 if self.fitArrangeList.has_key(Uid): 104 self.fitArrangeList[Uid].set_model(model) 105 else: 106 fitproblem= FitArrange() 107 fitproblem.set_model(model) 108 self.fitArrangeList[Uid]=fitproblem 110 109 111 110 def set_data(self,data,Uid): 112 111 """ Receive plottable and create a list of data to fit""" 113 #self.data.append(data)112 114 113 if self.fitArrangeList.has_key(Uid): 115 114 self.fitArrangeList[Uid].add_data(data) … … 119 118 self.fitArrangeList[Uid]=fitproblem 120 119 121 def get_ data(self):120 def get_model(self,Uid): 122 121 """ return list of data""" 123 return self. data122 return self.fitArrangeList[Uid] 124 123 125 124 def set_param(self,model, pars): 126 125 """ Recieve a dictionary of parameter and save it """ 127 self.parameters=[]126 parameters=[] 128 127 if model==None: 129 128 raise ValueError, "Cannot set parameters for empty model" … … 131 130 #for key ,value in pars: 132 131 for key, value in pars.iteritems(): 133 print "this is the key",key134 print "this is the value",value135 132 param = Parameter(model, key, value) 136 self.parameters.append(param) 137 138 def add_contraint(self, contraint): 133 parameters.append(param) 134 return parameters 135 136 def add_constraint(self, constraint): 139 137 """ User specify contraint to fit """ 140 self.con traint = str(contraint)141 142 def get_con traint(self):138 self.constraint = str(constraint) 139 140 def get_constraint(self): 143 141 """ return the contraint value """ 144 return self.contraint 145 146 142 return self.constraint 143 144 def set_constraint(self,constraint): 145 """ 146 receive a string as a constraint 147 @param constraint: a string used to constraint some parameters to get a 148 specific value 149 """ 150 self.constraint= constraint 151 152 153 147 154 148 155 class Parameter: … … 235 242 Fit.set_model(model,1) 236 243 Fit.set_data(data1,1) 237 #default_A = model.getParam('A') 238 #default_B = model.getParam('B') 239 #cstA = Parameter(model, 'A', default_A) 240 #cstB = Parameter(model, 'B', default_B) 241 242 #chisqr, out, cov=Fit.fit([cstA,cstB],None,None) 244 243 245 chisqr, out, cov=Fit.fit({'A':2,'B':1},None,None) 244 246 print"fit only one data",chisqr, out, cov
Note: See TracChangeset
for help on using the changeset viewer.