Changeset 66ff250 in sasview for sansview/perspectives/fitting
- Timestamp:
- Mar 18, 2011 6:20:50 PM (14 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:
- e4957fb
- Parents:
- 511c6810
- Location:
- sansview/perspectives/fitting
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/basepage.py
rf95301b r66ff250 65 65 self.data = None 66 66 self.mask = None 67 self. id = None67 self.uid = None 68 68 ## Q range 69 69 self.qmin = None … … 1448 1448 is_modified = False 1449 1449 1450 wx.PostEvent(self._manager.parent, StatusEvent(status=" \1451 updating ... ",type="update"))1450 #wx.PostEvent(self._manager.parent, StatusEvent(status=" \ 1451 #updating ... ",type="update")) 1452 1452 1453 1453 ##So make sure that update param values on_Fit. … … 1482 1482 else: 1483 1483 self._manager.set_smearer(smearer=temp_smearer, 1484 id=self.id,1484 uid=self.uid, 1485 1485 qmin=float(self.qmin_x), 1486 1486 qmax=float(self.qmax_x), … … 1489 1489 self._manager.set_smearer(smearer=temp_smearer, 1490 1490 qmin=float(self.qmin_x), 1491 id=self.id,1491 uid=self.uid, 1492 1492 qmax= float(self.qmax_x)) 1493 1493 index_data = ((self.qmin_x <= self.data.x)&\ … … 1759 1759 qmax=float(self.qmax_x), 1760 1760 qstep= float(self.npts_x), 1761 id=self.id,1761 page_id=self.uid, 1762 1762 toggle_mode_on=toggle_mode_on, 1763 1763 state = self.state, -
sansview/perspectives/fitting/console.py
re8bf1ed r66ff250 18 18 improvement_delta = 5 19 19 """Number of seconds between improvement updates""" 20 def __init__(self,parent, quiet=False,progress_delta=60,improvement_delta=5): 20 def __init__(self, parent, manager=None, 21 quiet=False,progress_delta=60,improvement_delta=5): 21 22 """ 22 23 If quiet is true, only print out final summary, not progress and … … 27 28 """ 28 29 self.parent= parent 30 self.manager = manager 29 31 self.progress_time = time.time() 30 32 self.progress_percent = 0 … … 52 54 self.improvement_time = t 53 55 54 wx.PostEvent(self.parent, StatusEvent(status=\55 "%d%% complete ..."%(p),type="progress"))56 #wx.PostEvent(self.parent, StatusEvent(status=\ 57 # "%d%% complete ..."%(p),type="progress")) 56 58 57 59 # Update percent complete … … 63 65 self.progress_percent = p 64 66 self.progress_time = t 65 wx.PostEvent(self.parent, StatusEvent(status=\66 "%d%% complete ..."%(p),67 type="progress"))67 #wx.PostEvent(self.parent, StatusEvent(status=\ 68 # "%d%% complete ..."%(p), 69 # type="progress")) 68 70 69 71 elif 2 < dp <= 5: 70 72 if p//5 != self.progress_percent//5: 71 wx.PostEvent(self.parent, StatusEvent(status=\72 "%d%% complete ..."%(5*(p//5)),type="progress"))73 #wx.PostEvent(self.parent, StatusEvent(status=\ 74 # "%d%% complete ..."%(5*(p//5)),type="progress")) 73 75 self.progress_percent = p 74 76 self.progress_time = t … … 77 79 self.progress_percent = p 78 80 self.progress_time = t 79 wx.PostEvent(self.parent, StatusEvent(status=\80 "%d%% complete ..."%(10*(p//10)),type="progress"))81 #wx.PostEvent(self.parent, StatusEvent(status=\ 82 #"%d%% complete ..."%(10*(p//10)),type="progress")) 81 83 82 84 def improvement(self): … … 93 95 if self.isbetter: 94 96 self.result.print_summary() 95 message = "fit Error"96 message = str(msg)+ " \n %s"%self.result.__str__()97 wx.PostEvent(self.parent, StatusEvent(status=message,98 info="error", type="stop"))97 #message = "fit Error" 98 #message = str(msg)+ " \n %s"%self.result.__str__() 99 #wx.PostEvent(self.parent, StatusEvent(status=message, 100 # info="error", type="stop")) 99 101 100 102 def finalize(self): … … 110 112 self.result.print_summary() 111 113 114 112 115 def update_fit(self, msg=""): 113 116 """ 114 117 """ 115 self.elapsed_time = time.time() - self.elapsed_time 116 msg = " Updating fit ...\n result:\n %s \n"%self.result.__str__() 117 wx.PostEvent(self.parent, StatusEvent(status=msg, info="info", 118 type="progress")) 119 time.sleep(0.01) 118 #self.elapsed_time = time.time() - self.elapsed_time 119 #msg = " Updating fit ...\n result:\n %s \n"%self.result.__str__() 120 #wx.PostEvent(self.parent, StatusEvent(status=msg, info="info", 121 # type="progress")) 122 #if self.manager is not None: 123 # self.manager.update_fit(msg=msg, result=self.result) 124 #time.sleep(0.01) 120 125 121 126 def starting_fit(self): 122 127 """ 123 128 """ 124 wx.PostEvent(self.parent, StatusEvent(status="Starting the Fit...",125 info="info",type="progress"))129 #wx.PostEvent(self.parent, StatusEvent(status="Starting the Fit...", 130 # info="info",type="progress")) 126 131 127 132 def set_result(self, result): … … 129 134 """ 130 135 self.result = result 136 137 def get_result(self): 138 """ 139 """ 140 return self.result 131 141 132 142 -
sansview/perspectives/fitting/fit_thread.py
r6bbeacd4 r66ff250 1 1 2 import sys 3 from data_util.calcthread import CalcThread 2 4 3 from data_util.calcthread import CalcThread4 5 5 6 class FitThread(CalcThread): … … 8 9 def __init__(self, parent, 9 10 fn, 11 page_id, 10 12 handler, 11 13 pars=None, … … 23 25 self.fitter = fn 24 26 self.pars = pars 27 self.page_id = page_id 25 28 self.starttime = 0 26 29 self.updatefn = updatefn … … 35 38 except KeyboardInterrupt: 36 39 raise KeyboardInterrupt 37 40 38 41 def compute(self): 39 42 """ … … 41 44 """ 42 45 try: 43 self.handler.starting_fit() 44 self.updatefn() 46 #self.handler.starting_fit() 45 47 #Result from the fit 46 48 result = self.fitter.fit(handler=self.handler, curr_thread=self) 47 self.updatefn()48 49 self.complete(result= result, 50 page_id=self.page_id, 49 51 pars = self.pars) 50 52 … … 54 56 #print "keyboard exception" 55 57 #Stop on exception during fitting. Todo: need to put some mssg and reset progress bar. 56 self.handler.error(msg=msg) 58 raise 59 #if self.handler is not None: 60 # self.handler.error(msg=msg) 61 except: 62 raise 63 #if self.handler is not None: 64 # self.handler.error(msg=str(sys.exc_value)) 65 57 66 67 -
sansview/perspectives/fitting/fitpage.py
rf95301b r66ff250 13 13 from sans.guiframe.utils import format_number,check_float 14 14 15 16 17 ## event to know the selected fit engine18 (FitterTypeEvent, EVT_FITTER_TYPE) = wx.lib.newevent.NewEvent()19 (FitStopEvent, EVT_FIT_STOP) = wx.lib.newevent.NewEvent()20 15 (Chi2UpdateEvent, EVT_CHI2_UPDATE) = wx.lib.newevent.NewEvent() 21 16 _BOX_WIDTH = 76 … … 52 47 self._fill_range_sizer() 53 48 self._set_smear(self.data) 54 ## to update the panel according to the fit engine type selected55 self.Bind(EVT_FITTER_TYPE,self._on_engine_change)56 self.Bind(EVT_FIT_STOP,self._on_fit_complete)57 49 self.Bind(EVT_CHI2_UPDATE, self.on_complete_chisqr) 58 50 self._set_bookmark_flag(False) 59 51 self._set_save_flag(False) 60 52 61 def _on_fit_complete(self , event):53 def _on_fit_complete(self): 62 54 """ 63 55 When fit is complete ,reset the fit button label. 64 56 """ 65 #self.btFit.SetLabel("Fit") 66 #self.btFit.Unbind(event=wx.EVT_BUTTON, id=self.btFit.GetId()) 67 #self.btFit.Bind(event=wx.EVT_BUTTON, handler=self._onFit,id=self.btFit.GetId()) 68 pass 57 self.btFit.SetLabel("Fit") 58 self.bind_fit_button() 69 59 70 60 def _is_2D(self): … … 75 65 76 66 """ 77 78 67 if self.data.__class__.__name__ =="Data2D": 79 68 return True 80 69 return False 81 70 82 def _on_engine_change(self, event): 83 """ 84 get an event containing the current name of the fit engine type 85 86 :param event: FitterTypeEvent containing the name of the current engine 87 88 """ 89 self.engine_type = event.type 71 def _on_engine_change(self, name): 72 """ 73 get the current name of the fit engine type 74 and update the panel accordingly 75 """ 76 77 self.engine_type = str(name) 90 78 self.state.engine_type = self.engine_type 91 if len(self.parameters) ==0:79 if len(self.parameters) == 0: 92 80 self.Layout() 93 81 return 94 if event.type =="park":95 self.btFit.SetLabel("Fit")96 82 #if self.engine_type =="park": 83 # self.btFit.SetLabel("Fit") 84 # self.bind_fit_button() 97 85 for item in self.parameters: 98 if event.type =="scipy" :86 if self.engine_type =="scipy" : 99 87 item[5].SetValue("") 100 88 item[5].Hide() … … 110 98 self.text2_max.Show(True) 111 99 for item in self.fittable_param: 112 if item[5]!=None and item[6]!=None and not item in self.orientation_params_disp: 113 if event.type =="scipy" and not item in self.orientation_params: 100 if item[5]!=None and item[6]!=None and not \ 101 item in self.orientation_params_disp: 102 if self.engine_type =="scipy" and \ 103 not item in self.orientation_params: 114 104 item[5].SetValue("") 115 105 item[5].Hide() … … 130 120 for item in self.orientation_params: 131 121 if item[5]!=None and item[6]!=None: 132 if event.type =="scipy" or self.data.__class__.__name__ !="Data2D": 122 if self.engine_type =="scipy" or \ 123 self.data.__class__.__name__ !="Data2D": 133 124 item[5].SetValue("") 134 125 item[5].Hide() … … 141 132 for item in self.orientation_params_disp: 142 133 if item[5]!=None and item[6]!=None: 143 if event.type =="scipy" or self.data.__class__.__name__ !="Data2D": 134 if self.engine_type =="scipy" or \ 135 self.data.__class__.__name__ !="Data2D": 144 136 item[5].SetValue("") 145 137 item[5].Hide() … … 151 143 self.Layout() 152 144 self.Refresh() 153 145 154 146 155 147 … … 965 957 self.qmin_x = float(self.qmin.GetValue()) 966 958 self.qmax_x = float( self.qmax.GetValue()) 967 self._manager._reset_schedule_problem( id=self.id,value=0)968 self._manager.schedule_for_fit( id=self.id,value=1, fitproblem =None)969 self._manager.set_fit_range( id=self.id,qmin= self.qmin_x,959 self._manager._reset_schedule_problem(value=0) 960 self._manager.schedule_for_fit(uid=self.uid,value=1, fitproblem =None) 961 self._manager.set_fit_range(uid=self.uid,qmin= self.qmin_x, 970 962 qmax= self.qmax_x) 971 963 972 964 #single fit 973 965 self._manager.onFit() 974 ## allow stopping the fit 966 self.btFit.SetLabel("Stop") 967 self.bind_fit_button() 968 969 def bind_fit_button(self): 970 """ 971 bind the fit button to either fit handler or stop fit handler 972 """ 973 self.btFit.Unbind(event=wx.EVT_BUTTON, id= self.btFit.GetId()) 974 if self.btFit.GetLabel().lower() == "stop": 975 self.btFit.Bind(event=wx.EVT_BUTTON, handler=self._StopFit, 976 id=self.btFit.GetId()) 977 elif self.btFit.GetLabel().lower() == "fit": 978 self.btFit.Bind(event=wx.EVT_BUTTON, handler=self._onFit, 979 id=self.btFit.GetId()) 980 else: 981 msg = "FitPage: fit button has unknown label" 982 raise ValuerError, msg 983 self._manager._reset_schedule_problem(value=0) 984 985 986 def _StopFit(self, event): 987 """ 988 Stop fit 989 """ 975 990 #if self.engine_type=="scipy": 976 # self.btFit.SetLabel("Stop") 977 # self.btFit.Unbind(event=wx.EVT_BUTTON, id= self.btFit.GetId()) 978 # self.btFit.Bind(event= wx.EVT_BUTTON, 979 # handler=self._StopFit, id=self.btFit.GetId()) 980 #else: 981 # self.btFit.SetLabel("Fit") 982 # self.btFit.Bind(event= wx.EVT_BUTTON, 983 # handler=self._onFit, id=self.btFit.GetId()) 984 985 def _StopFit(self, event): 986 """ 987 Stop fit 988 """ 989 self.btFit.SetLabel("Fit") 990 if self.engine_type=="scipy": 991 self._manager.stop_fit() 992 self.btFit.Unbind(event=wx.EVT_BUTTON, id=self.btFit.GetId()) 993 self.btFit.Bind(event=wx.EVT_BUTTON, handler=self._onFit, 994 id=self.btFit.GetId()) 995 996 991 self._manager.stop_fit(self.uid) 992 self._manager._reset_schedule_problem(value=0) 993 self._on_fit_complete() 994 997 995 def _on_select_model(self, event=None): 998 996 """ … … 1033 1031 temp_smear = self.smearer 1034 1032 except: 1033 raise 1035 1034 ## error occured on chisqr computation 1036 pass1035 #pass 1037 1036 ## event to post model to fit to fitting plugins 1038 1037 (ModelEventbox, EVT_MODEL_BOX) = wx.lib.newevent.NewEvent() … … 1043 1042 smearer=temp_smear, 1044 1043 qmin=float(self.qmin_x), 1045 id=self.id,1044 uid=self.uid, 1046 1045 qmax=float(self.qmax_x)) 1047 1046 … … 1075 1074 tcrtl = event.GetEventObject() 1076 1075 1077 wx.PostEvent(self._manager.parent, StatusEvent(status=" \1078 updating ... ",type="update"))1076 #wx.PostEvent(self._manager.parent, StatusEvent(status=" \ 1077 # updating ... ",type="update")) 1079 1078 #Clear msg if previously shown. 1080 1079 msg= "" … … 1098 1097 elif self.data.__class__.__name__ !="Data2D": 1099 1098 self._manager.set_smearer(smearer=temp_smearer, 1100 id=self.id,1099 uid=self.uid, 1101 1100 qmin= float(self.qmin_x), 1102 1101 qmax= float(self.qmax_x), … … 2229 2228 self.Layout() 2230 2229 ## set smearing value whether or not the data contain the smearing info 2231 self._manager.set_smearer( id=self.id, smearer=temp_smearer, qmin= float(self.qmin_x),2230 self._manager.set_smearer(uid=self.uid, smearer=temp_smearer, qmin= float(self.qmin_x), 2232 2231 qmax= float(self.qmax_x), draw=True) 2233 2232 -
sansview/perspectives/fitting/fitpanel.py
rf95301b r66ff250 8 8 from sans.guiframe.events import PanelOnFocusEvent 9 9 from sans.guiframe.events import StatusEvent 10 10 11 import basepage 11 12 import models … … 51 52 #page of simultaneous fit 52 53 self.sim_page = None 54 self.fit_engine_type = "scipy" 53 55 ## get the state of a page 54 56 self.Bind(basepage.EVT_PAGE_INFO, self._onGetstate) … … 56 58 self.Bind(basepage.EVT_NEXT_STATE, self._onRedo) 57 59 self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED, self.on_page_changing) 58 60 59 61 #add default pages 60 62 self.add_default_pages() 61 63 64 def _on_engine_change(self, name='scipy'): 65 """ 66 """ 67 for panel in self.opened_pages.values(): 68 self.set_engine_helper(panel=panel, name=name) 69 70 def set_engine_helper(self, panel, name='scipy'): 71 """ 72 """ 73 self.fit_engine_type = name 74 if panel != self.sim_page: 75 panel._on_engine_change(name=self.fit_engine_type) 76 62 77 def update_model_list(self): 63 78 """ … … 67 82 68 83 69 def get_page_by_id(self, id):70 """ 71 """ 72 if id not in self.opened_pages:73 msg = "Fitpanel cannot find ID: %s in self.opened_pages" % str( id)84 def get_page_by_id(self, uid): 85 """ 86 """ 87 if uid not in self.opened_pages: 88 msg = "Fitpanel cannot find ID: %s in self.opened_pages" % str(uid) 74 89 raise ValueError, msg 75 90 else: 76 return self.opened_pages[ id]91 return self.opened_pages[uid] 77 92 78 93 def on_page_changing(self, event): … … 157 172 page_is_opened = False 158 173 if state is not None: 159 for id, panel in self.opened_pages.iteritems():174 for uid, panel in self.opened_pages.iteritems(): 160 175 #Don't return any panel is the exact same page is created 161 if id == panel.id:176 if uid == panel.uid: 162 177 # the page is still opened 163 178 panel.reset_page(state=state) … … 168 183 # add data associated to the page created 169 184 if panel is not None: 170 self._manager.store_page(page=panel. id, data=state.data)185 self._manager.store_page(page=panel.uid, data=state.data) 171 186 panel.reset_page(state=state) 172 187 panel.save_current_state() … … 250 265 page_finder= self._manager.get_page_finder() 251 266 self.sim_page = SimultaneousFitPage(self,page_finder=page_finder, id=-1) 252 self.sim_page. id = wx.NewId()267 self.sim_page.uid = wx.NewId() 253 268 self.AddPage(self.sim_page,"Simultaneous Fit", True) 254 269 self.sim_page.set_manager(self._manager) … … 262 277 from fitpage import FitPage 263 278 panel = FitPage(parent=self) 264 panel. id = wx.NewId()279 panel.uid = wx.NewId() 265 280 panel.populate_box(dict=self.model_list_box) 266 281 panel.set_manager(self._manager) 267 282 caption = str(panel.window_name) + " " + str(self._manager.index_model) 268 283 self.AddPage(panel, caption, select=True) 269 self.opened_pages[panel.id] = panel 284 self.opened_pages[panel.uid] = panel 285 self.set_engine_helper(panel=panel) 270 286 return panel 271 287 … … 308 324 page = self.add_empty_page() 309 325 pos = self.GetPageIndex(page) 310 page.id = wx.NewId()311 326 page.set_data(data) 312 327 self.SetPageText(pos, str(data.name)) 313 self.opened_pages[page. id] = page328 self.opened_pages[page.uid] = page 314 329 315 330 return page … … 320 335 """ 321 336 page = event.page 322 if page. id in self.fit_page_name:323 self.fit_page_name[page. id].appendItem(page.createMemento())337 if page.uid in self.fit_page_name: 338 self.fit_page_name[page.uid].appendItem(page.createMemento()) 324 339 325 340 def _onUndo(self, event ): … … 328 343 """ 329 344 page = event.page 330 if page. id in self.fit_page_name:331 if self.fit_page_name[page. id].getCurrentPosition()==0:345 if page.uid in self.fit_page_name: 346 if self.fit_page_name[page.uid].getCurrentPosition()==0: 332 347 state = None 333 348 else: 334 state = self.fit_page_name[page. id].getPreviousItem()349 state = self.fit_page_name[page.uid].getPreviousItem() 335 350 page._redo.Enable(True) 336 351 page.reset_page(state) … … 341 356 """ 342 357 page = event.page 343 if page. id in self.fit_page_name:344 length= len(self.fit_page_name[page. id])345 if self.fit_page_name[page. id].getCurrentPosition()== length -1:358 if page.uid in self.fit_page_name: 359 length= len(self.fit_page_name[page.uid]) 360 if self.fit_page_name[page.uid].getCurrentPosition()== length -1: 346 361 state = None 347 362 page._redo.Enable(False) 348 363 page._redo.Enable(True) 349 364 else: 350 state =self.fit_page_name[page. id].getNextItem()365 state =self.fit_page_name[page.uid].getNextItem() 351 366 page.reset_page(state) 352 367 … … 376 391 if selected_page in page_finder: 377 392 #Delete the name of the page into the list of open page 378 for id, list in self.opened_pages.iteritems():393 for uid, list in self.opened_pages.iteritems(): 379 394 #Don't return any panel is the exact same page is created 380 395 381 if flag and selected_page. id ==id:382 self._manager.remove_plot( id, theory=False)396 if flag and selected_page.uid == uid: 397 self._manager.remove_plot(uid, theory=False) 383 398 break 384 399 del page_finder[selected_page] … … 392 407 393 408 #Delete the name of the page into the list of open page 394 for id, list in self.opened_pages.iteritems():409 for uid, list in self.opened_pages.iteritems(): 395 410 #Don't return any panel is the exact same page is created 396 411 397 if selected_page. id ==id:398 del self.opened_pages[selected_page. id]412 if selected_page.uid == uid: 413 del self.opened_pages[selected_page.uid] 399 414 break 400 415 -
sansview/perspectives/fitting/fitting.py
rf95301b r66ff250 23 23 import fitpage 24 24 25 25 26 from DataLoader.loader import Loader 26 27 from sans.guiframe.dataFitting import Data2D … … 67 68 self.calc_2D = None 68 69 self.calc_1D = None 69 self. calc_fit = None70 self.fit_thread_list = {} 70 71 71 72 # Start with a good default … … 278 279 title=str(data.title))) 279 280 except: 280 msg = "Fitting Set_data: " + str(sys.exc_value) 281 wx.PostEvent(self.parent, StatusEvent(status=msg, info="error")) 281 raise 282 #msg = "Fitting Set_data: " + str(sys.exc_value) 283 #wx.PostEvent(self.parent, StatusEvent(status=msg, info="error")) 282 284 283 285 def set_theory(self, theory_list=None): … … 378 380 self.state_reader.write(filename=filepath, fitstate=fitstate) 379 381 380 def set_fit_range(self, id, qmin, qmax):382 def set_fit_range(self, uid, qmin, qmax): 381 383 """ 382 384 Set the fitting range of a given page 383 385 """ 384 self.page_finder[ id].set_range(qmin=qmin, qmax=qmax)386 self.page_finder[uid].set_range(qmin=qmin, qmax=qmax) 385 387 386 def schedule_for_fit(self,value=0, id=None,fitproblem =None):388 def schedule_for_fit(self,value=0, uid=None,fitproblem =None): 387 389 """ 388 390 Set the fit problem field to 0 or 1 to schedule that problem to fit. … … 397 399 fitproblem.schedule_tofit(value) 398 400 else: 399 self.page_finder[ id].schedule_tofit(value)401 self.page_finder[uid].schedule_tofit(value) 400 402 401 403 def get_page_finder(self): … … 416 418 417 419 """ 418 sim_page_id = self.sim_page. id419 for id, value in self.page_finder.iteritems():420 if id != sim_page_id:420 sim_page_id = self.sim_page.uid 421 for uid, value in self.page_finder.iteritems(): 422 if uid != sim_page_id: 421 423 list = value.get_model() 422 424 model = list[0] … … 444 446 return model_name,param_name 445 447 446 def stop_fit(self ):448 def stop_fit(self, uid): 447 449 """ 448 450 Stop the fit engine 449 451 """ 450 if self.calc_fit!= None and self.calc_fit.isrunning(): 451 self.calc_fit.stop() 452 wx.PostEvent(self.parent, StatusEvent(status="Fitting \ 453 is cancelled" , type="stop")) 452 if uid in self.fit_thread_list.keys(): 453 calc_fit = self.fit_thread_list[uid] 454 if calc_fit is not None and calc_fit.isrunning(): 455 calc_fit.stop() 456 msg = "Fit stop!" 457 wx.PostEvent(self.parent, StatusEvent(status=msg, type="stop")) 458 #set the fit button label of page when fit stop is trigger from 459 #simultaneous fit pane 460 if self.sim_page is not None and uid == self.sim_page.uid: 461 for uid, value in self.page_finder.iteritems(): 462 if value.get_scheduled() == 1: 463 if uid in self.fit_panel.opened_pages.keys(): 464 panel = self.fit_panel.opened_pages[uid] 465 panel. _on_fit_complete() 454 466 455 def set_smearer(self, id, smearer, qmin=None, qmax=None, draw=True):467 def set_smearer(self, uid, smearer, qmin=None, qmax=None, draw=True): 456 468 """ 457 469 Get a smear object and store it to a fit problem … … 460 472 461 473 """ 462 if id not in self.page_finder.keys():463 msg = "Cannot find ID: %s in page_finder" % str( id)474 if uid not in self.page_finder.keys(): 475 msg = "Cannot find ID: %s in page_finder" % str(uid) 464 476 raise ValueError, msg 465 self.page_finder[ id].set_smearer(smearer)477 self.page_finder[uid].set_smearer(smearer) 466 478 if draw: 467 479 ## draw model 1D with smeared data 468 data = self.page_finder[ id].get_fit_data()469 model = self.page_finder[ id].get_model()480 data = self.page_finder[uid].get_fit_data() 481 model = self.page_finder[uid].get_model() 470 482 if model is None: 471 483 return 472 484 ## if user has already selected a model to plot 473 485 ## redraw the model with data smeared 474 smear = self.page_finder[ id].get_smearer()475 self.draw_model(model=model, data=data, id=id, smearer=smear,486 smear = self.page_finder[uid].get_smearer() 487 self.draw_model(model=model, data=data, page_id=uid, smearer=smear, 476 488 qmin=qmin, qmax=qmax) 477 489 478 def draw_model(self, model, id, data=None, smearer=None,490 def draw_model(self, model, page_id, data=None, smearer=None, 479 491 enable1D=True, enable2D=False, 480 492 state=None, … … 500 512 self._draw_model1D(model=model, 501 513 data=data, 502 id=id,514 page_id=page_id, 503 515 enable1D=enable1D, 504 516 smearer=smearer, … … 511 523 ## draw model 2D with no initial data 512 524 self._draw_model2D(model=model, 513 id=id,525 page_id=page_id, 514 526 data=data, 515 527 enable2D=enable2D, … … 527 539 ## count the number of fitproblem schedule to fit 528 540 fitproblem_count = 0 529 for value in self.page_finder. itervalues():541 for value in self.page_finder.values(): 530 542 if value.get_scheduled() == 1: 531 543 fitproblem_count += 1 … … 538 550 539 551 from sans.fit.Fitting import Fit 540 self.fitter = Fit(self._fit_engine)552 fitter = Fit(self._fit_engine) 541 553 542 554 if self._fit_engine == "park": … … 547 559 fproblemId = 0 548 560 self.current_pg = None 549 for id, value in self.page_finder.iteritems(): 561 list_page_id = [] 562 for page_id, value in self.page_finder.iteritems(): 550 563 try: 551 564 if value.get_scheduled() == 1: … … 553 566 pars = [] 554 567 templist = [] 555 page = self.fit_panel.get_page_by_id(id) 568 569 page = self.fit_panel.get_page_by_id(page_id) 556 570 templist = page.get_param_list() 557 571 for element in templist: … … 560 574 #Set Engine (model , data) related to the page on 561 575 self._fit_helper(value=value, pars=pars, 562 id=fproblemId, title=engineType) 576 fitter=fitter, 577 fitproblem_id=fproblemId, 578 title=engineType) 579 list_page_id.append(page_id) 563 580 fproblemId += 1 564 self.current_page_id = page581 current_page_id = page_id 565 582 except: 566 583 raise … … 573 590 # self.calc_fit.stop() 574 591 #Handler used for park engine displayed message 575 handler = ConsoleUpdate(parent=self.parent,improvement_delta=0.1) 592 handler = ConsoleUpdate(parent=self.parent, 593 manager=self, 594 improvement_delta=0.1) 595 576 596 ## perform single fit 577 597 if fitproblem_count == 1: 578 598 calc_fit = FitThread(parent=self.parent, 579 599 handler = handler, 580 fn= self.fitter,600 fn=fitter, 581 601 pars=pars, 582 updatefn=handler.update_fit,602 page_id=list_page_id, 583 603 completefn=self._single_fit_completed) 584 604 else: 605 current_page_id = self.sim_page.uid 585 606 ## Perform more than 1 fit at the time 586 607 calc_fit = FitThread(parent=self.parent, 587 608 handler=handler, 588 fn= self.fitter,589 completefn= self._simul_fit_completed,590 updatefn=handler.update_fit)591 609 fn=fitter, 610 page_id=list_page_id, 611 completefn= self._simul_fit_completed) 612 self.fit_thread_list[current_page_id] = calc_fit 592 613 calc_fit.queue() 593 614 self.ready_fit(calc_fit=calc_fit) 594 615 616 595 617 def ready_fit(self, calc_fit): 596 618 """ … … 603 625 time.sleep(0.4) 604 626 605 def remove_plot(self, id, theory=False):627 def remove_plot(self, uid, theory=False): 606 628 """ 607 629 remove model plot when a fit page is closed 608 630 """ 609 fitproblem = self.page_finder[ id]631 fitproblem = self.page_finder[uid] 610 632 data = fitproblem.get_fit_data() 611 633 model = fitproblem.get_model() 612 id = None634 plot_id = None 613 635 if model is not None: 614 id = data.id + name636 plot_id = data.id + name 615 637 if theory: 616 id = data.id638 plot_id = data.id 617 639 group_id = data.group_id 618 wx.PostEvent(self.parent, NewPlotEvent(id= id,640 wx.PostEvent(self.parent, NewPlotEvent(id=plot_id, 619 641 group_id=group_id, 620 642 action='remove')) 621 643 622 def store_data(self, id, data=None, caption=None):644 def store_data(self, uid, data=None, caption=None): 623 645 """ 624 646 Helper to save page reference into the plug-in … … 628 650 """ 629 651 #create a fitproblem storing all link to data,model,page creation 630 if not id in self.page_finder.keys():631 self.page_finder[ id] = FitProblem()632 self.page_finder[ id].set_fit_data(data)633 self.page_finder[ id].set_fit_tab_caption(caption)652 if not uid in self.page_finder.keys(): 653 self.page_finder[uid] = FitProblem() 654 self.page_finder[uid].set_fit_data(data) 655 self.page_finder[uid].set_fit_tab_caption(caption) 634 656 635 657 def on_add_new_page(self, event=None): … … 642 664 # add data associated to the page created 643 665 if page != None: 644 self.store_data( id=page.id, caption=page_caption,666 self.store_data(uid=page.uid, caption=page_caption, 645 667 data=page.get_data()) 646 668 wx.PostEvent(self.parent, StatusEvent(status="Page Created", … … 665 687 #append Data1D to the panel containing its theory 666 688 #if theory already plotted 667 if page. id in self.page_finder:668 theory_data = self.page_finder[page. id].get_theory_data()689 if page.uid in self.page_finder: 690 theory_data = self.page_finder[page.uid].get_theory_data() 669 691 if issubclass(data.__class__, Data2D): 670 692 data.group_id = wx.NewId() 671 693 if theory_data is not None: 672 group_id = str(page. id) + " Model1D"694 group_id = str(page.uid) + " Model1D" 673 695 wx.PostEvent(self.parent, 674 696 NewPlotEvent(group_id=group_id, … … 677 699 else: 678 700 if theory_data is not None: 679 group_id = str(page. id) + " Model2D"701 group_id = str(page.uid) + " Model2D" 680 702 data.group_id = theory_data.group_id 681 703 wx.PostEvent(self.parent, … … 684 706 self.parent.update_data(prev_data=theory_data, new_data=data) 685 707 686 self.store_data( id=page.id, data=data, caption=page.window_name)708 self.store_data(uid=page.uid, data=data, caption=page.window_name) 687 709 if self.sim_page is not None: 688 710 self.sim_page.draw_page() … … 709 731 if event is None or event.data is None: 710 732 return 711 712 733 if hasattr(event.data,"is_data"): 713 734 if not event.data.is_data or \ 714 event.data.__class__.__name__ =="Data1D":735 event.data.__class__.__name__ == "Data1D": 715 736 self.fit_panel.close_page_with_data(event.data) 716 737 717 def _add_page_onmenu(self, name, fitproblem=None):738 def _add_page_onmenu(self, name, fitproblem=None): 718 739 """ 719 740 Add name of a closed page of fitpanel in a menu … … 729 750 self.menu1.Append(event_id, name, "Show %s fit panel" % name) 730 751 self.closed_page_dict[name]= [event_id, fitproblem] 731 wx.EVT_MENU(self.parent, event_id,self._open_closed_page)752 wx.EVT_MENU(self.parent, event_id, self._open_closed_page) 732 753 733 754 def _open_closed_page(self, event): … … 737 758 for name, value in self.closed_page_dict.iteritems(): 738 759 if event.GetId() in value: 739 id,fitproblem = value760 uid,fitproblem = value 740 761 if name !="Model": 741 762 data= fitproblem.get_fit_data() 742 763 page = self.fit_panel.add_fit_page(data=data, reset=True) 743 764 if fitproblem != None: 744 self.page_finder[ id] = fitproblem765 self.page_finder[uid] = fitproblem 745 766 if self.sim_page != None: 746 767 self.sim_page.draw_page() … … 752 773 break 753 774 754 def _reset_schedule_problem(self, id,value=0):775 def _reset_schedule_problem(self, value=0): 755 776 """ 756 777 unschedule or schedule all fitproblem to be fit 757 778 """ 758 779 for page_id in self.page_finder.keys(): 759 self.page_finder[ id].schedule_tofit(value)760 761 def _fit_helper(self, pars, value, id, title="Single Fit " ):780 self.page_finder[page_id].schedule_tofit(value) 781 782 def _fit_helper(self, pars, value, fitproblem_id,fitter, title="Single Fit " ): 762 783 """ 763 784 helper for fitting … … 767 788 smearer = value.get_smearer() 768 789 qmin, qmax = value.get_range() 769 self.fit_id = id790 self.fit_id = fitproblem_id 770 791 #Create list of parameters for fitting used 771 792 templist = [] … … 783 804 784 805 #Do the single fit 785 self.fitter.set_model(model, self.fit_id,806 fitter.set_model(model, self.fit_id, 786 807 pars, constraints=listOfConstraint) 787 808 788 self.fitter.set_data(data=metadata, id=self.fit_id,809 fitter.set_data(data=metadata, id=self.fit_id, 789 810 smearer=smearer, qmin=qmin, qmax=qmax) 790 811 791 self.fitter.select_problem_for_fit(id=self.fit_id,812 fitter.select_problem_for_fit(id=self.fit_id, 792 813 value=value.get_scheduled()) 793 814 value.clear_model_param() … … 814 835 self.add_fit_page(data=data) 815 836 816 def _single_fit_completed(self,result, pars, elapsed=None): 837 def update_fit(self, result=None, msg=""): 838 """ 839 """ 840 print "update_fit result", result 841 842 def _single_fit_completed(self, result, pars, page_id, elapsed=None): 817 843 """ 818 844 Display fit result on one page of the notebook. … … 826 852 """ 827 853 try: 828 if result == None:854 if result == None: 829 855 msg= "Simple Fitting Stop !!!" 830 856 wx.PostEvent(self.parent, StatusEvent(status=msg,info="warning", … … 838 864 StatusEvent(status=msg, type="stop")) 839 865 return 840 page_id = None 841 for id, value in self.page_finder.iteritems(): 842 if value.get_scheduled()==1: 843 model = value.get_model() 844 page_id = id 845 break 846 param_name = [] 847 i = 0 848 for name in pars: 849 param_name.append(name) 850 851 cpage = self.fit_panel.get_page_by_id(page_id) 852 cpage.onsetValues(result.fitness, 853 param_name, result.pvec,result.stderr) 866 for uid in page_id: 867 value = self.page_finder[uid] 868 model = value.get_model() 869 page_id = uid 870 871 param_name = [] 872 for name in pars: 873 param_name.append(name) 874 875 cpage = self.fit_panel.get_page_by_id(uid) 876 cpage.onsetValues(result.fitness, 877 param_name, result.pvec,result.stderr) 878 cpage._on_fit_complete() 854 879 855 880 except: 856 msg = "Single Fit completed but Following" 857 msg += " error occurred:%s" % sys.exc_value 858 wx.PostEvent(self.parent, StatusEvent(status=msg, info="error", 859 type="stop")) 881 raise 882 #msg = "Single Fit completed but Following" 883 #msg += " error occurred:%s" % sys.exc_value 884 #wx.PostEvent(self.parent, StatusEvent(status=msg, info="error", 885 # type="stop")) 860 886 return 861 887 862 def _simul_fit_completed(self, result, pa rs=None, elapsed=None):888 def _simul_fit_completed(self, result, page_id,pars=None, elapsed=None): 863 889 """ 864 890 Parameter estimation completed, … … 869 895 870 896 """ 897 if page_id is None: 898 page_id = [] 871 899 ## fit more than 1 model at the same time 872 900 try: 873 901 msg = "" 874 if result ==None: 875 msg= "Complex Fitting Stop !!!" 876 wx.PostEvent(self.parent, StatusEvent(status=msg,type="stop")) 902 if result == None: 903 msg = "Complex Fitting Stop !!!" 904 wx.PostEvent(self.parent, StatusEvent(status=msg, 905 type="stop")) 877 906 return 878 if not numpy.isfinite(result.fitness) or numpy.any(result.pvec ==None )or not numpy.all(numpy.isfinite(result.pvec) ): 907 if not numpy.isfinite(result.fitness) or \ 908 numpy.any(result.pvec == None) or not \ 909 numpy.all(numpy.isfinite(result.pvec)): 879 910 msg= "Simultaneous Fitting did not converge!!!" 880 911 wx.PostEvent(self.parent, StatusEvent(status=msg,type="stop")) 881 912 return 882 913 883 for id, value in self.page_finder.iteritems(): 884 if value.get_scheduled() == 1: 885 model = value.get_model() 886 data = value.get_fit_data() 887 small_param_name = [] 888 small_out = [] 889 small_cov = [] 890 i = 0 891 #Separate result in to data corresponding to each page 892 for p in result.parameters: 893 model_name,param_name = self.split_string(p.name) 894 if model.name == model_name: 895 p_name= model.name+"."+param_name 896 if p.name == p_name: 897 if p.value != None and numpy.isfinite(p.value): 898 small_out.append(p.value ) 899 small_param_name.append(param_name) 900 small_cov.append(p.stderr) 901 902 # Display result on each page 903 cpage = self.fit_panel.get_page_by_id(id) 904 cpage.onsetValues(result.fitness, 905 small_param_name, 906 small_out,small_cov) 914 for uid in page_id: 915 value = self.page_finder[uid] 916 model = value.get_model() 917 data = value.get_fit_data() 918 small_param_name = [] 919 small_out = [] 920 small_cov = [] 921 #Separate result in to data corresponding to each page 922 for p in result.parameters: 923 model_name, param_name = self.split_string(p.name) 924 if model.name == model_name: 925 p_name= model.name+"."+param_name 926 if p.name == p_name: 927 if p.value != None and numpy.isfinite(p.value): 928 small_out.append(p.value) 929 small_param_name.append(param_name) 930 small_cov.append(p.stderr) 931 # Display result on each page 932 cpage = self.fit_panel.get_page_by_id(uid) 933 cpage.onsetValues(result.fitness, 934 small_param_name, 935 small_out,small_cov) 936 cpage._on_fit_complete() 907 937 except: 908 raise 909 #msg= "Simultaneous Fit completed" 910 #msg +=" but Following error occurred:%s"%sys.exc_value 911 #wx.PostEvent(self.parent, StatusEvent(status=msg,type="stop")) 912 #return 913 938 msg = "Simultaneous Fit completed" 939 msg += " but Following error occurred:%s" % sys.exc_value 940 wx.PostEvent(self.parent, StatusEvent(status=msg, type="stop")) 941 914 942 def _on_show_panel(self, event): 915 943 """ … … 992 1020 wx.PostEvent(self.parent, 993 1021 StatusEvent(status=msg)) 994 ## Bind every open fit page with a newevent to 995 #know the current fitting engine 996 #import fitpage 997 event = fitpage.FitterTypeEvent() 998 event.type = self._fit_engine 999 wx.PostEvent(self.fit_panel, event) 1022 ## send the current engine type to fitpanel 1023 self.fit_panel._on_engine_change(name=self._fit_engine) 1000 1024 1001 1025 def _on_model_panel(self, evt): … … 1007 1031 """ 1008 1032 model = evt.model 1009 id = evt.id1033 uid = evt.uid 1010 1034 qmin = evt.qmin 1011 1035 qmax = evt.qmax … … 1015 1039 return 1016 1040 1017 if self.page_finder[ id].get_model() is None:1041 if self.page_finder[uid].get_model() is None: 1018 1042 model.name = "M" + str(self.index_model) 1019 1043 self.index_model += 1 1020 1044 else: 1021 model.name = self.page_finder[ id].get_model().name1045 model.name = self.page_finder[uid].get_model().name 1022 1046 # save the name containing the data name with the appropriate model 1023 self.page_finder[ id].set_model(model)1024 self.page_finder[ id].set_range(qmin=qmin, qmax=qmax)1047 self.page_finder[uid].set_model(model) 1048 self.page_finder[uid].set_range(qmin=qmin, qmax=qmax) 1025 1049 if self.sim_page is not None: 1026 1050 self.sim_page.draw_page() … … 1030 1054 Update the output of plotting model 1D 1031 1055 """ 1032 msg = "Plot updating ... "1033 wx.PostEvent(self.parent, StatusEvent(status=msg,type="update"))1034 self.ready_fit()1056 #msg = "Plot updating ... " 1057 #wx.PostEvent(self.parent, StatusEvent(status=msg,type="update")) 1058 #self.ready_fit() 1035 1059 #self.calc_thread.ready(0.01) 1036 1060 1037 def _fill_default_model2D(self, theory, id, qmax,qstep, qmin=None):1061 def _fill_default_model2D(self, theory, page_id, qmax,qstep, qmin=None): 1038 1062 """ 1039 1063 fill Data2D with default value … … 1118 1142 theory.ymin = ymin 1119 1143 theory.ymax = ymax 1120 theory.group_id = str( id) + " Model2D"1121 theory.id = str( id) + " Model2D"1144 theory.group_id = str(page_id) + " Model2D" 1145 theory.id = str(page_id) + " Model2D" 1122 1146 1123 def _complete1D(self, x,y, id, elapsed,index,model,1147 def _complete1D(self, x,y, page_id, elapsed,index,model, 1124 1148 toggle_mode_on=False,state=None, data=None): 1125 1149 """ … … 1136 1160 #if the theory is already plotted use the same group id 1137 1161 #to replot 1138 if id in self.page_finder:1139 theory_data = self.page_finder[ id].get_theory_data()1162 if page_id in self.page_finder: 1163 theory_data = self.page_finder[page_id].get_theory_data() 1140 1164 if theory_data is not None: 1141 1165 data.group_id = theory_data.group_id … … 1149 1173 new_plot.title = "Analytical model 1D " 1150 1174 #find a group id to plot theory without data 1151 new_plot.group_id = str( id) + " Model1D"1152 new_plot.id = str( id) + " Model1D"1175 new_plot.group_id = str(page_id) + " Model1D" 1176 new_plot.id = str(page_id) + " Model1D" 1153 1177 1154 1178 #find if this theory was already plotted and replace that plot given 1155 1179 #the same id 1156 if id in self.page_finder:1157 theory_data = self.page_finder[id].get_theory_data()1158 1159 1180 1181 theory_data = self.page_finder[page_id].get_theory_data() 1182 if theory_data is not None: 1183 new_plot.id = theory_data.id 1160 1184 1161 1185 new_plot.name = model.name + " ["+ str(model.__class__.__name__)+ "]" … … 1163 1187 new_plot.yaxis(_yaxis, _yunit) 1164 1188 if toggle_mode_on: 1165 new_plot.id = str( id) + " Model"1189 new_plot.id = str(page_id) + " Model" 1166 1190 wx.PostEvent(self.parent, 1167 NewPlotEvent(group_id=str( id) + " Model2D",1191 NewPlotEvent(group_id=str(page_id) + " Model2D", 1168 1192 action="Hide")) 1169 1193 1170 self.page_finder[ id].set_theory_data(new_plot)1171 theory_data = self.page_finder[ id].get_theory_data()1194 self.page_finder[page_id].set_theory_data(new_plot) 1195 theory_data = self.page_finder[page_id].get_theory_data() 1172 1196 if data is None: 1173 1197 name = "Data generates by Fitting " … … 1181 1205 theory=theory_data, 1182 1206 state=state) 1183 current_pg = self.fit_panel.get_page_by_id( id)1207 current_pg = self.fit_panel.get_page_by_id(page_id) 1184 1208 title = new_plot.title 1185 1209 wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, … … 1188 1212 wx.PostEvent(current_pg, 1189 1213 Chi2UpdateEvent(output=self._cal_chisqr(data=data, 1190 id=id,1214 page_id=page_id, 1191 1215 index=index))) 1192 1216 msg = "Plot 1D complete !" … … 1202 1226 Update the output of plotting model 1203 1227 """ 1204 wx.PostEvent(self.parent, StatusEvent(status="Plot \1228 #wx.PostEvent(self.parent, StatusEvent(status="Plot \ 1205 1229 #updating ... ", type="update")) 1206 self.ready_fit()1230 #self.ready_fit() 1207 1231 #self.calc_thread.ready(0.01) 1208 1232 1209 def _complete2D(self, image, data, model, id, elapsed, index, qmin,1233 def _complete2D(self, image, data, model, page_id, elapsed, index, qmin, 1210 1234 qmax, toggle_mode_on=False,state=None,qstep=DEFAULT_NPTS): 1211 1235 """ … … 1221 1245 self._fill_default_model2D(theory=new_plot, 1222 1246 qmax=qmax, 1223 id=id,1247 page_id=page_id, 1224 1248 qstep=qstep, 1225 1249 qmin= qmin) 1226 1250 1227 1251 else: 1228 new_plot.id = str( id) + " Model2D"1229 new_plot.group_id = str( id) + " Model2D"1252 new_plot.id = str(page_id) + " Model2D" 1253 new_plot.group_id = str(page_id) + " Model2D" 1230 1254 new_plot.x_bins = data.x_bins 1231 1255 new_plot.y_bins = data.y_bins … … 1250 1274 theory_data.name = "Unknown" 1251 1275 if toggle_mode_on: 1252 new_plot.id = str( id) + " Model"1276 new_plot.id = str(page_id) + " Model" 1253 1277 wx.PostEvent(self.parent, 1254 NewPlotEvent(group_id=str( id) + " Model1D",1278 NewPlotEvent(group_id=str(page_id) + " Model1D", 1255 1279 action="Hide")) 1256 1280 1257 self.page_finder[ id].set_theory_data(new_plot)1258 theory_data = self.page_finder[ id].get_theory_data()1281 self.page_finder[page_id].set_theory_data(new_plot) 1282 theory_data = self.page_finder[page_id].get_theory_data() 1259 1283 if data is None: 1260 1284 name = "Data generates by Fitting " … … 1267 1291 theory=theory_data, 1268 1292 state=state) 1269 current_pg = self.fit_panel.get_page_by_id( id)1293 current_pg = self.fit_panel.get_page_by_id(page_id) 1270 1294 title = new_plot.title 1271 1295 wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, … … 1273 1297 # Chisqr in fitpage 1274 1298 wx.PostEvent(current_pg, 1275 Chi2UpdateEvent(output=self._cal_chisqr(data=data, id=id, index=index))) 1299 Chi2UpdateEvent(output=self._cal_chisqr(data=data, 1300 page_id=page_id, 1301 index=index))) 1276 1302 msg = "Plot 2D complete !" 1277 1303 wx.PostEvent(self.parent, StatusEvent(status=msg, type="stop")) 1278 1304 1279 def _draw_model2D(self, model, id, data=None, smearer=None,1305 def _draw_model2D(self, model, page_id, data=None, smearer=None, 1280 1306 description=None, enable2D=False, 1281 1307 state=None, … … 1303 1329 endpoint=True) 1304 1330 if model is None: 1305 msg = "Panel with ID: %s does not contained model" % str( id)1331 msg = "Panel with ID: %s does not contained model" % str(page_id) 1306 1332 raise ValueError, msg 1307 1333 ## use data info instead … … 1325 1351 model=model, 1326 1352 data=data, 1327 id=id,1353 page_id=page_id, 1328 1354 smearer=smearer, 1329 1355 qmin=qmin, … … 1332 1358 toggle_mode_on=toggle_mode_on, 1333 1359 state=state, 1334 completefn=self._complete2D ,1335 updatefn=self._update2D)1360 completefn=self._complete2D)#, 1361 #updatefn=self._update2D) 1336 1362 self.calc_2D.queue() 1337 1363 … … 1342 1368 #wx.PostEvent(self.parent, StatusEvent(status=msg)) 1343 1369 1344 def _draw_model1D(self, model, id, data=None, smearer=None,1370 def _draw_model1D(self, model, page_id, data=None, smearer=None, 1345 1371 qmin=DEFAULT_QMIN, qmax=DEFAULT_QMAX, 1346 1372 state=None, … … 1378 1404 data=data, 1379 1405 model=model, 1380 id=id,1406 page_id=page_id, 1381 1407 qmin=qmin, 1382 1408 qmax=qmax, … … 1384 1410 state=state, 1385 1411 toggle_mode_on=toggle_mode_on, 1386 completefn=self._complete1D ,1387 updatefn=self._update1D)1412 completefn=self._complete1D)#, 1413 #updatefn=self._update1D) 1388 1414 self.calc_1D.queue() 1389 1415 … … 1393 1419 wx.PostEvent(self.parent, StatusEvent(status=msg)) 1394 1420 1395 def _cal_chisqr(self, id, data=None, index=None):1421 def _cal_chisqr(self, page_id, data=None, index=None): 1396 1422 """ 1397 1423 Get handy Chisqr using the output from draw1D and 2D, … … 1411 1437 index = index & (data.err_data != 0) 1412 1438 fn = data.data[index] 1413 theory_data = self.page_finder[ id].get_theory_data()1439 theory_data = self.page_finder[page_id].get_theory_data() 1414 1440 gn = theory_data.data[index] 1415 1441 en = data.err_data[index] … … 1426 1452 dy[dy==0] = 1 1427 1453 fn = data.y[index] 1428 theory_data = self.page_finder[ id].get_theory_data()1454 theory_data = self.page_finder[page_id].get_theory_data() 1429 1455 gn = theory_data.y 1430 1456 en = dy[index] -
sansview/perspectives/fitting/model_thread.py
rfa65e99 r66ff250 15 15 """ 16 16 def __init__(self, x, y, data,model,smearer,qmin, qmax,qstep, 17 id ,17 page_id , 18 18 state=None, 19 19 toggle_mode_on=False, … … 34 34 self.y = y 35 35 self.data= data 36 self.page_id = id36 self.page_id = page_id 37 37 self.state = None 38 38 # the model on to calculate … … 122 122 self.complete(image=output, 123 123 data=self.data, 124 id=self.page_id,124 page_id=self.page_id, 125 125 model=self.model, 126 126 state=self.state, … … 138 138 """ 139 139 def __init__(self, x, model, 140 id,140 page_id, 141 141 data=None, 142 142 qmin=None, … … 163 163 self.toggle_mode_on = toggle_mode_on 164 164 self.state = state 165 self.page_id = id165 self.page_id = page_id 166 166 self.smearer = smearer 167 167 self.starttime = 0 … … 186 186 187 187 self.complete(x=self.x[index], y=output[index], 188 id=self.page_id,188 page_id=self.page_id, 189 189 state=self.state, 190 190 toggle_mode_on=self.toggle_mode_on, -
sansview/perspectives/fitting/simfitpage.py
r6bbeacd4 r66ff250 65 65 ## number of constraint 66 66 self.nb_constraint= 0 67 self.id = wx.NewId() 67 68 ## draw page 68 69 self.define_page_structure() … … 140 141 ## model was actually selected from this page to be fit 141 142 if len(self.model_toFit) >= 1 : 142 self.manager._reset_schedule_problem( 143 self.manager._reset_schedule_problem(value=0) 143 144 for item in self.model_list: 144 145 if item[0].GetValue():
Note: See TracChangeset
for help on using the changeset viewer.