Changeset c69b6d5 in sasview for sansview/perspectives/fitting
- Timestamp:
- Nov 11, 2009 5:49:13 PM (15 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:
- 35c9d31
- Parents:
- f1aa385
- Location:
- sansview/perspectives/fitting
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/basepage.py
rf1aa385 rc69b6d5 860 860 after fitting 861 861 """ 862 862 """ 863 863 if hasattr(self,"text2_3"): 864 864 self.text2_3.Hide() … … 883 883 item[4].Hide() 884 884 ##Is this layout necessary? Had a problem w/MAC:Not anymore. 885 #self.Layout()886 885 self.Layout() 886 """ 887 887 return 888 888 def _selectDlg(self): -
sansview/perspectives/fitting/fitpage.py
rffb838f rc69b6d5 61 61 self.Bind(EVT_FITTER_TYPE,self._on_engine_change) 62 62 self.Bind(EVT_FIT_STOP,self._on_fit_complete) 63 63 64 64 def _on_fit_complete(self, event): 65 65 """ … … 376 376 ctl3 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 377 377 kill_focus_callback = self._onparamRangeEnter, 378 text_enter_callback = self._onparamRangeEnter, 379 #mouse_up_callback = self._onparamRangeEnter, 378 380 set_focus_callback = self._onparamRangeEnter) 379 381 … … 384 386 ctl4 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 385 387 kill_focus_callback = self._onparamRangeEnter, 388 text_enter_callback = self._onparamRangeEnter, 389 #mouse_up_callback = self._onparamRangeEnter, 386 390 set_focus_callback = self._onparamRangeEnter) 387 391 self.sizer4_4.Add(ctl4, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) … … 474 478 ctl3 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 475 479 kill_focus_callback = self._onparamRangeEnter, 480 text_enter_callback = self._onparamRangeEnter, 481 #mouse_up_callback = self._onparamRangeEnter, 476 482 set_focus_callback = self._onparamRangeEnter) 477 483 … … 483 489 ctl4 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 484 490 kill_focus_callback = self._onparamRangeEnter, 491 text_enter_callback = self._onparamRangeEnter, 492 #mouse_up_callback = self._onparamRangeEnter, 485 493 set_focus_callback = self._onparamRangeEnter) 486 494 self.sizer4_4.Add(ctl4, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) … … 587 595 588 596 #Clear errors if exist from previous fitting 589 self._clear_Err_on_Fit() 597 self._clear_Err_on_Fit() 590 598 591 599 # Remove or do not allow fitting on the Q=0 point, especially when y(q=0)=None at x[0]. … … 699 707 Check validity of value enter in the parameters range field 700 708 """ 709 is_modified = False 701 710 tcrtl= event.GetEventObject() 702 711 if tcrtl.GetValue().lstrip().rstrip()!="": … … 706 715 except: 707 716 tcrtl.SetBackgroundColour("pink") 708 tcrtl.Refresh()709 717 return 710 718 else: 711 719 tcrtl.SetBackgroundColour(wx.WHITE) 720 self.save_current_state() 721 #is_modified = True 712 722 713 is_modified = False 714 if self.model !=None: 715 # Flag to register when a parameter has changed. 716 is_modified =self._check_value_enter( self.fittable_param ,is_modified) 717 is_modified =self._check_value_enter( self.fixed_param ,is_modified) 718 is_modified =self._check_value_enter( self.parameters ,is_modified) 719 720 #self._onparamEnter_helper() 721 tcrtl.Refresh() 723 if not is_modified: 724 self._onparamEnter_helper() 722 725 ## new state posted 723 if is_modified:726 if self.state_change: 724 727 #self._undo.Enable(True) 725 728 self.save_current_state() 726 #self._undo.Enable(True)727 729 event = PageInfoEvent(page = self) 728 730 wx.PostEvent(self.parent, event) 729 731 self.state_change= False 730 732 self.Layout() 733 self.Refresh() 734 731 735 732 736 … … 766 770 """ 767 771 return float(self.qmin_x) , float(self.qmax_x) 772 773 def get_chi2(self): 774 """ 775 return the current chi2 776 """ 777 return self.tcChi.GetLabel() 768 778 769 779 def get_param_list(self): … … 788 798 789 799 """ 790 self.tcChi.SetLabel(format_number(chisqr)) 800 #format chi2 801 chi2 = format_number(chisqr) 802 803 self.tcChi.SetLabel(chi2) 791 804 params = {} 792 805 is_modified = False … … 804 817 #set the panel when fit result are float not list 805 818 if out.__class__== numpy.float64: 819 #print "float64" 806 820 self.param_toFit[0][2].SetValue(format_number(out)) 807 821 self.param_toFit[0][2].Refresh() 808 822 809 self.param_toFit[0][4].Clear()810 self.param_toFit[0][4].Hide()823 if self.param_toFit[0][4].IsShown: 824 self.param_toFit[0][4].Hide() 811 825 if cov !=None : 812 826 self.text2_3.Show(True) … … 821 835 822 836 if cov[0]==None or not numpy.isfinite(cov[0]): 823 self.param_toFit[0][3].Hide() 824 self.param_toFit[0][4].Clear() 825 #self.param_toFit[0][4].Hide() 826 self.param_toFit[0][4].Refresh() 837 if self.param_toFit[0][3].IsShown: 838 self.param_toFit[0][3].Hide() 827 839 else: 840 828 841 self.param_toFit[0][3].Show(True) 829 self.param_toFit[0][4].Clear() 842 self.param_toFit[0][3].Refresh() 843 self.param_toFit[0][4].Show(True) 830 844 self.param_toFit[0][4].SetValue(format_number(cov[0])) 831 self.param_toFit[0][4].Show(True)832 845 self.param_toFit[0][4].Refresh() 833 846 has_error = True 834 847 else: 835 848 836 849 if self.text2_3.IsShown(): 837 850 self.text2_3.Hide() 838 851 i = 0 839 852 #Set the panel when fit result are list 840 853 for item in self.param_toFit: … … 845 858 item[4].Hide() 846 859 847 if( out != None ) and len(out)<=len(self.param_toFit) :#and i < len(out):860 if( out != None ) and len(out)<=len(self.param_toFit) and i < len(out): 848 861 item[2].SetValue(format_number(self.model.getParam(item[1]))) 849 862 item[2].Refresh() … … 854 867 break 855 868 856 if(cov !=None) and len(cov)<=len(self.param_toFit) :#and i < len(cov):869 if(cov !=None) and len(cov)<=len(self.param_toFit) and i < len(cov): 857 870 try: 858 871 name= dispersity.__name__ … … 877 890 item[4].Refresh() 878 891 has_error = True 879 892 i += 1 880 893 #Show error title when any errors displayed 881 894 if has_error: … … 889 902 self.Layout() 890 903 self.Refresh() 891 904 892 905 def onSmear(self, event): 893 906 """ … … 1220 1233 ctl3 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 1221 1234 kill_focus_callback = self._onparamRangeEnter, 1235 text_enter_callback = self._onparamRangeEnter, 1236 #mouse_up_callback = self._onparamRangeEnter, 1222 1237 set_focus_callback = self._onparamRangeEnter) 1223 1238 … … 1228 1243 ctl4 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 1229 1244 kill_focus_callback = self._onparamRangeEnter, 1245 text_enter_callback = self._onparamRangeEnter, 1246 #mouse_up_callback = self._onparamRangeEnter, 1230 1247 set_focus_callback = self._onparamRangeEnter) 1231 1248 sizer.Add(ctl4, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) … … 1313 1330 1314 1331 1315 #param_min, param_max= self.model.details[item][1:]1316 1332 ix += 1 1317 1333 ctl3 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 1318 1334 kill_focus_callback = self._onparamRangeEnter, 1335 text_enter_callback = self._onparamRangeEnter, 1336 #mouse_up_callback = self._onparamRangeEnter, 1319 1337 set_focus_callback = self._onparamRangeEnter) 1320 1338 … … 1330 1348 ctl4 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 1331 1349 kill_focus_callback = self._onparamRangeEnter, 1350 text_enter_callback = self._onparamRangeEnter, 1351 #mouse_up_callback = self._onparamRangeEnter, 1332 1352 set_focus_callback = self._onparamRangeEnter) 1333 1353 sizer.Add(ctl4, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) -
sansview/perspectives/fitting/fitting.py
r6d91073 rc69b6d5 20 20 from sans.guiframe.dataFitting import Theory1D 21 21 from sans.guiframe import dataFitting 22 from sans.guiframe.utils import format_number 22 23 23 24 from sans.guicomm.events import NewPlotEvent, StatusEvent … … 751 752 wx.PostEvent(self.parent, StatusEvent(status=msg,type="stop")) 752 753 return 753 if n umpy.any(result.pvec ==None )or not numpy.all(numpy.isfinite(result.pvec) ):754 if not numpy.isfinite(result.fitness) or numpy.any(result.pvec ==None )or not numpy.all(numpy.isfinite(result.pvec) ): 754 755 msg= "Single Fitting did not converge!!!" 755 756 wx.PostEvent(self.parent, StatusEvent(status=msg,type="stop")) … … 798 799 ## fit more than 1 model at the same time 799 800 try: 801 msg = "" 800 802 if result ==None: 801 803 msg= "Complex Fitting Stop !!!" 802 804 wx.PostEvent(self.parent, StatusEvent(status=msg,type="stop")) 803 805 return 804 if n umpy.any(result.pvec ==None )or not numpy.all(numpy.isfinite(result.pvec) ):806 if not numpy.isfinite(result.fitness) or numpy.any(result.pvec ==None )or not numpy.all(numpy.isfinite(result.pvec) ): 805 807 msg= "Single Fitting did not converge!!!" 806 808 wx.PostEvent(self.parent, StatusEvent(status=msg,type="stop")) 807 809 return 810 808 811 for page, value in self.page_finder.iteritems(): 812 if format_number(result.fitness) == page.get_chi2(): 813 #ToDo: Compare parameter inputs with outputs too. 814 msg= "Simultaneous Fit completed" 815 msg +=" but chi2 has not been improved..." 816 wx.PostEvent(self.parent, StatusEvent(status="%s " % msg)) 817 break 809 818 if value.get_scheduled()==1: 810 819 model = value.get_model() … … 838 847 self.draw_model( model=model, data= metadata, smearer=smearer, 839 848 qmin= qmin, qmax= qmax) 840 wx.PostEvent(self.parent, StatusEvent(status= "", type="stop"))849 wx.PostEvent(self.parent, StatusEvent(status=msg, type="stop")) 841 850 except: 842 851 msg= "Simultaneous Fit completed"
Note: See TracChangeset
for help on using the changeset viewer.