Changeset 2dbb681 in sasview
- Timestamp:
- Oct 21, 2008 10:30:12 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:
- 5893cdb
- Parents:
- b3328d8
- Location:
- sansview
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/local_config.py
rd89f09b r2dbb681 6 6 # Version of the application 7 7 #__appname__ = "PrView" 8 __appname__ = " FitView"8 __appname__ = "SansView" 9 9 __version__ = '0.1.1' 10 10 __download_page__ = 'http://danse.chem.utk.edu' -
sansview/perspectives/fitting/fitpage1D.py
r693ab78 r2dbb681 135 135 ix +=2 136 136 self.sizer1.Add(self.btFit,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 137 iy+= 1 138 ix = 3 137 ix+= 1 139 138 self.sizer1.Add( self.btClose,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 139 ix= 1 140 iy+=1 141 self.sizer1.Add((20,20),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 140 142 # contains link between model ,all its parameters, and panel organization 141 143 self.parameters=[] … … 183 185 @return residuals 184 186 """ 185 print self.data.x186 print self.data.y187 print self.data.dy188 187 189 188 flag=self.checkFitRange() … … 293 292 valueMax = self.xmax.GetValue() 294 293 # Check for possible values entered 295 print "fitpage: checkfitrange:",valueMin,valueMax294 #print "fitpage: checkfitrange:",valueMin,valueMax 296 295 try: 297 296 if (float(valueMax)> float(valueMin)): … … 341 340 self.model = model 342 341 keys = self.model.getParamList() 342 print "fitpage1D : dispersion list",self.model.getDispParamList() 343 343 keys.sort() 344 344 iy = 1 … … 436 436 for item in self.parameters: 437 437 try: 438 name=str(item[0].GetLabelText()) 439 value= float(item[1].GetValue()) 440 self.model.setParam(name,value) 438 439 name=str(item[0].GetLabelText()) 440 value= float(item[1].GetValue()) 441 self.model.setParam(name,value) 441 442 except: 442 443 wx.PostEvent(self.parent.GrandParent, StatusEvent(status=\ -
sansview/perspectives/fitting/fitpage2D.py
r9d31a8b r2dbb681 157 157 ix +=2 158 158 self.sizer1.Add(self.btFit,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 159 iy+= 1 160 ix = 3 159 ix+= 1 161 160 self.sizer1.Add( self.btClose,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 161 ix= 1 162 iy+=1 163 self.sizer1.Add((20,20),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 162 164 # contains link between model ,all its parameters, and panel organization 163 165 self.parameters=[] -
sansview/perspectives/fitting/fitpanel.py
r693ab78 r2dbb681 102 102 if page_title !=self.draw_model_name or self.draw_model_name ==None: 103 103 from modelpage import ModelPage 104 panel = ModelPage(self.nb,model, description,-1)104 panel = ModelPage(self.nb,model, -1) 105 105 panel.set_manager(self.manager) 106 106 panel.set_owner(self.event_owner) … … 151 151 selected on that page. remove its reference into page_finder (fitting module) 152 152 """ 153 154 sim_page = self.nb.GetPage(0) 155 selected_page = self.nb.GetPage(self.nb.GetSelection()) 156 157 if sim_page != selected_page: 158 # remove the check box link to the model name of this page (selected_page) 159 sim_page.remove_model(selected_page) 160 #remove that page from page_finder of fitting module 161 page_finder=self.manager.get_page_finder() 162 for page, value in page_finder.iteritems(): 163 if page==selected_page: 164 del page_finder[page] 165 break 166 #Delete the page from notebook 167 page_number = self.nb.GetSelection() 168 if self.nb.GetPageText(page_number)== self.page_name: 169 self.draw_model_name=None 170 171 selected_page.Destroy() 172 self.nb.RemovePage(page_number) 173 #self.name=None 174 self.fit_page_name=None 153 try: 154 sim_page = self.nb.GetPage(0) 155 selected_page = self.nb.GetPage(self.nb.GetSelection()) 175 156 157 if sim_page != selected_page: 158 # remove the check box link to the model name of this page (selected_page) 159 sim_page.remove_model(selected_page) 160 #remove that page from page_finder of fitting module 161 page_finder=self.manager.get_page_finder() 162 for page, value in page_finder.iteritems(): 163 if page==selected_page: 164 del page_finder[page] 165 break 166 #Delete the page from notebook 167 page_number = self.nb.GetSelection() 168 if self.nb.GetPageText(page_number)== self.page_name: 169 self.draw_model_name=None 170 171 selected_page.Destroy() 172 self.nb.RemovePage(page_number) 173 #self.name=None 174 self.fit_page_name=None 175 except: 176 raise 177 print "fitpanel", self.draw_model_name 176 178 def set_model_list(self,dict): 177 179 """ -
sansview/perspectives/fitting/fitting.py
r693ab78 r2dbb681 11 11 from fitpanel import FitPanel 12 12 13 import models 13 import models,modelpage 14 14 import fitpage1D,fitpage2D 15 15 import park … … 60 60 id2 = wx.NewId() 61 61 owner.Bind(models.EVT_MODEL,self._on_model_menu) 62 #owner.Bind(modelpage.EVT_MODEL,self._on_model_menu) 62 63 self.fit_panel.set_owner(owner) 63 64 self.fit_panel.set_model_list(self.menu_mng.get_model_list()) … … 84 85 for item in graph.plottables: 85 86 if item.__class__.__name__ is "Data2D": 86 return [["Fit Data2D", "Dialog with fitting parameters ", self._onSelect]] 87 return [["Select data for Fitting",\ 88 "Dialog with fitting parameters ", self._onSelect]] 87 89 else: 88 90 if item.name==graph.selected_plottable and\ 89 91 item.__class__.__name__ is "Data1D": 90 return [["Fit Data1D", "Dialog with fitting parameters ", self._onSelect]] 92 return [["Select data for Fitting", \ 93 "Dialog with fitting parameters ", self._onSelect]] 91 94 return [] 92 95 … … 539 542 theory.image=model.runXY(data.image) 540 543 541 print "fitting : plot_helper:",theory.image544 #print "fitting : plot_helper:",theory.image 542 545 theory.zmin= data.zmin 543 546 theory.zmax= data.zmax … … 555 558 """ 556 559 name="Model View" 557 model=evt.modelinfo.model() 558 description=evt.modelinfo.description 560 model=evt.model() 561 562 description=model.description 559 563 self.fit_panel.add_model_page(model,description,name) 560 564 self.draw_model(model) … … 573 577 dy[i] = math.sqrt(math.fabs(y[i])) 574 578 try: 575 576 579 new_plot = Theory1D(x, y) 577 580 new_plot.name = "Model" … … 581 584 wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title="Analytical model")) 582 585 except: 583 wx.PostEvent(self.parent, StatusEvent(status="fitting \ 584 skipping point x %g %s" %(qmax, sys.exc_value))) 585 586 raise 586 587 if __name__ == "__main__": 587 588 i = Plugin() -
sansview/perspectives/fitting/modelpage.py
r00561739 r2dbb681 39 39 40 40 41 def __init__(self, parent,model, description,*args, **kwargs):41 def __init__(self, parent,model, *args, **kwargs): 42 42 wx.Panel.__init__(self, parent, *args, **kwargs) 43 43 """ … … 80 80 # model on which the fit would be performed 81 81 self.model=model 82 self.description=description 83 self.set_panel(model,description) 82 try: 83 print"init modelpage",model.name 84 self.set_panel(model) 85 except: 86 raise 84 87 # preview selected model name 85 88 self.prevmodel_name=model.__class__.__name__ … … 95 98 self.SetSizer(self.vbox) 96 99 self.Centre() 97 100 98 101 99 102 def onClose(self,event): … … 123 126 id=0 124 127 self.model_list_box=dict 125 for item in self.model_list_box.itervalues(): 126 if hasattr(item, "name"): 127 name = item.name 128 else: 129 name = item.__name__ 130 128 list_name=[] 129 for item in self.model_list_box.itervalues(): 130 name = item.__name__ 131 model=item() 132 if hasattr(model, "name"): 133 name = model.name 134 list_name.append(name) 135 list_name.sort() 136 for name in list_name: 131 137 self.modelbox.Insert(name,int(id)) 132 138 id+=1 133 134 wx.EVT_COMBOBOX(self.modelbox,-1, self._on_select_model) 139 wx.EVT_COMBOBOX(self.modelbox,-1, self._on_select_model) 135 140 return 0 136 141 137 def set_page(self, model,description ):142 def set_page(self, model,description=None): 138 143 #print " modelpage: set_page was called",model 139 144 self.model=model 140 self.description=description145 name = self.model.__class__.__name__ 141 146 if hasattr(self.model, "name"): 142 147 name = self.model.name 143 else:144 name = self.model.__class__.__name__148 149 145 150 self.modelbox.SetValue(name) 146 self.set_panel(self.model ,description)151 self.set_panel(self.model) 147 152 self.manager.draw_model(self.model) 153 148 154 def _on_select_model(self,event): 149 155 """ … … 153 159 #print "modelpage: self.model_list_box ",self.model_list_box 154 160 for item in self.model_list_box.itervalues(): 155 model=item() 156 #print "modelpage:model",model 157 if hasattr(model, "name"): 158 name = model.name 159 else: 160 name = model.__class__.__name__ 161 try: 162 if name ==event.GetString(): 163 self.model=model 164 self.set_panel(self.model) 165 self.manager.draw_model(self.model) 166 except: 167 raise #ValueError,"model.name is not equal to model class name" 161 name = item.__name__ 162 items=item() 163 if hasattr(items, "name"): 164 name = items.name 165 print "fitpage: _on_select_model model name",name ,event.GetString() 166 if name ==event.GetString(): 167 model=items 168 print "fitpage: _on_select_model model name",name ,event.GetString() 169 self.manager.draw_model(model) 170 self.set_panel(model) 168 171 def set_model_name(self,name): 169 172 """ … … 197 200 198 201 199 def set_panel(self,model ,description=None):202 def set_panel(self,model): 200 203 """ 201 204 Build the panel from the model content 202 205 @param model: the model selected in combo box for fitting purpose 203 206 """ 204 207 205 208 self.sizer2.Clear(True) 206 209 self.sizer1.Clear(True) … … 210 213 keys = self.model.getParamList() 211 214 keys.sort() 215 print "went here",self.model.name,model.description 212 216 iy = 1 213 217 ix = 0 … … 216 220 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 217 221 ix += 1 218 self.cb01 = wx.StaticText(self, -1,str( description))222 self.cb01 = wx.StaticText(self, -1,str(model.description)) 219 223 self.sizer1.Add(self.cb01,(iy, ix),(1,1),\ 220 224 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) … … 245 249 ctl1.Bind(wx.EVT_TEXT_ENTER, self._onparamEnter) 246 250 self.sizer2.Add(ctl1, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 247 248 251 ix +=1 249 252 # Units … … 262 265 else: 263 266 self.text2_4.Hide() 264 265 267 self.vbox.Layout() 266 268 self.GrandParent.GetSizer().Layout() 267 269 print "out" 268 270 269 271 def _onparamEnter(self,event): … … 280 282 value= float(item[1].GetValue()) 281 283 self.model.setParam(name,value) 282 self.manager.draw_model(self.model)283 284 except: 284 285 285 wx.PostEvent(self.parent.GrandParent, StatusEvent(status=\ 286 286 "Model Drawing Error:wrong value entered : %s"% sys.exc_value)) 287 288 287 self.manager.draw_model(self.model) 288 -
sansview/perspectives/fitting/models.py
r00561739 r2dbb681 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 """ 12 def __init__(self,model,description=None): 13 self.model=model 14 self.description=description 15 16 def set_description(self, descrition): 17 self.description =str(description) 18 19 def get_description(self): 20 return self.description 8 21 9 22 10 … … 84 72 self.model_list = {} 85 73 self.model_list_box = {} 86 87 model_info="shape-based models" 74 88 75 89 76 from sans.models.SphereModel import SphereModel 90 self.model_list[str(wx.NewId())] = ModelInfo(SphereModel , model_info)77 self.model_list[str(wx.NewId())] = SphereModel 91 78 92 79 from sans.models.CylinderModel import CylinderModel 93 self.model_list[str(wx.NewId())] = ModelInfo(CylinderModel , model_info)80 self.model_list[str(wx.NewId())] =CylinderModel 94 81 95 82 from sans.models.CoreShellModel import CoreShellModel 96 self.model_list[str(wx.NewId())] = ModelInfo(CoreShellModel , model_info)83 self.model_list[str(wx.NewId())] = CoreShellModel 97 84 98 85 from sans.models.CoreShellCylinderModel import CoreShellCylinderModel 99 self.model_list[str(wx.NewId())] = ModelInfo(CoreShellCylinderModel , model_info)86 self.model_list[str(wx.NewId())] =CoreShellCylinderModel 100 87 101 88 from sans.models.EllipticalCylinderModel import EllipticalCylinderModel 102 self.model_list[str(wx.NewId())] = ModelInfo(EllipticalCylinderModel , model_info)89 self.model_list[str(wx.NewId())] =EllipticalCylinderModel 103 90 104 91 from sans.models.EllipsoidModel import EllipsoidModel 105 self.model_list[str(wx.NewId())] = ModelInfo(EllipsoidModel , model_info)92 self.model_list[str(wx.NewId())] = EllipsoidModel 106 93 107 94 from sans.guitools.LineModel import LineModel 108 self.model_list[str(wx.NewId())] = ModelInfo(LineModel , model_info)95 self.model_list[str(wx.NewId())] = LineModel 109 96 110 97 … … 112 99 113 100 from sans.models.BEPolyelectrolyte import BEPolyelectrolyte 114 self.indep_model.append( ModelInfo( BEPolyelectrolyte , model_info))101 self.indep_model.append(BEPolyelectrolyte ) 115 102 116 103 from sans.models.DABModel import DABModel 117 self.indep_model.append( ModelInfo(DABModel , model_info+ 118 "\n Evaluates F(x) = scale/( 1 + (x*L)^2 )^(2) +bkd") ) 104 self.indep_model.append(DABModel ) 119 105 120 106 from sans.models.DebyeModel import DebyeModel 121 self.indep_model.append( ModelInfo(DebyeModel , model_info+ 122 "\n Evaluates F(x) = 2( exp(-x)+x -1 )/x**2") ) 107 self.indep_model.append(DebyeModel ) 123 108 124 109 from sans.models.FractalModel import FractalModel … … 126 111 def _Fractal(self, x): 127 112 return FractalModel._Fractal(self, math.fabs(x)) 128 self.indep_model.append( ModelInfo(FractalAbsModel , model_info))113 self.indep_model.append(FractalAbsModel) 129 114 130 115 from sans.models.LorentzModel import LorentzModel 131 self.indep_model.append( ModelInfo(LorentzModel , model_info+ 132 "\n Evaluates F(x)= scale/( 1 + (x*L)^2 ) + bkd ") ) 116 self.indep_model.append( LorentzModel) 133 117 134 118 from sans.models.PowerLawModel import PowerLawModel … … 139 123 except: 140 124 print sys.exc_value 141 self.indep_model.append( ModelInfo(PowerLawAbsModel , model_info+ 142 "\n Evaluates abs(F(x)) \n with F(x) = scale* (x)^(m) + bkd ") ) 143 144 125 self.indep_model.append( PowerLawAbsModel ) 145 126 from sans.models.TeubnerStreyModel import TeubnerStreyModel 146 self.indep_model.append( ModelInfo(TeubnerStreyModel , model_info) ) 147 148 149 150 151 152 153 127 self.indep_model.append(TeubnerStreyModel ) 128 154 129 #Looking for plugins 155 130 self.plugins = findModels() … … 169 144 self._getModelList() 170 145 self.event_owner = event_owner 171 172 146 shape_submenu= wx.Menu() 173 147 indep_submenu = wx.Menu() 174 148 added_models = wx.Menu() 175 176 149 for id_str,value in self.model_list.iteritems(): 177 item = self.model_list[id_str] 178 name = item. model.__name__150 item = self.model_list[id_str]() 151 name = item.__class__.__name__ 179 152 if hasattr(item, "name"): 180 name = item. model.name181 self.model_list_box[name] =value .model153 name = item.name 154 self.model_list_box[name] =value 182 155 shape_submenu.Append(int(id_str), name, name) 183 156 wx.EVT_MENU(event_owner, int(id_str), self._on_model) 184 157 modelmenu.AppendMenu(wx.NewId(), "Shapes...", shape_submenu, "List of shape-based models") 185 186 158 id = wx.NewId() 187 159 if len(self.indep_model_list) == 0: 188 for item in self.indep_model:160 for items in self.indep_model: 189 161 #if item not in self.indep_model_list.values(): 190 162 #self.indep_model_list[str(id)] = item 191 self.model_list[str(id)]=item 192 name = item.model.__name__ 163 self.model_list[str(id)]=items 164 item=items() 165 name = item.__class__.__name__ 193 166 if hasattr(item, "name"): 194 name = item. model.name167 name = item.name 195 168 indep_submenu.Append(id,name, name) 196 self.model_list_box[name] =item .model169 self.model_list_box[name] =items 197 170 wx.EVT_MENU(event_owner, int(id), self._on_model) 198 171 id = wx.NewId() 199 172 modelmenu.AppendMenu(wx.NewId(), "Shape-independent...", indep_submenu, "List of shape-independent models") 200 201 202 203 model_info="additional models"204 173 id = wx.NewId() 205 174 if len(self.custom_models) == 0: 206 for item in self.plugins:175 for items in self.plugins: 207 176 #if item not in self.custom_models.values(): 208 177 #self.custom_models[str(id)] = item 209 self.model_list[str(id)]=ModelInfo(item,model_info) 210 name = item.__name__ 178 self.model_list[str(id)]=items 179 item=items() 180 name = item.__class__.__name__ 211 181 if hasattr(item, "name"): 212 182 name = item.name 213 183 added_models.Append(id, name, name) 214 self.model_list_box[name] =item 184 self.model_list_box[name] =items 215 185 wx.EVT_MENU(event_owner, int(id), self._on_model) 216 186 id = wx.NewId() … … 231 201 232 202 model = self.model_list[str(evt.GetId())] 233 evt = ModelEvent(model info=model)203 evt = ModelEvent(model= model ) 234 204 wx.PostEvent(self.event_owner, evt) 235 205
Note: See TracChangeset
for help on using the changeset viewer.