Changeset 00561739 in sasview for sansview/perspectives
- Timestamp:
- Sep 29, 2008 7:37:15 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:
- fa9674b
- Parents:
- 4ab1c91
- Location:
- sansview/perspectives/fitting
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/fitpage.py
r442895f r00561739 211 211 212 212 def onClose(self,event): 213 """ close the page associated with this panel""" 213 214 self.GrandParent.onClose() 214 215 … … 233 234 sum=0 234 235 for item in res: 235 sum +=item 236 self.tcChi.SetValue(format_number(math.fabs(sum))) 236 if numpy.isfinite(item): 237 sum +=item 238 self.tcChi.SetValue(format_number(math.fabs(sum))) 237 239 238 240 … … 259 261 list_name=[] 260 262 for item in self.model_list_box.itervalues(): 263 name = item.__name__ 261 264 if hasattr(item, "name"): 262 265 name = item.name 263 else:264 name = item.__name__265 266 list_name.append(name) 266 267 list_name.sort() … … 277 278 post an event to its owner to draw an appropriate theory 278 279 """ 280 279 281 for item in self.model_list_box.itervalues(): 280 model=item() 281 if hasattr(model, "name"): 282 name = model.name 283 else: 284 name = model.__class__.__name__ 285 try: 286 if name ==event.GetString(): 287 evt = ModelEventbox(model=model,name=name) 282 name = item.__name__ 283 if hasattr(item, "name"): 284 name = item.name 285 #print "fitpage: _on_select_model model name",name ,event.GetString() 286 if name ==event.GetString(): 287 try: 288 evt = ModelEventbox(model=item(),name=name) 288 289 wx.PostEvent(self.event_owner, evt) 289 except:290 raise #ValueError,"model.name is not equal to model class name"291 290 except: 291 raise #ValueError,"model.name is not equal to model class name" 292 break 292 293 293 294 def _onTextEnter(self,event): -
sansview/perspectives/fitting/fitproblem.py
r3b19ac9 r00561739 20 20 self.model_list=[] 21 21 self.schedule='False' 22 self.param_name= None 23 self.param_value=None 22 24 23 25 def set_model(self,model,name): … … 39 41 def get_model(self): 40 42 """ @return: saved model """ 43 print "fitproblem",self.model_list 41 44 return self.model_list 42 45 … … 65 68 @param value: value of that parameter 66 69 """ 67 68 self.model_list[0].setParam(name,value) 69 70 print "fitproblem",name,value 71 #self.model_list[0].setParam(name,value) 72 self.param_name = name 73 self.param_value= value 74 def get_model_param(self): 75 """ 76 set the value of a given parameter of this model 77 @param name: name of the given parameter 78 @param value: value of that parameter 79 """ 80 print self.param_name, self.param_value 81 #self.model_list[0].setParam(name,value) 82 return self.param_name, self.param_value 70 83 71 84 def reset_model(self,model): -
sansview/perspectives/fitting/fitting.py
r442895f r00561739 14 14 import fitpage 15 15 import park 16 class PlottableDatas(Data,Data1D):17 """ class plottable data: class allowing to plot Data type on panel"""18 19 def __init__(self,data=None,data1d=None):20 Data.__init__(self,sans_data=data1d)21 Data1D.__init__(self,x=data1d.x,y = data1d.y,dx = data1d.dx,dy = data1d.dy)22 #self.x = data1d.x23 #self.y = data1d.y24 #self.dx = data1d.dx25 #self.dy = data1d.dy26 #self.data=data27 self.group_id = data1d.group_id28 #x_name, x_units = data1d.get_xaxis()29 #y_name, y_units = data1d.get_yaxis()30 #self.xaxis( x_name, x_units)31 #self.yaxis( y_name, y_units )32 #self.qmin = data.qmin33 #self.qmax = data.qmax34 35 36 class PlottableData(Data,Data1D):37 """ class plottable data: class allowing to plot Data type on panel"""38 39 def __init__(self,data=None,data1d=None):40 #Data.__init__(self,*args)41 #Data1D.__init__(self,**kw)42 self.x = data1d.x43 self.y = data1d.y44 self.dx = data1d.dx45 self.dy = data1d.dy46 self.data=data47 self.group_id = data1d.group_id48 x_name, x_units = data1d.get_xaxis()49 y_name, y_units = data1d.get_yaxis()50 self.xaxis( x_name, x_units)51 self.yaxis( y_name, y_units )52 self.qmin = data.qmin53 self.qmax = data.qmax54 def residuals(self, fn):55 return self.data.residuals(fn)56 16 57 17 class Plugin: … … 218 178 list=value.get_model() 219 179 model=list[0] 180 print "fitting",model.name,modelname 220 181 if model.name== modelname: 221 182 value.set_model_param(names,values) … … 400 361 wx.PostEvent(self.parent, StatusEvent(status="Fitting error: %s" % sys.exc_value)) 401 362 return 402 self.fitter.set_model(Model(model), self.id, pars) 363 new_model=Model(model) 364 param_name,param_value=value.get_model_param() 365 print "fitting ",param_name 366 new_model.set( param_name =str(param_value)) 367 #self.fitter.set_model(new_model, self.id, pars) 403 368 self.fitter.set_data(Data(sans_data=data),self.id,qmin,qmax) 404 369 … … 492 457 theory.xaxis(x_name, x_units) 493 458 theory.yaxis(y_name, y_units) 494 #print"fitting : redraw data.x",data.x495 #print"fitting : redraw data.y",data.y496 #print"fitting : redraw data.dy",data.dy497 459 if qmin == None : 498 460 qmin = min(data.x) … … 524 486 theory.x.append(tempx) 525 487 theory.y.append(tempy) 526 except:527 wx.PostEvent(self.parent, StatusEvent(status="fitting \528 skipping point x %g %s" %(qmax, sys.exc_value)))529 try:530 #print "fitting redraw for plot thoery .x",theory.x531 #print "fitting redraw for plot thoery .y",theory.y532 #print "fitting redraw for plot thoery .dy",theory.dy533 #rom sans.guicomm.events import NewPlotEvent534 488 wx.PostEvent(self.parent, NewPlotEvent(plot=theory, title="Analytical model")) 535 489 except: 536 raise537 print "SimView.complete1D: could not import sans.guicomm.events"538 490 wx.PostEvent(self.parent, StatusEvent(status="fitting \ 491 skipping point x %g %s" %(qmax, sys.exc_value))) 492 539 493 540 494 def _on_model_menu(self, evt): … … 567 521 new_plot.yaxis("\\rm{Intensity} ","cm^{-1}") 568 522 new_plot.group_id ="Fitness" 569 570 523 wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title="Analytical model")) 571 524 except: 572 print "SimView.complete1D: could not import sans.guicomm.events\n %s" % sys.exc_value573 logging.error("SimView.complete1D: could not import sans.guicomm.events\n %s" % sys.exc_value)525 wx.PostEvent(self.parent, StatusEvent(status="fitting \ 526 skipping point x %g %s" %(qmax, sys.exc_value))) 574 527 575 528 if __name__ == "__main__": -
sansview/perspectives/fitting/modelpage.py
r442895f r00561739 52 52 self.sizer1 = wx.GridBagSizer(5,5) 53 53 self.sizer2 = wx.GridBagSizer(5,5) 54 self.sizer4 = wx.GridBagSizer(5,5) 54 55 self.modelbox = wx.ComboBox(self, -1) 55 56 id = wx.NewId() … … 57 58 self.vbox.Add(self.sizer1) 58 59 self.vbox.Add(self.sizer2) 60 self.vbox.Add(self.sizer4) 61 62 id = wx.NewId() 63 self.btClose =wx.Button(self,id,'Close') 64 self.btClose.Bind(wx.EVT_BUTTON, self.onClose,id=id) 65 self.btClose.SetToolTipString("Close page.") 66 67 ix = 12 68 iy = 1 69 self.sizer4.Add( self.btClose,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 59 70 ix = 0 60 71 iy = 1 61 62 72 self.sizer3.Add(wx.StaticText(self,-1,'Model'),(iy,ix),(1,1)\ 63 73 , wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) … … 87 97 88 98 99 def onClose(self,event): 100 """ close the page associated with this panel""" 101 self.GrandParent.onClose() 102 89 103 def set_owner(self,owner): 90 104 """ … … 122 136 123 137 def set_page(self, model,description): 124 print " modelpage: set_page was called",model138 #print " modelpage: set_page was called",model 125 139 self.model=model 126 140 self.description=description … … 137 151 post an event to its owner to draw an appropriate theory 138 152 """ 139 print "modelpage: self.model_list_box ",self.model_list_box153 #print "modelpage: self.model_list_box ",self.model_list_box 140 154 for item in self.model_list_box.itervalues(): 141 155 model=item() 142 print "modelpage:model",model156 #print "modelpage:model",model 143 157 if hasattr(model, "name"): 144 158 name = model.name -
sansview/perspectives/fitting/models.py
r442895f r00561739 5 5 6 6 (ModelEvent, EVT_MODEL) = wx.lib.newevent.NewEvent() 7 7 8 class ModelInfo(object): 9 """ 10 this class contains description for a given model 11 """ 8 12 def __init__(self,model,description=None): 9 13 self.model=model 10 14 self.description=description 15 11 16 def set_description(self, descrition): 12 17 self.description =str(description) 18 13 19 def get_description(self): 14 20 return self.description 21 22 15 23 def log(message): 16 24 print message … … 179 187 if len(self.indep_model_list) == 0: 180 188 for item in self.indep_model: 181 if item not in self.indep_model_list.values(): 182 self.indep_model_list[str(id)] = item 183 self.model_list[str(id)]=item 184 if hasattr(item, "name"): 185 name = item.model.name 186 else: 187 name = item.model.__name__ 188 indep_submenu.Append(id,name, name) 189 self.model_list_box[name] =item.model 190 wx.EVT_MENU(event_owner, int(id), self._on_model) 191 id = wx.NewId() 189 #if item not in self.indep_model_list.values(): 190 #self.indep_model_list[str(id)] = item 191 self.model_list[str(id)]=item 192 name = item.model.__name__ 193 if hasattr(item, "name"): 194 name = item.model.name 195 indep_submenu.Append(id,name, name) 196 self.model_list_box[name] =item.model 197 wx.EVT_MENU(event_owner, int(id), self._on_model) 198 id = wx.NewId() 192 199 modelmenu.AppendMenu(wx.NewId(), "Shape-independent...", indep_submenu, "List of shape-independent models") 193 200 … … 198 205 if len(self.custom_models) == 0: 199 206 for item in self.plugins: 200 if item not in self.custom_models.values(): 201 self.custom_models[str(id)] = item 202 203 self.model_list[str(id)]=ModelInfo(item,model_info) 204 if hasattr(item, "name"): 205 name = item.name 206 else: 207 name = item.__name__ 208 added_models.Append(id, name, name) 209 self.model_list_box[name] =item 210 wx.EVT_MENU(event_owner, int(id), self._on_model) 211 id = wx.NewId() 207 #if item not in self.custom_models.values(): 208 #self.custom_models[str(id)] = item 209 self.model_list[str(id)]=ModelInfo(item,model_info) 210 name = item.__name__ 211 if hasattr(item, "name"): 212 name = item.name 213 added_models.Append(id, name, name) 214 self.model_list_box[name] =item 215 wx.EVT_MENU(event_owner, int(id), self._on_model) 216 id = wx.NewId() 212 217 modelmenu.AppendMenu(wx.NewId(),"Added models...", added_models, "List of additional models") 213 218 return 0 -
sansview/perspectives/fitting/simfitpage.py
r442895f r00561739 44 44 45 45 self.ctl2 = wx.TextCtrl(self, -1, style=wx.TE_MULTILINE) 46 self.ctl2.Bind(wx.EVT_KILL_FOCUS, self._onTextEnter)47 self.ctl2.Bind(wx.EVT_TEXT_ENTER, self._onTextEnter)46 #self.ctl2.Bind(wx.EVT_KILL_FOCUS, self._onTextEnter) 47 #self.ctl2.Bind(wx.EVT_TEXT_ENTER, self._onTextEnter) 48 48 self.sizer2.Add(self.ctl2, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) 49 49 … … 65 65 def onFit(self,event): 66 66 """ signal for fitting""" 67 self._onTextEnter() 67 68 if len(self.model_toFit) >0 : 68 69 if len(self.params)>0: … … 75 76 wx.PostEvent(self.parent.GrandParent, StatusEvent(status=\ 76 77 "Select at least on model to fit ")) 78 79 77 80 def set_manager(self, manager): 78 81 """ … … 105 108 @param page_finder: the dictionary containing models information 106 109 """ 107 import copy110 108 111 self.model_list=[] 109 112 self.model_toFit=[] … … 206 209 207 210 208 def _onTextEnter(self,event): 211 #def _onTextEnter(self,event): 212 def _onTextEnter(self): 209 213 """ 210 214 get values from the constrainst textcrtl ,parses them into model name … … 225 229 self.params.append(self.parser_helper(item)) 226 230 except: 227 wx.PostEvent(self.parent.GrandParent, StatusEvent(status=" LoadingError: %s" % sys.exc_value))231 wx.PostEvent(self.parent.GrandParent, StatusEvent(status="Constraint Error: %s" % sys.exc_value)) 228 232 else: 229 233 try: 230 234 self.params.append(self.parser_helper(value)) 231 235 except: 232 wx.PostEvent(self.parent.GrandParent, StatusEvent(status=" LoadingError: %s" % sys.exc_value))236 wx.PostEvent(self.parent.GrandParent, StatusEvent(status="Constraint Error: %s" % sys.exc_value)) 233 237 except: 234 238 raise … … 253 257 model_name=param_names[0] 254 258 param_name=param_names[1] 255 param=[str(model_name),str(param_name),str(param_value)] 259 ##### just added 260 if string.find(param_name,".")!=-1: 261 ######## 262 param_new_name= re.split("\.",param_name) 263 else: 264 param_new_name= param_name 265 print "simfitpage: param name",param_new_name 266 param=[str(model_name),str(param_new_name[1]),str(param_value)] 256 267 #print "simfitpage: param",param 257 268 return param
Note: See TracChangeset
for help on using the changeset viewer.