- Timestamp:
- Feb 17, 2009 3:55:06 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:
- 9e27de9
- Parents:
- 282a3e7
- Location:
- sansview/perspectives/fitting
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/fit_thread.py
r202a7dc3 r3215d32 154 154 self.starttime = time.time() 155 155 wx.PostEvent(self.parent, StatusEvent(status=\ 156 " Setting the fit Engine...",curr_thread=self,type="progress"))156 "Computing . ...",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
r202a7dc3 r3215d32 49 49 self._fit_engine = 'scipy' 50 50 self.enable_model2D=False 51 self.fit_id= 051 52 52 # Log startup 53 53 logging.info("Fitting plug-in started") … … 276 276 277 277 278 def _single_fit_completed(self,result,pars,cpage,qmin,qmax,elapsed ,278 def _single_fit_completed(self,result,pars,cpage,qmin,qmax,elapsed=None, 279 279 ymin=None, ymax=None, xmin=None, xmax=None): 280 280 """ … … 290 290 #print "single fit ", pars,result.pvec,result.stderr,result.fitness 291 291 wx.PostEvent(self.parent, StatusEvent(status="Single fit \ 292 complete in %g sec" % elapsed, type="stop"))292 complete " , type="stop")) 293 293 try: 294 294 for page, value in self.page_finder.iteritems(): … … 299 299 break 300 300 i = 0 301 print "single-->result",pars,cpage,str(result),result.parameters,result.fitness,result.stderr 301 302 #print "fitting: single fit pars ", pars 302 303 for name in pars: … … 330 331 @param elapsed: computation time 331 332 """ 332 wx.PostEvent(self.parent, StatusEvent(status="Sinmultaneous fit \ 333 complete in %g sec" % elapsed, type="stop")) 334 try: 335 for page, value in self.page_finder.iteritems(): 336 if value.get_scheduled()==1: 337 #fitdata = value.get_data() 338 list = value.get_model() 339 model= list[0] 340 341 small_out = [] 342 small_cov = [] 343 i = 0 344 #Separate result in to data corresponding to each page 345 for p in result.parameters: 346 model_name,param_name = self.split_string(p.name) 347 if model.name == model_name: 348 small_out.append(p.value ) 349 small_cov.append(p.stderr) 350 model.setParam(param_name,p.value) 351 # Display result on each page 352 page.onsetValues(result.fitness, small_out,small_cov) 353 #Replot model 354 self.plot_helper(currpage= page,qmin= qmin,qmax= qmax, 355 xmin=xmin, xmax=xmax, 356 ymin=ymin, ymax=ymax) 357 except: 358 wx.PostEvent(self.parent, StatusEvent(status="Fitting error: %s" % sys.exc_value)) 359 333 if cpage!=None: 334 self._single_fit_completed(result=result,pars=pars,cpage=cpage, 335 qmin=qmin,qmax=qmax, 336 ymin=ymin, ymax=ymax, xmin=xmin, xmax=xmax) 337 return 338 else: 339 wx.PostEvent(self.parent, StatusEvent(status="Simultaneous fit \ 340 complete ", type="stop")) 341 print "result",cpage,str(result),result.parameters,result.fitness,result.stderr 342 343 try: 344 for page, value in self.page_finder.iteritems(): 345 if value.get_scheduled()==1: 346 #fitdata = value.get_data() 347 list = value.get_model() 348 model= list[0] 349 350 small_out = [] 351 small_cov = [] 352 i = 0 353 #Separate result in to data corresponding to each page 354 for p in result.parameters: 355 model_name,param_name = self.split_string(p.name) 356 if model.name == model_name: 357 small_out.append(p.value ) 358 small_cov.append(p.stderr) 359 model.setParam(param_name,p.value) 360 # Display result on each page 361 page.onsetValues(result.fitness, small_out,small_cov) 362 #Replot model 363 self.plot_helper(currpage= page,qmin= qmin,qmax= qmax, 364 xmin=xmin, xmax=xmax, 365 ymin=ymin, ymax=ymax) 366 except: 367 raise 368 wx.PostEvent(self.parent, StatusEvent(status="Simultaneous Fitting error: %s" % sys.exc_value)) 369 360 370 361 371 def _on_single_fit(self,id=None,qmin=None, qmax=None,ymin=None, ymax=None,xmin=None,xmax=None): … … 372 382 self.fitter= Fit(self._fit_engine) 373 383 #Setting an id to store model and data in fit engine 384 self.fit_id= 0 374 385 if id!=None: 375 386 self.fit_id= id … … 410 421 self.fitter.select_problem_for_fit(Uid=self.fit_id,value=value.get_scheduled()) 411 422 page_fitted=current_pg 412 self.fit_id+=1423 #self.fit_id+=1 413 424 #self.schedule_for_fit( 0,value) 414 425 except: 415 raise 416 #wx.PostEvent(self.parent, StatusEvent(status="Fitting error: %s" % sys.exc_value)) 426 wx.PostEvent(self.parent, StatusEvent(status="Single Fit error: %s" % sys.exc_value)) 417 427 return 418 428 # make sure to keep an alphabetic order … … 440 450 441 451 except: 442 raise443 452 wx.PostEvent(self.parent, StatusEvent(status="Single Fit error: %s" % sys.exc_value)) 444 453 return … … 456 465 from sans.fit.Fitting import Fit 457 466 self.fitter= Fit(self._fit_engine) 458 467 self.fit_id= 0 459 468 #Setting an id to store model and data 460 469 if id!=None: … … 469 478 model= list[0] 470 479 #Create dictionary of parameters for fitting used 480 cpage= page 481 print "" 471 482 pars = [] 472 483 templist = [] … … 477 488 pars.append(name) 478 489 except: 479 wx.PostEvent(self.parent, StatusEvent(status=" Fittingerror: %s" % sys.exc_value))490 wx.PostEvent(self.parent, StatusEvent(status="Simultaneous Fit error: %s" % sys.exc_value)) 480 491 return 481 492 # need to check this print "new model " 493 """ 482 494 new_model=Model(model) 483 495 param=value.get_model_param() … … 493 505 #new_model.set( exec "%s"%(param_nam) = param_value) 494 506 new_model.parameterset[ param_name].set( param_value ) 495 496 self.fitter.set_model(new_model, self.fit_id, pars) 507 """ 508 #self.fitter.set_model(new_model, self.fit_id, pars) 509 print "sim-->model",metadata,model,self.fit_id, pars 510 self.fitter.set_model(Model(model), self.fit_id, pars) 497 511 self.fitter.set_data(metadata,self.fit_id,qmin,qmax,ymin,ymax) 498 512 print "sim---->value of problem",value.get_scheduled() 499 513 self.fitter.select_problem_for_fit(Uid=self.fit_id,value=value.get_scheduled()) 500 514 self.fit_id += 1 501 self.schedule_for_fit( 0,value)515 #self.schedule_for_fit( 0,value) 502 516 except: 503 #raise 504 wx.PostEvent(self.parent, StatusEvent(status="Fitting error: %s" % sys.exc_value)) 517 wx.PostEvent(self.parent, StatusEvent(status="Simultaneous Fit error: %s" % sys.exc_value)) 505 518 return 506 519 #Do the simultaneous fit … … 509 522 if self.calc_thread != None and self.calc_thread.isrunning(): 510 523 self.calc_thread.stop() 511 512 self.calc_thread =FitThread(parent =self.parent, 524 if self.fit_id==1: 525 self.calc_thread =FitThread(parent =self.parent, 526 fn= self.fitter, 527 qmin=qmin, 528 qmax=qmax, 529 ymin= ymin, 530 ymax= ymax, 531 cpage=cpage, 532 pars= pars, 533 completefn= self._simul_fit_completed, 534 updatefn=None) 535 536 else: 537 self.calc_thread =FitThread(parent =self.parent, 513 538 fn= self.fitter, 514 539 qmin=qmin, … … 522 547 523 548 except: 524 #raise 525 wx.PostEvent(self.parent, StatusEvent(status="Simultaneous Fitting error: %s" % sys.exc_value)) 549 wx.PostEvent(self.parent, StatusEvent(status="Simultaneous Fit error: %s" % sys.exc_value)) 526 550 return 527 551 -
sansview/perspectives/fitting/simfitpage.py
rf343069 r3215d32 65 65 page.set_model_parameter() 66 66 67 if len(self.model_toFit) ==1 :68 self.manager._on_single_fit()67 #if len(self.model_toFit) ==1 : 68 # self.manager._on_single_fit() 69 69 # print "simfitpage: when here" 70 elif len(self.model_toFit) >1 :70 if len(self.model_toFit) >= 1 : 71 71 self._onTextEnter() 72 72 self.set_model() … … 112 112 @param page_finder: the dictionary containing models information 113 113 """ 114 114 if len(self.model_list)>0: 115 for item in self.model_list: 116 #print "went here to clear" 117 item[0].SetValue(False) 118 self.manager.schedule_for_fit( value=0,fitproblem =item[1]) 115 119 self.model_list=[] 116 120 self.model_toFit=[]
Note: See TracChangeset
for help on using the changeset viewer.