Changeset d4b0687 in sasview for park_integration/AbstractFitEngine.py
- 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
- File:
-
- 1 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
Note: See TracChangeset
for help on using the changeset viewer.