Changeset e9b4cc4 in sasview for sansview/perspectives/fitting/fitting.py
- Timestamp:
- Jan 15, 2009 5:39:19 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:
- 633ba04
- Parents:
- 681f0dc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/fitting.py
rd23544dc re9b4cc4 10 10 from fitproblem import FitProblem 11 11 from fitpanel import FitPanel 12 12 from fit_thread import FitThread 13 13 import models,modelpage 14 14 import fitpage1D,fitpage2D 15 15 import park 16 16 DEFAULT_BEAM = 0.005 17 import time 18 import thread 19 print "main",thread.get_ident() 20 17 21 class Plugin: 18 22 """ … … 28 32 ## List of panels for the simulation perspective (names) 29 33 self.perspective = [] 34 35 self.calc_thread = None 36 self.done = False 30 37 # Start with a good default 31 38 self.elapsed = 0.022 … … 222 229 return model_name,param_name 223 230 224 225 def _single_fit_completed(self,result,pars,cpage,qmin,qmax, ymin=None, ymax=None):231 232 def _single_fit_completed(self,result,pars,cpage,qmin,qmax,elapsed,ymin=None, ymax=None): 226 233 """ 227 234 Display fit result on one page of the notebook. … … 233 240 234 241 """ 242 #self.done = True 243 #wx.PostEvent(self.parent, StatusEvent(status="Fitting Completed: %g" % elapsed)) 235 244 try: 236 245 for page, value in self.page_finder.iteritems(): … … 260 269 261 270 262 def _simul_fit_completed(self,result,qmin,qmax, ymin=None, ymax=None):271 def _simul_fit_completed(self,result,qmin,qmax, elapsed,pars=None,cpage=None, ymin=None, ymax=None): 263 272 """ 264 273 Parameter estimation completed, … … 267 276 @param elapsed: computation time 268 277 """ 278 wx.PostEvent(self.parent, StatusEvent(status="Fitting Completed: %g" % elapsed)) 269 279 try: 270 280 for page, value in self.page_finder.iteritems(): … … 291 301 wx.PostEvent(self.parent, StatusEvent(status="Fitting error: %s" % sys.exc_value)) 292 302 293 303 294 304 def _on_single_fit(self,id=None,qmin=None,qmax=None,ymin=None,ymax=None): 295 305 """ … … 344 354 #of parameter names in the list 345 355 try: 346 result=self.fitter.fit() 347 #self._single_fit_completed(result,pars,current_pg,qmin,qmax) 348 #print "single_fit: result",result.fitness,result.pvec,result.stderr 349 #self._single_fit_completed(result,pars,page,qmin,qmax) 350 self._single_fit_completed(result,pars,page_fitted,qmin,qmax,ymin,ymax) 356 # If a thread is already started, stop it 357 if self.calc_thread != None and self.calc_thread.isrunning(): 358 self.calc_thread.stop() 359 360 self.calc_thread =FitThread(parent =self.parent, 361 fn= self.fitter, 362 pars= pars, 363 cpage= page_fitted, 364 qmin=qmin, 365 qmax=qmax, 366 ymin= ymin, 367 ymax= ymax, 368 completefn=self._single_fit_completed, 369 updatefn=None) 370 self.calc_thread.queue() 371 self.calc_thread.ready(2.5) 372 #while not self.done: 373 #print "when here" 374 # time.sleep(1) 375 376 351 377 except: 352 378 raise … … 412 438 #Do the simultaneous fit 413 439 try: 414 result=self.fitter.fit() 415 self._simul_fit_completed(result,qmin,qmax,ymin,ymax) 440 # If a thread is already started, stop it 441 if self.calc_thread != None and self.calc_thread.isrunning(): 442 self.calc_thread.stop() 443 444 self.calc_thread =FitThread(parent =self.parent, 445 fn= self.fitter, 446 qmin=qmin, 447 qmax=qmax, 448 ymin= ymin, 449 ymax= ymax, 450 completefn= self._simul_fit_completed, 451 updatefn=None) 452 self.calc_thread.queue() 453 self.calc_thread.ready(2.5) 454 416 455 except: 417 456 wx.PostEvent(self.parent, StatusEvent(status="Simultaneous Fitting error: %s" % sys.exc_value)) … … 479 518 self.plot_helper(currpage=page,qmin= qmin,qmax= qmax) 480 519 481 def plot_helper(self,currpage, qmin=None,qmax=None,ymin=None,ymax=None):520 def plot_helper(self,currpage, fitModel=None, qmin=None,qmax=None,ymin=None,ymax=None): 482 521 """ 483 522 Plot a theory given a model and data … … 654 693 except: 655 694 raise 656 def update(self, output,elapsed): 657 print "Got an update", elapsed 658 wx.PostEvent(self.parent, StatusEvent(status="Plot \ 659 updating ... %g sec" % elapsed)) 695 def update(self, output,time): 696 pass 660 697 661 698 def complete(self, output, elapsed, model, qmin, qmax): 662 #printEVT("Calc complete in %g sec" % elapsed)699 663 700 wx.PostEvent(self.parent, StatusEvent(status="Calc \ 664 701 complete in %g sec" % elapsed)) … … 723 760 qmax=qmax, 724 761 completefn=self.complete, 725 updatefn= self.update)762 updatefn=None) 726 763 self.calc_thread.queue() 727 764 self.calc_thread.ready(2.5)
Note: See TracChangeset
for help on using the changeset viewer.