Changeset 925a30e in sasview for sansview/perspectives
- Timestamp:
- Mar 6, 2009 2:27:00 PM (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:
- 7b73518
- Parents:
- f93dfcb
- Location:
- sansview/perspectives/fitting
- Files:
-
- 2 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/fit_thread.py
r98be89f r925a30e 175 175 raise 176 176 except: 177 wx.PostEvent(self.parent, StatusEvent(status="Fitting error: %s" % sys.exc_value)) 178 return 177 raise 178 #wx.PostEvent(self.parent, StatusEvent(status="Fitting error: %s" % sys.exc_value)) 179 #return 179 180 -
sansview/perspectives/fitting/fitpanel.py
rb491d6e r925a30e 9 9 (FitPageEvent, EVT_FIT_PAGE) = wx.lib.newevent.NewEvent() 10 10 class FitPanel(wx.aui.AuiNotebook): 11 #class FitPanel(wx.aui.AuiNotebook,wx.panel): 11 12 12 """ 13 13 FitPanel class contains fields allowing to fit models and data … … 22 22 CENTER_PANE = True 23 23 def __init__(self, parent, *args, **kwargs): 24 25 #wx.aui.AuiNotebook.__init__(self,parent,-1, style=wx.aui.AUI_NB_SCROLL_BUTTONS )26 24 wx.aui.AuiNotebook.__init__(self,parent,-1, style=wx.aui.AUI_NB_DEFAULT_STYLE ) 27 25 … … 38 36 self.about_page = PanelAbout(self, -1) 39 37 self.AddPage(self.about_page,"welcome!") 40 #self.about_page.Disable() 41 #Creating a page for simultaneous fitting 38 42 39 43 44 self._mgr = self.GetAuiManager()45 46 47 40 #dictionary of miodel {model class name, model class} 48 41 self.model_list_box={} … … 64 57 def onClosePage(self, event): 65 58 """ 59 close page and remove all references to the closed page 66 60 """ 67 61 selected_page = self.GetPage(self.GetSelection()) … … 78 72 break 79 73 #Delete the page from notebook 80 81 #print "on close",selected_page.name,self.GetPageText(page_number),self.draw_model_name82 83 74 if selected_page.name in self.fit_page_name: 84 75 self.fit_page_name.remove(selected_page.name) 85 76 86 77 if selected_page.name== self.draw_model_name: 87 #print "went here"88 78 self.draw_model_name=None 89 79 self.model_page=None … … 91 81 self.model_page=None 92 82 self.draw_model_name=None 93 #selected_page.Destroy() 94 #self.RemovePage(page_number) 95 #i=self.DeletePage(page_number) 83 96 84 elif selected_page==self.about_page: 97 #selected_page.Destroy()98 #self.DeletePage(page_number)99 85 self.about_page=None 100 86 else: 101 102 87 self.manager.sim_page=None 103 #self.DeletePage(page_number) 104 105 106 88 107 89 108 90 def set_manager(self, manager): … … 112 94 """ 113 95 self.manager = manager 114 #self.sim_page.set_manager(manager) 96 115 97 116 98 def set_owner(self,owner): … … 119 101 @param owner: the class responsible of plotting 120 102 """ 121 self.event_owner =owner103 self.event_owner = owner 122 104 123 105 def add_sim_page(self): 106 """ 107 Add the simultaneous fit page 108 """ 124 109 from simfitpage import SimultaneousFitPage 125 110 self.sim_page = SimultaneousFitPage(self, id=-1) … … 131 116 """ 132 117 Add a fitting page on the notebook contained by fitpanel 133 @param panel: contains in the page to add 134 @param name: title of the page tab 118 @param data: data to fit 135 119 @return panel : page just added for futher used. is used by fitting module 136 120 """ 137 121 try: 138 name = data.name # item in Data1D122 name = data.name 139 123 except: 140 124 name = 'Fit' 141 125 142 #if self.fit_page_name != name and self.draw_model_name !=name:143 126 if not name in self.fit_page_name : 144 #self.about_page.Disable()145 127 from fitpage1D import FitPage1D 146 128 panel = FitPage1D(self,data, -1) 147 129 panel.name=name 148 #m_name= "M"+str(self.count)130 149 131 panel.set_manager(self.manager) 150 132 panel.set_owner(self.event_owner) … … 154 136 self.fit_page_name.append(name) 155 137 156 return panel #,m_name138 return panel 157 139 else: 158 return None #, None140 return None 159 141 160 142 def _help_add_model_page(self,model,description,page_title, qmin=0, qmax=0.1, npts=50): … … 167 149 """ 168 150 from modelpage import ModelPage 169 #print "fitpanel model", model151 170 152 panel = ModelPage(self,model,page_title, -1) 171 153 panel.set_manager(self.manager) … … 201 183 @param npts: number of Q points 202 184 """ 203 #print "self.draw_model_name none",self.draw_model_name204 185 if topmenu==True: 205 186 if self.draw_model_name ==None: 206 #print "self.draw_model_name none"207 187 self._help_add_model_page(model,description,page_title, qmin=qmin, qmax=qmax, npts=npts) 208 188 else: 209 #self.model_page.name=page_title210 #self.draw_model_name=page_title211 #print "wnent here self.draw_model_name ",self.draw_model_name,self.model_page.name,self.model_page212 213 189 self.model_page.select_model(model, page_title) 214 190 … … 217 193 @return the current page selected 218 194 """ 219 #return self.nb.GetCurrentPage()220 195 return self.GetPage(self.GetSelection() ) 221 196 222 223 def onClose(self, page=None,page_number=None): 224 """ 225 close the current page except the simpage. remove each check box link to the model 226 selected on that page. remove its reference into page_finder (fitting module) 227 """ 228 #print "model page", page_number, page, self.draw_model_name 229 if page!=None and page_number!=None: 230 i=self.DeletePage(page_number) 231 #self.nb.RemovePage(page_number) 232 #page.Destroy() 233 self.model_page_number=None 234 self.model_page=None 235 self.draw_model_name=None 236 #print"self.draw_model_name",self.draw_model_name 237 return 238 try: 239 sim_page = self.GetPage(1) 240 selected_page = self.GetPage(self.GetSelection()) 241 #print "sim_page ",sim_page ,selected_page 242 if sim_page != selected_page: 243 #print "sim_page ",sim_page ,selected_page 244 # remove the check box link to the model name of this page (selected_page) 245 sim_page.remove_model(selected_page) 246 #remove that page from page_finder of fitting module 247 page_finder=self.manager.get_page_finder() 248 for page, value in page_finder.iteritems(): 249 if page==selected_page: 250 del page_finder[page] 251 break 252 #Delete the page from notebook 253 page_number = self.GetSelection() 254 #print "on close",selected_page.name,self.GetPageText(page_number),self.draw_model_name 255 256 if selected_page.name in self.fit_page_name: 257 self.fit_page_name.remove(selected_page.name) 258 259 if selected_page.name== self.draw_model_name: 260 #print "went here" 261 self.draw_model_name=None 262 self.model_page=None 263 if page_number == 1: 264 self.model_page=None 265 self.draw_model_name=None 266 #selected_page.Destroy() 267 #self.RemovePage(page_number) 268 i=self.DeletePage(page_number) 269 #self.count =self.count -1 270 271 except: 272 raise 273 #print "fitpanel", self.draw_model_name 274 197 275 198 def set_model_list(self,dict): 276 199 """ -
sansview/perspectives/fitting/fitproblem.py
r2a8fac1 r925a30e 16 16 and its name assign example [lineModel, M0] 17 17 """ 18 ## data used for fitting 18 19 self.fit_data=None 19 self.theory_name=None20 ## list containing couple of model and its name 20 21 self.model_list=[] 22 ## if 1 this fit problem will be selected to fit , if 0 23 ## it will not be selected for fit 21 24 self.schedule=0 25 ##list containing parameter name and value 22 26 self.list_param=[] 23 self.name_per_page=None27 ## smear object to smear or not data1D 24 28 self.smearer= None 29 ## same as fit_data but with more info for plotting 30 ## axis unit info and so on see plottables definition 25 31 self.plotted_data=None 26 32 33 27 34 def set_smearer(self, smearer): 35 """ 36 save reference of smear object on fitdata 37 @param smear : smear object from DataLoader 38 """ 28 39 self.smearer= smearer 29 #print "smeaerer in fitproblem",self.smearer40 30 41 def get_smearer(self): 42 """ 43 return smear object 44 """ 31 45 return self.smearer 32 46 33 def save_model_name(self, name):34 self.name_per_page= name35 36 37 def get_name(self):38 return self.name_per_page39 47 40 48 def set_model(self,model,name): … … 53 61 """ 54 62 self.plotted_data = data 63 64 55 65 def add_fit_data(self,data): 56 66 """ … … 62 72 def get_model(self): 63 73 """ @return: saved model """ 64 #print "fitproblem",self.model_list65 74 return self.model_list 66 75 … … 89 98 def set_model_param(self,name,value): 90 99 """ 91 set the value of a given parameter of this model100 Store the name and value of a parameter of this fitproblem's model 92 101 @param name: name of the given parameter 93 102 @param value: value of that parameter 94 103 """ 95 #print "fitproblem",name,value96 #self.model_list[0].setParam(name,value)97 104 self.list_param.append([name,value]) 105 106 98 107 def get_model_param(self): 99 108 """ 100 set the value of a given parameter of this model 101 @param name: name of the given parameter 102 @param value: value of that parameter 109 @return list of couple of parameter name and value 103 110 """ 104 #print self.param_name, self.param_value105 #self.model_list[0].setParam(name,value)106 111 return self.list_param 112 107 113 108 114 def reset_model(self,model): … … 111 117 @param value: new model 112 118 """ 113 #print "fitproblem : reset model"114 119 self.model_list[0]=model 120 115 121 116 122 def schedule_tofit(self, schedule=0): … … 123 129 """ return true or false if a problem as being schedule for fitting""" 124 130 return self.schedule 131 132 125 133 def clear_model_param(self): 126 134 """ … … 128 136 """ 129 137 self.list_param=[] 138 139 -
sansview/perspectives/fitting/helpPanel.py
r2268d10 r925a30e 46 46 47 47 button_OK = wx.Button(self, wx.ID_OK, "OK") 48 #button_Cancel = wx.Button(self, wx.ID_CANCEL, "Cancel") 49 48 50 49 sizer_button = wx.BoxSizer(wx.HORIZONTAL) 51 50 sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) 52 sizer_button.Add(button_OK, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) 53 #sizer_button.Add(button_Cancel, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) 51 sizer_button.Add(button_OK, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) 54 52 vbox.Add(sizer_button, 0, wx.EXPAND|wx.BOTTOM|wx.TOP, 10) 55 53 … … 63 61 def __init__(self, parent, id, title): 64 62 wx.Frame.__init__(self, parent, id, title, size=(600, 450)) 65 63 """ 64 contains help info 65 """ 66 66 vbox1 = wx.BoxSizer(wx.HORIZONTAL) 67 67 … … 127 127 128 128 self.SetSizer(vbox1) 129 130 129 self.Centre() 131 130 self.Show(True) 131 132 132 133 def OnLinkClicked(self, event): 133 134 """ -
sansview/perspectives/fitting/simfitpage.py
red2ea6a r925a30e 9 9 two data members window_name and window_caption 10 10 """ 11 11 ## Internal name for the AUI manager 12 12 window_name = "simultaneous Fit page" 13 13 ## Title to appear on top of the window … … 21 21 """ 22 22 self.parent = parent 23 #self.page_finder = page_finder24 23 self.page_finder={} 25 24 self.sizer3 = wx.GridBagSizer(5,5) 26 25 self.sizer1 = wx.GridBagSizer(5,5) 27 #self.sizer2 = wx.GridBagSizer(5,5)28 26 self.sizer2 = wx.BoxSizer(wx.HORIZONTAL) 29 27 self.vbox = wx.BoxSizer(wx.VERTICAL) … … 54 52 self.model_toFit=[] 55 53 56 #self.add_model(self.page_finder)57 54 self.vbox.Layout() 58 55 self.vbox.Fit(self) … … 84 81 self.add_model( self.manager.page_finder) 85 82 83 86 84 def select_all_model_name(self,event): 87 85 """ … … 92 90 for item in self.model_list: 93 91 item[0].SetValue(True) 94 #item[1].schedule_tofit(1)95 92 self.manager.schedule_for_fit( value=1,fitproblem =item[1]) 96 93 self.model_toFit.append(item) 97 94 else: 98 #print"simfit: deselected all"99 100 95 for item in self.model_list: 101 96 item[0].SetValue(False) … … 112 107 if len(self.model_list)>0: 113 108 for item in self.model_list: 114 #print "went here to clear"115 109 item[0].SetValue(False) 116 110 self.manager.schedule_for_fit( value=0,fitproblem =item[1]) … … 123 117 iy = 1 124 118 list=[] 125 # if len(self.page_finder)>0:126 119 for page, value in page_finder.iteritems(): 127 120 try: … … 137 130 self.model_list.append([cb,value,page,modelname]) 138 131 except: 139 #wx.PostEvent(self.parent.GrandParent, StatusEvent(status="Simultaneous fit: %s doesn't have a model selected yet %s" % \140 #(value.get_data().group_id,sys.exc_value)))141 132 pass 142 133 iy +=1 … … 145 136 self.vbox.Layout() 146 137 138 147 139 def remove_model(self,delpage): 148 140 """ … … 150 142 @param delpage: the page removed 151 143 """ 152 #print "self.model_list",self.model_list153 154 144 self.model_list=[] 155 145 self.model_toFit=[] … … 174 164 self.model_list.append([cb,value,page,modelname]) 175 165 except: 176 #wx.PostEvent(self.parent.GrandParent, StatusEvent(status="Simultaneous fit: %s doesn't have a model selected yet %s" % \177 #(value.get_data().group_id,sys.exc_value)))178 166 pass 179 167 iy +=1 … … 182 170 self.vbox.Layout() 183 171 172 184 173 def select_model_name(self,event): 185 174 """ … … 189 178 for item in self.model_list: 190 179 if item[0].GetValue()==True: 191 #item[1].schedule_tofit('True')192 #item[1].schedule_tofit(1)193 180 self.model_toFit.append(item) 194 181 self.manager.schedule_for_fit( value=1,fitproblem =item[1]) 195 182 else: 196 #print"simfit: deselected one"197 183 self.manager.schedule_for_fit( value=0,fitproblem =item[1]) 198 184 if item in self.model_toFit: … … 209 195 def set_model(self): 210 196 """ 211 set_model take values in self.params which are the values enters by the user 212 and try to assign them into the model concerned in self.manager. page.finder 197 set_model take values in self.params which are the values 198 entered by the user and try to assign them into the model 199 concerned in self.manager. page.finder 213 200 """ 214 201 if len(self.params) >0: 215 202 for item in self.model_toFit: 216 #print"simfitpage: self.model_toFit",item[1]217 203 list=item[1].get_model() 218 #print "simfitpage: list fitpanel2",list,list[0]219 204 model=list[0] 220 205 param_list=model.getParamList() 221 #print "simfitpage: on set_model self.params ",self.params222 206 if self.params !=[]: 223 207 for element in self.params: … … 225 209 for item in param_list: 226 210 if item==str(element[1]): 227 #print "simfitpage: on set_model page 1",param_list 228 #print "simfitpage: model name",element[0], model.name 229 #print "simfitpage: param name ,param value",element[1],element[2] 230 self.manager.set_page_finder(model.name,element[1],\ 211 self.manager.set_page_finder(model.name,element[1], 231 212 str(element[2])) 232 #print "simfitpage:on set_model page 2",model.params['A'],self.params[2]213 233 214 234 215 def _onTextEnter(self): … … 236 217 get values from the constrainst textcrtl ,parses them into model name 237 218 parameter name and parameters values. 238 store them in a list self.params .when when params is not empty set_model uses it239 to reset the appropriate model and its appropriates parameters219 store them in a list self.params .when when params is not empty set_model 220 uses it to reset the appropriate model and its appropriates parameters 240 221 """ 241 222 value= self.ctl2.GetValue() 242 223 if value: 243 224 self.params=[] 244 #print "simfitpage: value",value245 225 try: 246 226 expression='[\s,;]' 247 227 if re.search(expression,value) !=None: 248 228 word=re.split(expression,value) 249 #print "simfitpage: when herre",word250 229 for item in word: 251 230 self.params.append(self.parser_helper(item)) … … 253 232 self.params.append(self.parser_helper(value)) 254 233 except: 255 #raise256 234 wx.PostEvent(self.parent.Parent, StatusEvent(status="Constraint Error: %s" % sys.exc_value)) 257 #print "simfitpage: self.params",self.params 258 def new_parser_helper(self,value): 235 236 237 def parser_helper(self,value): 259 238 """ 260 239 @return param:a list containing the name of a model ,its parameters 261 240 value and name extracted from the constrainst controlbox 262 241 """ 263 from sans.guiframe import utils264 mylist=["=","<",">","<=", ">="]265 for item in mylist:266 if utils.look_for_tag( value,str(item))[0]:267 #print "went here"268 model_param = utils.split_text(str(item), value,1)269 param_name = model_param[0]270 param_value = model_param[1]271 #print "simpage",utils.look_for_tag(param_name,"\.")[0]272 if utils.look_for_tag(param_name,"\.")[0]:273 param_names = utils.split_text("\.",param_name,1)274 model_name = param_names[0]275 param_name = param_names[1]276 ##### just added277 #print "simfitpage: param name",model_name,param_name278 279 param=[str(model_name),param_name,str(param_value),"="]280 #print "simfitpage: param",param281 return param282 else:283 #raise ValueError,"cannot evaluate this expression"284 wx.PostEvent(self.parent.Parent,285 StatusEvent(status="cannot evaluate this expression"))286 return287 elif utils.look_for_tag( value,"<")[0]:288 model_param = utils.split_text("<", value,2)289 if len(model_param)== 2:290 try:291 param_name = str(model_param[0])292 param_value = float(model_param[1])293 param=[str(model_name),param_name,param_value,"<"]294 #print "simfitpage: param",param295 return param296 except:297 wx.PostEvent(self.parent.Parent, StatusEvent(status="\298 could read this expression%s" % sys.exc_value))299 return300 else:301 #raise ValueError,"Missing '=' in expression"302 wx.PostEvent(self.parent.Parent, StatusEvent(status="Missing '=' in expression"))303 304 305 306 def parser_helper(self,value):307 """308 @return param:a list containing the name of a model ,its parameters309 value and name extracted from the constrainst controlbox310 """311 #print "simfitpage: value",value312 242 if string.find(value, "=") !=-1: 313 243 model_param= re.split("=",value) 314 244 param_name=model_param[0] 315 245 param_value=model_param[1] 316 #print"simfitpage: ", param_name 317 #print "simfitpage: ",param_value 246 318 247 if string.find(param_name,".")!=-1: 319 248 param_names= re.split("\.",param_name) 320 249 model_name=param_names[0] 321 250 param_name=param_names[1] 322 ##### just added323 #print "simfitpage: param name",model_name,param_name324 325 251 param=[str(model_name),param_name,str(param_value)] 326 #print "simfitpage: param",param327 252 return param 328 253 else: 329 #raise ValueError,"cannot evaluate this expression"330 254 wx.PostEvent(self.parent.Parent, 331 255 StatusEvent(status="cannot evaluate this expression")) 332 256 return 333 257 else: 334 #raise ValueError,"Missing '=' in expression"335 258 wx.PostEvent(self.parent.Parent, StatusEvent(status="Missing '=' in expression")) 336 259
Note: See TracChangeset
for help on using the changeset viewer.