Changeset d4b0687 in sasview
- Timestamp:
- Jul 11, 2008 11:16:18 AM (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:
- 94b44293
- Parents:
- 4c718654
- Location:
- park_integration
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
park_integration/AbstractFitEngine.py
r4c718654 rd4b0687 32 32 return xtemp, ytemp,dytemp 33 33 34 def set_model(self,model,name,Uid,pars={}): 35 """ 34 36 37 Receive a dictionary of parameter and save it Parameter list 38 For scipy.fit use. 39 Set model in a FitArrange object and add that object in a dictionary 40 with key Uid. 41 @param model: model on with parameter values are set 42 @param name: model name 43 @param Uid: unique key corresponding to a fitArrange object with model 44 @param pars: dictionary of paramaters name and value 45 pars={parameter's name: parameter's value} 46 47 """ 48 self.parameters=[] 49 if model==None: 50 raise ValueError, "Cannot set parameters for empty model" 51 else: 52 model.name=name 53 for key, value in pars.iteritems(): 54 param = Parameter(model, key, value) 55 self.parameters.append(param) 56 57 #A fitArrange is already created but contains dList only at Uid 58 if self.fitArrangeList.has_key(Uid): 59 self.fitArrangeList[Uid].set_model(model) 60 else: 61 #no fitArrange object has been create with this Uid 62 fitproblem= FitArrange() 63 fitproblem.set_model(model) 64 self.fitArrangeList[Uid]=fitproblem 65 66 67 def set_data(self,data,Uid): 68 """ Receives plottable, creates a list of data to fit,set data 69 in a FitArrange object and adds that object in a dictionary 70 with key Uid. 71 @param data: data added 72 @param Uid: unique key corresponding to a fitArrange object with data 73 """ 74 #A fitArrange is already created but contains model only at Uid 75 if self.fitArrangeList.has_key(Uid): 76 self.fitArrangeList[Uid].add_data(data) 77 else: 78 #no fitArrange object has been create with this Uid 79 fitproblem= FitArrange() 80 fitproblem.add_data(data) 81 self.fitArrangeList[Uid]=fitproblem 82 83 def get_model(self,Uid): 84 """ 85 @param Uid: Uid is key in the dictionary containing the model to return 86 @return a model at this uid or None if no FitArrange element was created 87 with this Uid 88 """ 89 if self.fitArrangeList.has_key(Uid): 90 return self.fitArrangeList[Uid].get_model() 91 else: 92 return None 93 94 def remove_Fit_Problem(self,Uid): 95 """remove fitarrange in Uid""" 96 if self.fitArrangeList.has_key(Uid): 97 del self.fitArrangeList[Uid] 98 99 100 101 35 102 class Parameter: 36 103 """ … … 55 122 return self.model.getParam(self.name) 56 123 124 class FitArrange: 125 def __init__(self): 126 """ 127 Class FitArrange contains a set of data for a given model 128 to perform the Fit.FitArrange must contain exactly one model 129 and at least one data for the fit to be performed. 130 model: the model selected by the user 131 Ldata: a list of data what the user wants to fit 132 133 """ 134 self.model = None 135 self.dList =[] 136 137 def set_model(self,model): 138 """ 139 set_model save a copy of the model 140 @param model: the model being set 141 """ 142 self.model = model 143 144 def add_data(self,data): 145 """ 146 add_data fill a self.dList with data to fit 147 @param data: Data to add in the list 148 """ 149 if not data in self.dList: 150 self.dList.append(data) 151 152 def get_model(self): 153 """ @return: saved model """ 154 return self.model 155 156 def get_data(self): 157 """ @return: list of data dList""" 158 return self.dList 159 160 def remove_data(self,data): 161 """ 162 Remove one element from the list 163 @param data: Data to remove from dList 164 """ 165 if data in self.dList: 166 self.dList.remove(data) 167 def remove_datalist(self): 168 """ empty the complet list dLst""" 169 self.dList=[] 170 57 171 58 172 -
park_integration/ParkFitting.py
r4c718654 rd4b0687 14 14 from sans.guitools.plottables import Data1D 15 15 from Loader import Load 16 from AbstractFitEngine import FitEngine, Parameter 17 16 from AbstractFitEngine import FitEngine, Parameter, FitArrange 18 17 class SansParameter(park.Parameter): 19 18 """ … … 103 102 """ 104 103 return [] 105 class FitArrange: 106 def __init__(self): 107 """ 108 Class FitArrange contains a set of data for a given model 109 to perform the Fit.FitArrange must contain exactly one model 110 and at least one data for the fit to be performed. 111 model: the model selected by the user 112 Ldata: a list of data what the user wants to fit 113 114 """ 115 self.model = None 116 self.dList =[] 117 118 def set_model(self,model): 119 """ 120 set_model save a copy of the model 121 @param model: the model being set 122 """ 123 self.model = model 124 def remove_model(self): 125 """ remove model """ 126 self.model=None 127 def add_data(self,data): 128 """ 129 add_data fill a self.dList with data to fit 130 @param data: Data to add in the list 131 """ 132 if not data in self.dList: 133 self.dList.append(data) 134 135 def get_model(self): 136 """ @return: saved model """ 137 return self.model 138 139 def get_data(self): 140 """ @return: list of data dList""" 141 return self.dList 142 143 def remove_data(self,data): 144 """ 145 Remove one element from the list 146 @param data: Data to remove from dList 147 """ 148 if data in self.dList: 149 self.dList.remove(data) 150 def remove_datalist(self): 151 """ empty the complet list dLst""" 152 self.dList=[] 153 104 154 105 155 106 class ParkFit(FitEngine): … … 203 154 204 155 Ldata=value.get_data() 205 x,y,dy ,dx=self._concatenateData(Ldata)156 x,y,dy=self._concatenateData(Ldata) 206 157 #wrap sansdata 207 parkdata=Data(x,y,dy, dx)158 parkdata=Data(x,y,dy,None) 208 159 couple=(parkmodel,parkdata) 209 160 mylist.append(couple) … … 244 195 return result.fitness,result.pvec,result.cov 245 196 246 def set_model(self,model,name,Uid,pars={}):247 """248 249 Receive a dictionary of parameter and save it Parameter list250 For scipy.fit use.251 Set model in a FitArrange object and add that object in a dictionary252 with key Uid.253 @param model: model on with parameter values are set254 @param name: model name255 @param Uid: unique key corresponding to a fitArrange object with model256 @param pars: dictionary of paramaters name and value257 pars={parameter's name: parameter's value}258 259 """260 self.parameters=[]261 if model==None:262 raise ValueError, "Cannot set parameters for empty model"263 else:264 model.name=name265 for key, value in pars.iteritems():266 param = Parameter(model, key, value)267 self.parameters.append(param)268 269 #A fitArrange is already created but contains dList only at Uid270 if self.fitArrangeList.has_key(Uid):271 self.fitArrangeList[Uid].set_model(model)272 else:273 #no fitArrange object has been create with this Uid274 fitproblem= FitArrange()275 fitproblem.set_model(model)276 self.fitArrangeList[Uid]=fitproblem277 278 279 def set_data(self,data,Uid):280 """ Receives plottable, creates a list of data to fit,set data281 in a FitArrange object and adds that object in a dictionary282 with key Uid.283 @param data: data added284 @param Uid: unique key corresponding to a fitArrange object with data285 """286 #A fitArrange is already created but contains model only at Uid287 if self.fitArrangeList.has_key(Uid):288 self.fitArrangeList[Uid].add_data(data)289 else:290 #no fitArrange object has been create with this Uid291 fitproblem= FitArrange()292 fitproblem.add_data(data)293 self.fitArrangeList[Uid]=fitproblem294 295 def get_model(self,Uid):296 """297 @param Uid: Uid is key in the dictionary containing the model to return298 @return a model at this uid or None if no FitArrange element was created299 with this Uid300 """301 if self.fitArrangeList.has_key(Uid):302 return self.fitArrangeList[Uid].get_model()303 else:304 return None305 306 def remove_Fit_Problem(self,Uid):307 """remove fitarrange in Uid"""308 if self.fitArrangeList.has_key(Uid):309 del self.fitArrangeList[Uid]310 311 312 197 313 -
park_integration/ScipyFitting.py
r4c718654 rd4b0687 8 8 from scipy import optimize 9 9 from AbstractFitEngine import FitEngine, Parameter 10 from AbstractFitEngine import FitArrange 10 11 11 class FitArrange:12 def __init__(self):13 """14 Class FitArrange contains a set of data for a given model15 to perform the Fit.FitArrange must contain exactly one model16 and at least one data for the fit to be performed.17 model: the model selected by the user18 Ldata: a list of data what the user wants to fit19 20 """21 self.model = None22 self.dList =[]23 24 def set_model(self,model):25 """26 set_model save a copy of the model27 @param model: the model being set28 """29 self.model = model30 31 def add_data(self,data):32 """33 add_data fill a self.dList with data to fit34 @param data: Data to add in the list35 """36 if not data in self.dList:37 self.dList.append(data)38 39 def get_model(self):40 """ @return: saved model """41 return self.model42 43 def get_data(self):44 """ @return: list of data dList"""45 return self.dList46 47 def remove_data(self,data):48 """49 Remove one element from the list50 @param data: Data to remove from dList51 """52 if data in self.dList:53 self.dList.remove(data)54 def remove_datalist(self):55 """ empty the complet list dLst"""56 self.dList=[]57 58 12 class ScipyFit(FitEngine): 59 13 """ … … 123 77 return chisqr, out, cov 124 78 125 def set_model(self,model,name,Uid,pars={}): 126 """ 127 128 Receive a dictionary of parameter and save it Parameter list 129 For scipy.fit use. 130 Set model in a FitArrange object and add that object in a dictionary 131 with key Uid. 132 @param model: model on with parameter values are set 133 @param name: model name 134 @param Uid: unique key corresponding to a fitArrange object with model 135 @param pars: dictionary of paramaters name and value 136 pars={parameter's name: parameter's value} 137 138 """ 139 self.parameters=[] 140 if model==None: 141 raise ValueError, "Cannot set parameters for empty model" 142 else: 143 model.name=name 144 for key, value in pars.iteritems(): 145 param = Parameter(model, key, value) 146 self.parameters.append(param) 147 148 #A fitArrange is already created but contains dList only at Uid 149 if self.fitArrangeList.has_key(Uid): 150 self.fitArrangeList[Uid].set_model(model) 151 else: 152 #no fitArrange object has been create with this Uid 153 fitproblem= FitArrange() 154 fitproblem.set_model(model) 155 self.fitArrangeList[Uid]=fitproblem 156 157 def set_data(self,data,Uid): 158 """ Receives plottable, creates a list of data to fit,set data 159 in a FitArrange object and adds that object in a dictionary 160 with key Uid. 161 @param data: data added 162 @param Uid: unique key corresponding to a fitArrange object with data 163 """ 164 #A fitArrange is already created but contains model only at Uid 165 if self.fitArrangeList.has_key(Uid): 166 self.fitArrangeList[Uid].add_data(data) 167 else: 168 #no fitArrange object has been create with this Uid 169 fitproblem= FitArrange() 170 fitproblem.add_data(data) 171 self.fitArrangeList[Uid]=fitproblem 172 173 def get_model(self,Uid): 174 """ 175 @param Uid: Uid is key in the dictionary containing the model to return 176 @return a model at this uid or None if no FitArrange element was created 177 with this Uid 178 """ 179 if self.fitArrangeList.has_key(Uid): 180 return self.fitArrangeList[Uid].get_model() 181 else: 182 return None 183 184 185 186 def remove_Fit_Problem(self,Uid): 187 """remove fitarrange in Uid""" 188 if self.fitArrangeList.has_key(Uid): 189 del self.fitArrangeList[Uid] 190 79 191 80 def fitHelper(model, pars, x, y, err_y ,qmin=None, qmax=None): 192 81 """
Note: See TracChangeset
for help on using the changeset viewer.