Changeset 202a7dc3 in sasview
- Timestamp:
- Feb 17, 2009 10:15:53 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:
- 2cd9153
- Parents:
- ef628a1
- Location:
- sansview/perspectives/fitting
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/fit_thread.py
rf343069 r202a7dc3 133 133 self.done= False 134 134 wx.PostEvent(self.parent, StatusEvent(status=\ 135 "Start the computation %g " % self.starttime,curr_thread=self,type="start"))135 "Start the computation ",curr_thread=self,type="start")) 136 136 def isquit(self): 137 137 try: … … 148 148 elapsed = time.time()-self.starttime 149 149 wx.PostEvent(self.parent, StatusEvent(status="Computing \ 150 ... %g sec" % elapsed,curr_thread=self,type="update"))150 ... " ,curr_thread=self,type="update")) 151 151 152 152 def compute(self): … … 154 154 self.starttime = time.time() 155 155 wx.PostEvent(self.parent, StatusEvent(status=\ 156 "Setting the fit Engine %g " % self.starttime,curr_thread=self,type="progress"))156 "Setting the fit Engine ...",curr_thread=self,type="progress")) 157 157 handler= ConsoleUpdate(parent= self.parent,improvement_delta=0.1) 158 158 result = self.fitter.fit(handler= handler) -
sansview/perspectives/fitting/fitting.py
rf343069 r202a7dc3 49 49 self._fit_engine = 'scipy' 50 50 self.enable_model2D=False 51 self.fit_id= 0 51 52 # Log startup 52 53 logging.info("Fitting plug-in started") … … 371 372 self.fitter= Fit(self._fit_engine) 372 373 #Setting an id to store model and data in fit engine 373 if id==None: 374 self.id=0 375 else: 376 self.id = id 374 if id!=None: 375 self.fit_id= id 376 377 377 page_fitted=None 378 378 fit_problem=None 379 379 #Get information (model , data) related to the page on 380 380 #with the fit will be perform 381 #current_pg=self.fit_panel.get_current_page()382 #simul_pg=self.fit_panel.get_page(0)381 current_pg=self.fit_panel.get_current_page() 382 simul_pg=self.fit_panel.GetPage(1 ) 383 383 pars=[] 384 for page, value in self.page_finder.iteritems(): 385 if value.get_scheduled() ==1 : 386 metadata = value.get_data() 387 list=value.get_model() 388 model=list[0] 389 smearer= value.get_smearer() 390 print "single fit", model, smearer 391 #Create list of parameters for fitting used 384 #for page, value in self.page_finder.iteritems(): 385 if current_pg!= simul_pg: 386 # if value.get_scheduled() ==1 : 387 value = self.page_finder[current_pg] 388 metadata = value.get_data() 389 list = value.get_model() 390 model = list[0] 391 smearer= value.get_smearer() 392 print "single fit", model, smearer 393 #Create list of parameters for fitting used 394 395 templist=[] 396 try: 397 #templist=current_pg.get_param_list() 398 templist=current_pg.get_param_list() 399 for element in templist: 400 pars.append(str(element[0].GetLabelText())) 401 pars.sort() 402 print "single fit start pars:", pars 403 #Do the single fit 404 self.fitter.set_model(Model(model), self.fit_id, pars) 405 #print "args...:",metadata,self.fit_id,smearer,qmin,qmax,ymin,ymax 406 407 self.fitter.set_data(data=metadata,Uid=self.fit_id, 408 smearer=smearer,qmin= qmin,qmax=qmax, 409 ymin=ymin,ymax=ymax) 410 self.fitter.select_problem_for_fit(Uid=self.fit_id,value=value.get_scheduled()) 411 page_fitted=current_pg 412 self.fit_id+=1 413 #self.schedule_for_fit( 0,value) 414 except: 415 raise 416 #wx.PostEvent(self.parent, StatusEvent(status="Fitting error: %s" % sys.exc_value)) 417 return 418 # make sure to keep an alphabetic order 419 #of parameter names in the list 420 try: 421 # If a thread is already started, stop it 422 if self.calc_thread != None and self.calc_thread.isrunning(): 423 self.calc_thread.stop() 424 425 self.calc_thread =FitThread(parent =self.parent, 426 fn= self.fitter, 427 pars= pars, 428 cpage= page_fitted, 429 qmin=qmin, 430 qmax=qmax, 431 432 completefn=self._single_fit_completed, 433 updatefn=None) 434 self.calc_thread.queue() 435 self.calc_thread.ready(2.5) 436 #while not self.done: 437 #print "when here" 438 # time.sleep(1) 392 439 393 templist=[] 394 try: 395 #templist=current_pg.get_param_list() 396 templist=page.get_param_list() 397 for element in templist: 398 pars.append(str(element[0].GetLabelText())) 399 pars.sort() 400 #print "single fit start pars:", pars 401 #Do the single fit 402 self.fitter.set_model(Model(model), self.id, pars) 403 #print "args...:",metadata,self.id,smearer,qmin,qmax,ymin,ymax 404 405 self.fitter.set_data(data=metadata,Uid=self.id, 406 smearer=smearer,qmin= qmin,qmax=qmax, 407 ymin=ymin,ymax=ymax) 408 print "single---->value of problem",value.get_scheduled() 409 self.fitter.select_problem_for_fit(Uid=self.id,value=value.get_scheduled()) 410 page_fitted=page 411 self.id+=1 412 #self.schedule_for_fit( 0,value) 413 except: 414 raise 415 #wx.PostEvent(self.parent, StatusEvent(status="Fitting error: %s" % sys.exc_value)) 416 return 417 # make sure to keep an alphabetic order 418 #of parameter names in the list 419 try: 420 # If a thread is already started, stop it 421 if self.calc_thread != None and self.calc_thread.isrunning(): 422 self.calc_thread.stop() 423 424 self.calc_thread =FitThread(parent =self.parent, 425 fn= self.fitter, 426 pars= pars, 427 cpage= page_fitted, 428 qmin=qmin, 429 qmax=qmax, 430 431 completefn=self._single_fit_completed, 432 updatefn=None) 433 self.calc_thread.queue() 434 self.calc_thread.ready(2.5) 435 #while not self.done: 436 #print "when here" 437 # time.sleep(1) 438 439 440 except: 441 raise 442 wx.PostEvent(self.parent, StatusEvent(status="Single Fit error: %s" % sys.exc_value)) 443 return 440 441 except: 442 raise 443 wx.PostEvent(self.parent, StatusEvent(status="Single Fit error: %s" % sys.exc_value)) 444 return 444 445 445 446 def _on_simul_fit(self, id=None,qmin=None,qmax=None, ymin=None, ymax=None): … … 457 458 458 459 #Setting an id to store model and data 459 if id ==None:460 id = 0461 self.id = id460 if id!=None: 461 self.fit_id= id 462 462 463 463 464 for page, value in self.page_finder.iteritems(): … … 493 494 new_model.parameterset[ param_name].set( param_value ) 494 495 495 self.fitter.set_model(new_model, self. id, pars)496 self.fitter.set_data(metadata,self. id,qmin,qmax,ymin,ymax)496 self.fitter.set_model(new_model, self.fit_id, pars) 497 self.fitter.set_data(metadata,self.fit_id,qmin,qmax,ymin,ymax) 497 498 print "sim---->value of problem",value.get_scheduled() 498 self.fitter.select_problem_for_fit(Uid=self.id,value=value.get_scheduled()) 499 self.id += 1 499 self.fitter.select_problem_for_fit(Uid=self.fit_id,value=value.get_scheduled()) 500 self.fit_id += 1 501 self.schedule_for_fit( 0,value) 500 502 except: 501 503 #raise
Note: See TracChangeset
for help on using the changeset viewer.