Changeset 997131a in sasview
- Timestamp:
- Apr 16, 2009 11:20:40 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:
- 847091f
- Parents:
- d1e0473
- Location:
- sansview/perspectives/fitting
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/basepage.py
r06b59fe r997131a 43 43 ## selected parameters to apply dispersion 44 44 self.disp_cb_dict ={} 45 ## smearer object 46 self.smearer = None 45 47 ##list of model parameters. each item must have same length 46 48 ## each item related to a given parameters … … 224 226 sizer_select_dispers.Add((10,10)) 225 227 sizer_select_dispers.Add(self.model_disp) 226 sizer_select_dispers.Add(self.disp_box) 227 sizer_select_dispers.Add((10,10)) 228 sizer_select_dispers.Add(self.disp_box,0, 229 wx.TOP|wx.BOTTOM|wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE,border=5) 230 #sizer_select_dispers.Add((10,10)) 228 231 self.model_disp.Hide() 229 232 self.disp_box.Hide() 230 233 231 boxsizer1.Add( sizer_dispersion ) 232 boxsizer1.Add( (10,10) ) 234 boxsizer1.Add( sizer_dispersion,0, 235 wx.TOP|wx.BOTTOM|wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE,border=5) 236 #boxsizer1.Add( (10,10) ) 233 237 boxsizer1.Add( sizer_select_dispers ) 234 238 self.sizer4_4 = wx.GridBagSizer(5,5) -
sansview/perspectives/fitting/fitpage.py
rd1e0473 r997131a 22 22 from basepage import BasicPage 23 23 from basepage import PageInfoEvent 24 24 from DataLoader.qsmearing import smear_selection 25 25 26 26 class FitPage(BasicPage): … … 48 48 self._fill_range_sizer() 49 49 self._on_select_model(event=None) 50 50 if self.data !=None: 51 self.smearer = smear_selection( self.data ) 52 51 53 ## to update the panel according to the fit engine type selected 52 54 self.Bind(EVT_FITTER_TYPE,self._on_engine_change) … … 452 454 self.set_model_param_sizer(self.model) 453 455 try: 454 self.compute_chisqr() 456 temp_smear= None 457 if self.enable_smearer.GetValue(): 458 temp_smear= self.smearer 459 self.compute_chisqr(temp_smear) 455 460 except: 456 461 ## error occured on chisqr computation … … 603 608 are compute when fitting 604 609 """ 605 smear =None 606 msg="" 610 607 611 if self.enable_smearer.GetValue(): 608 from DataLoader.qsmearing import smear_selection609 smear = smear_selection( self.data )612 msg="" 613 temp_smearer= self.smearer 610 614 if hasattr(self.data,"dxl"): 611 615 msg= ": Resolution smearing parameters" 612 616 if hasattr(self.data,"dxw"): 613 617 msg= ": Slit smearing parameters" 614 if s mear ==None:618 if self.smearer ==None: 615 619 wx.PostEvent(self.manager.parent, StatusEvent(status=\ 616 620 "Data contains no smearing information")) … … 618 622 wx.PostEvent(self.manager.parent, StatusEvent(status=\ 619 623 "Data contains smearing information %s"%msg)) 624 else: 625 temp_smearer = None 620 626 ## set smearing value whether or not the data contain the smearing info 621 self.manager.set_smearer( smear, qmin= float(self.qmin_x),627 self.manager.set_smearer(temp_smearer, qmin= float(self.qmin_x), 622 628 qmax= float(self.qmax_x)) 623 629 ##Calculate chi2 624 self.compute_chisqr( )630 self.compute_chisqr(smearer= temp_smearer) 625 631 ## save the state enable smearing 626 632 self.save_current_state() … … 668 674 669 675 670 def compute_chisqr(self ):676 def compute_chisqr(self , smearer=None): 671 677 """ 672 678 compute chi square given a model and data 1D and set the value … … 692 698 dy= numpy.asarray(self.data.dy) 693 699 dy[dy==0]=1 700 694 701 if self.qmin_x==None and self.qmax_x==None: 695 702 fx =numpy.asarray([self.model.run(v) for v in x]) 703 if smearer!=None: 704 fx= smearer(fx) 696 705 temp=(y - fx)/dy 697 706 res= temp*temp … … 699 708 idx = (x>= self.qmin_x) & (x <=self.qmax_x) 700 709 fx = numpy.asarray([self.model.run(item)for item in x[idx ]]) 710 if smearer!=None: 711 fx= smearer(fx) 701 712 temp=(y[idx] - fx)/dy[idx] 702 713 res= temp*temp … … 708 719 self.tcChi.SetLabel(format_number(math.fabs(sum/ len(res)))) 709 720 except: 710 wx.PostEvent(self.parent.GrandParent, StatusEvent(status=\ 711 "Chisqr cannot be compute: %s"% sys.exc_value)) 712 return 721 raise 722 #wx.PostEvent(self.parent.GrandParent, StatusEvent(status=\ 723 # "Chisqr cannot be compute: %s"% sys.exc_value)) 724 #return 713 725 714 726 -
sansview/perspectives/fitting/fitting.py
rd7e391e r997131a 796 796 qmin, qmax= current_pg.get_range() 797 797 self.page_finder[current_pg].set_range(qmin=qmin, qmax=qmax) 798 798 smearer= self.page_finder[current_pg].get_smearer() 799 799 # save model name 800 self.draw_model( model=model, data= metadata, qmin=qmin, qmax=qmax) 800 self.draw_model( model=model,smearer=smearer, 801 data= metadata, qmin=qmin, qmax=qmax) 801 802 802 803 if self.sim_page!=None:
Note: See TracChangeset
for help on using the changeset viewer.