Changeset d7b7156 in sasview for sansview/perspectives
- Timestamp:
- Oct 22, 2010 5:51:22 PM (14 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:
- 7406040
- Parents:
- 4628e31
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/fitpage.py
rfb59ed9 rd7b7156 440 440 441 441 ## class base method to add view 2d button 442 self._set_model_sizer(sizer=sizer, box_sizer=boxsizer1, title="Model",object=self.model_help ) 442 self._set_model_sizer(sizer=sizer, box_sizer=boxsizer1, 443 title="Model",object=self.model_help ) 443 444 444 445 def _set_sizer_dispersion(self, dispersity): … … 475 476 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 476 477 ix += 1 477 values = wx.StaticText(self, -1, 'Sigma (STD)') 478 values.SetToolTipString("Polydispersity multiplied by the value of the original parameter.") 479 self.sizer4_4.Add(values,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 478 values = wx.StaticText(self, -1, 'Sigma [A]') 479 values.SetToolTipString(\ 480 "Sigma(STD) in the A unit; the standard deviation from the mean value.") 481 482 self.sizer4_4.Add(values,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 483 0) 480 484 ix +=2 481 485 self.text_disp_1 = wx.StaticText(self, -1, '') … … 499 503 ix += 1 500 504 npts = wx.StaticText(self, -1, 'Npts') 501 npts.SetToolTipString("Number of points for weighting.") 505 npts.SetToolTipString("Number of sampling points for the numerical\n\ 506 integration over the distribution function.") 502 507 self.sizer4_4.Add(npts,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 503 508 ix += 1 504 509 nsigmas = wx.StaticText(self, -1, 'Nsigmas') 505 nsigmas.SetToolTipString("Number of sigmas between which the range of the distribution function will be used for weighting. The value '3' covers 99.5% for Gaussian distribution function.") 506 self.sizer4_4.Add(nsigmas,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 510 nsigmas.SetToolTipString(" Number of sigmas between which the range\n\ 511 of the distribution function will be used for weighting. \n\ 512 The value '3' covers 99.5% for Gaussian distribution \n\ 513 function.") 514 self.sizer4_4.Add(nsigmas,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 515 0) 507 516 508 517 if self.engine_type=="park": … … 514 523 if not self.disp_cb_dict.has_key(item): 515 524 self.disp_cb_dict[item]= None 525 name0="Distribution of " + item 516 526 name1=item+".width" 517 527 name2=item+".npts" … … 525 535 if p=="width": 526 536 ix = 0 527 cb = wx.CheckBox(self, -1, name 1, (10, 10))537 cb = wx.CheckBox(self, -1, name0, (10, 10)) 528 538 cb.SetToolTipString("Check for fitting") 529 539 wx.EVT_CHECKBOX(self, cb.GetId(), self.select_param) 530 540 self.sizer4_4.Add( cb,( iy, ix),(1,1), 531 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 541 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 542 15) 532 543 ix = 1 533 544 value= self.model.getParam(name1) 534 ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 535 style=wx.TE_PROCESS_ENTER) 536 ctl1.SetToolTipString("Polydispersity multiplied by the value of '%s'."%item) 545 ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20) 546 ,style=wx.TE_PROCESS_ENTER) 547 ctl1.SetToolTipString("Absolute Sigma: \n\ 548 1) It is the STD (ratio*mean) of '%s' distribution.\n \ 549 2) It should not exceed Mean/(2*Nsigmas)." %item) 537 550 ctl1.SetValue(str (format_number(value))) 538 551 self.sizer4_4.Add(ctl1, (iy,ix),(1,1),wx.EXPAND) … … 545 558 546 559 ix = 3 547 ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=0) 560 ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), 561 style=0) 548 562 549 self.sizer4_4.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 563 self.sizer4_4.Add(ctl2, (iy,ix),(1,1), 564 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 550 565 551 566 ctl2.Hide() 552 567 553 568 ix = 4 554 ctl3 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 555 text_enter_callback = self._onparamRangeEnter) 569 ctl3 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2, 570 20), style=wx.TE_PROCESS_ENTER, 571 text_enter_callback = self._onparamRangeEnter) 556 572 557 self.sizer4_4.Add(ctl3, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 573 self.sizer4_4.Add(ctl3, (iy,ix),(1,1), 574 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 558 575 ctl3.Hide() 559 576 560 577 ix = 5 561 ctl4 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 562 text_enter_callback = self._onparamRangeEnter) 578 ctl4 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2, 579 20), style=wx.TE_PROCESS_ENTER, 580 text_enter_callback = self._onparamRangeEnter) 563 581 564 self.sizer4_4.Add(ctl4, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 582 self.sizer4_4.Add(ctl4, (iy,ix),(1,1), 583 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 565 584 566 585 ctl4.Hide() … … 576 595 ix = 6 577 596 value= self.model.getParam(name2) 578 Tctl = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), 597 Tctl = self.ModelTextCtrl(self, -1, 598 size=(_BOX_WIDTH/2,20), 579 599 style=wx.TE_PROCESS_ENTER) 580 600 … … 587 607 ix = 7 588 608 value= self.model.getParam(name3) 589 Tct2 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), 609 Tct2 = self.ModelTextCtrl(self, -1, 610 size=(_BOX_WIDTH/2,20), 590 611 style=wx.TE_PROCESS_ENTER) 591 612 … … 598 619 599 620 self.fixed_param.append([None,name3, Tct2 600 ,None,None,None, None,None]) 621 ,None,None,None, 622 None,None]) 601 623 602 624 ix =0 603 625 iy +=1 604 self.sizer4_4.Add((20,20),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 626 self.sizer4_4.Add((20,20),(iy,ix),(1,1), 627 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 628 first_orient = True 605 629 for item in self.model.dispersion.keys(): 606 630 if item in self.model.orientation_params: 607 631 if not self.disp_cb_dict.has_key(item): 608 632 self.disp_cb_dict[item]= None 633 name0="Distribution of " + item 609 634 name1=item+".width" 610 635 name2=item+".npts" 611 636 name3=item+".nsigmas" 637 612 638 if not self.model.details.has_key(name1): 613 639 self.model.details [name1] = ["",None,None] … … 619 645 if p=="width": 620 646 ix = 0 621 cb = wx.CheckBox(self, -1, name 1, (10, 10))647 cb = wx.CheckBox(self, -1, name0, (10, 10)) 622 648 cb.SetToolTipString("Check for fitting") 623 649 wx.EVT_CHECKBOX(self, cb.GetId(), self.select_param) 624 650 self.sizer4_4.Add( cb,( iy, ix),(1,1), 625 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 651 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 652 15) 626 653 if self.data.__class__.__name__ =="Data2D": 627 654 cb.Show(True) … … 630 657 ix = 1 631 658 value= self.model.getParam(name1) 632 ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 633 style=wx.TE_PROCESS_ENTER) 634 ctl1.SetToolTipString("Polydispersity multiplied by the value of '%s'."%item) 659 ctl1 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 660 20),style=wx.TE_PROCESS_ENTER) 661 ctl1.SetToolTipString("Absolute Sigma: \n\ 662 1) It is the STD (ratio*mean) of '%s' distribution."% \ 663 item) 635 664 ctl1.SetValue(str (format_number(value))) 636 665 if self.data.__class__.__name__ =="Data2D": 666 if first_orient: 667 values.SetLabel('Sigma [A (or deg)]') 668 values.SetToolTipString(\ 669 "Sigma(STD) in the A or deg(for angles) unit;\n\ 670 the standard deviation from the mean value.") 671 first_orient = False 637 672 ctl1.Show(True) 638 673 elif ctl1.IsShown(): 639 674 ctl1.Hide() 675 640 676 self.sizer4_4.Add(ctl1, (iy,ix),(1,1),wx.EXPAND) 641 677 ## text to show error sign … … 647 683 648 684 ix = 3 649 ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=0) 685 ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), 686 style=0) 650 687 651 self.sizer4_4.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 688 self.sizer4_4.Add(ctl2, (iy,ix),(1,1), 689 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 652 690 ctl2.Hide() 653 691 654 692 ix = 4 655 ctl3 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 656 text_enter_callback = self._onparamRangeEnter) 657 658 self.sizer4_4.Add(ctl3, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 693 ctl3 = self.ModelTextCtrl(self, -1, 694 size=(_BOX_WIDTH/2,20), 695 style=wx.TE_PROCESS_ENTER, 696 text_enter_callback = self._onparamRangeEnter) 697 698 self.sizer4_4.Add(ctl3, (iy,ix),(1,1), 699 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 659 700 660 701 ctl3.Hide() 661 702 662 703 ix = 5 663 ctl4 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 664 text_enter_callback = self._onparamRangeEnter) 665 self.sizer4_4.Add(ctl4, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 704 ctl4 = self.ModelTextCtrl(self, -1, 705 size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 706 text_enter_callback = self._onparamRangeEnter) 707 self.sizer4_4.Add(ctl4, (iy,ix),(1,1), 708 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 666 709 ctl4.Hide() 667 710 #if self.data.__class__.__name__ =="Data2D": … … 670 713 #ctl4.Hide() 671 714 672 if self.engine_type=="park" and self.data.__class__.__name__ =="Data2D": 715 if self.engine_type=="park" and \ 716 self.data.__class__.__name__ =="Data2D": 673 717 ctl3.Show(True) 674 718 ctl4.Show(True) … … 679 723 self.fittable_param.append([cb,name1,ctl1,text2, 680 724 ctl2, ctl3, ctl4,None]) 681 self.orientation_params_disp.append([cb,name1,ctl1, text2,682 725 self.orientation_params_disp.append([cb,name1,ctl1, 726 text2, ctl2, ctl3, ctl4,None]) 683 727 elif p=="npts": 684 728 ix = 6 685 729 value= self.model.getParam(name2) 686 Tctl = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), 730 Tctl = self.ModelTextCtrl(self, -1, 731 size=(_BOX_WIDTH/2,20), 687 732 style=wx.TE_PROCESS_ENTER) 688 733 … … 696 741 self.fixed_param.append([None,name2, Tctl,None,None, 697 742 None, None,None]) 698 self.orientation_params_disp.append([None,name2, Tctl,None,None, 743 self.orientation_params_disp.append([None,name2, 744 Tctl,None,None, 699 745 None, None,None]) 700 746 elif p=="nsigmas": 701 747 ix = 7 702 748 value= self.model.getParam(name3) 703 Tct2 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), 749 Tct2 = self.ModelTextCtrl(self, -1, 750 size=(_BOX_WIDTH/2,20), 704 751 style=wx.TE_PROCESS_ENTER) 705 752 … … 714 761 715 762 self.fixed_param.append([None,name3, Tct2 716 763 ,None,None, None, None,None]) 717 764 718 self.orientation_params_disp.append([None,name3, Tct2719 720 765 self.orientation_params_disp.append([None,name3, 766 Tct2 ,None,None, None, None,None]) 767 721 768 self.state.disp_cb_dict = copy.deepcopy(self.disp_cb_dict) 722 769 … … 727 774 self._copy_parameters_state(self.orientation_params_disp, 728 775 self.state.orientation_params_disp) 729 self._copy_parameters_state(self.fittable_param, self.state.fittable_param) 776 self._copy_parameters_state(self.fittable_param, 777 self.state.fittable_param) 730 778 self._copy_parameters_state(self.fixed_param, self.state.fixed_param) 731 779 … … 769 817 #self._clear_Err_on_Fit() 770 818 771 # Remove or do not allow fitting on the Q=0 point, especially when y(q=0)=None at x[0]. 819 # Remove or do not allow fitting on the Q=0 point, especially 820 # when y(q=0)=None at x[0]. 772 821 self.qmin_x = float(self.qmin.GetValue()) 773 822 self.qmax_x = float( self.qmax.GetValue()) 774 823 self.manager._reset_schedule_problem( value=0) 775 824 self.manager.schedule_for_fit( value=1,page=self,fitproblem =None) 776 self.manager.set_fit_range(page= self,qmin= self.qmin_x, qmax= self.qmax_x) 825 self.manager.set_fit_range(page= self,qmin= self.qmin_x, 826 qmax= self.qmax_x) 777 827 778 828 #single fit … … 782 832 # self.btFit.SetLabel("Stop") 783 833 # self.btFit.Unbind(event=wx.EVT_BUTTON, id= self.btFit.GetId()) 784 # self.btFit.Bind(event= wx.EVT_BUTTON, handler=self._StopFit, id=self.btFit.GetId()) 834 # self.btFit.Bind(event= wx.EVT_BUTTON, 835 # handler=self._StopFit, id=self.btFit.GetId()) 785 836 #else: 786 837 # self.btFit.SetLabel("Fit") 787 # self.btFit.Bind(event= wx.EVT_BUTTON, handler=self._onFit, id=self.btFit.GetId()) 838 # self.btFit.Bind(event= wx.EVT_BUTTON, 839 # handler=self._onFit, id=self.btFit.GetId()) 788 840 789 841 def _StopFit(self, event): … … 795 847 self.manager.stop_fit() 796 848 self.btFit.Unbind(event=wx.EVT_BUTTON, id=self.btFit.GetId()) 797 self.btFit.Bind(event=wx.EVT_BUTTON, handler=self._onFit,id=self.btFit.GetId()) 849 self.btFit.Bind(event=wx.EVT_BUTTON, handler=self._onFit, 850 id=self.btFit.GetId()) 798 851 799 852 … … 831 884 ## event to post model to fit to fitting plugins 832 885 (ModelEventbox, EVT_MODEL_BOX) = wx.lib.newevent.NewEvent() 833 if self.data is not None and self.data.__class__.__name__ !="Data2D": 834 ## set smearing value whether or not the data contain the smearing info 886 if self.data is not None and \ 887 self.data.__class__.__name__ !="Data2D": 888 ## set smearing value whether or not 889 # the data contain the smearing info 835 890 evt = ModelEventbox(model=self.model, 836 891 smearer=temp_smear, … … 881 936 if not self.disable_smearer.GetValue(): 882 937 temp_smearer= self.current_smearer 883 ## set smearing value whether or not the data contain the smearing info 938 ## set smearing value whether or not 939 # the data contain the smearing info 884 940 if self.slit_smearer.GetValue(): 885 941 flag1 = self.update_slit_smear() … … 889 945 flag = flag or flag1 890 946 elif self.data.__class__.__name__ !="Data2D": 891 self.manager.set_smearer(smearer=temp_smearer, qmin= float(self.qmin_x), 892 qmax= float(self.qmax_x)) 947 self.manager.set_smearer(smearer=temp_smearer, 948 qmin= float(self.qmin_x), 949 qmax= float(self.qmax_x)) 893 950 if flag: 894 951 #self.compute_chisqr(smearer= temp_smearer) … … 901 958 self.state_change= False 902 959 else: 903 return # invalid fit range: do nothing here: msg already displayed in validate 960 # invalid fit range: do nothing here: 961 # msg already displayed in validate 962 return 904 963 else: 905 964 self.save_current_state() … … 983 1042 if self.data.__class__.__name__ =="Data2D": 984 1043 # set mask 985 radius= numpy.sqrt( self.data.qx_data*self.data.qx_data + self.data.qy_data*self.data.qy_data ) 1044 radius= numpy.sqrt( self.data.qx_data*self.data.qx_data + 1045 self.data.qy_data*self.data.qy_data ) 986 1046 index_data = ((self.qmin <= radius)&(radius<= self.qmax)) 987 1047 index_data = (index_data)&(self.data.mask) 988 1048 index_data = (index_data)&(numpy.isfinite(self.data.data)) 989 1049 if len(index_data[index_data]) < 10: 990 msg= "Cannot Plot :No or too little npts in that data range!!! " 1050 msg= "Cannot Plot :No or too little npts in \ 1051 that data range!!! " 991 1052 wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) 992 1053 return … … 995 1056 self.Npts_fit.Setvalue(str(len(self.data.mask))) 996 1057 else: 997 index_data = ((self.qmin <= self.data.x)&(self.data.x <= self.qmax)) 1058 index_data = ((self.qmin <= self.data.x)& \ 1059 (self.data.x <= self.qmax)) 998 1060 self.Npts_fit.SetValue(str(len(self.data.x[index_data]))) 999 1061 … … 1068 1130 1069 1131 :return: self.smear_type, self.dq_l and self.dq_r, 1070 respectively the type of the smear, dq_min and dq_max for pinhole smear data 1132 respectively the type of the smear, dq_min and 1133 dq_max for pinhole smear data 1071 1134 while dxl and dxw for slit smear 1072 1135 … … 1083 1146 if data.dqx_data == None or data.dqy_data ==None: 1084 1147 return 1085 elif self.smearer != None and (data.dqx_data.any()!=0) and (data.dqx_data.any()!=0): 1148 elif self.smearer != None and (data.dqx_data.any()!=0) and \ 1149 (data.dqx_data.any()!=0): 1086 1150 self.smear_type = "Pinhole2d" 1087 1151 self.dq_l = format_number(numpy.average(data.dqx_data)) … … 1225 1289 self.onSmear(event=None) 1226 1290 if self.current_smearer != None: 1227 self.current_smearer.set_accuracy(accuracy = self.smear2d_accuracy) 1291 self.current_smearer.set_accuracy(accuracy = 1292 self.smear2d_accuracy) 1228 1293 event.Skip() 1229 1294 … … 1241 1306 self.model.setParam(name,fun_val) 1242 1307 # save state 1243 self._copy_parameters_state(self.str_parameters, self.state.str_parameters) 1308 self._copy_parameters_state(self.str_parameters, 1309 self.state.str_parameters) 1244 1310 # update params 1245 1311 self._update_paramv_on_fit() … … 1255 1321 """ 1256 1322 1257 from sans.guiframe.local_perspectives.plotting.masking import MaskPanel as MaskDialog 1323 from sans.guiframe.local_perspectives.plotting.masking \ 1324 import MaskPanel as MaskDialog 1258 1325 1259 1326 self.panel = MaskDialog(self, data=self.data,id =-1 ) … … 1383 1450 qmin,qmax = self.get_range() 1384 1451 if self.data.__class__.__name__ =="Data2D": 1385 radius= numpy.sqrt( self.data.qx_data*self.data.qx_data + self.data.qy_data*self.data.qy_data ) 1452 radius= numpy.sqrt( self.data.qx_data*self.data.qx_data + 1453 self.data.qy_data*self.data.qy_data ) 1386 1454 index_data = (self.qmin_x <= radius)&(radius<= self.qmax_x) 1387 1455 index_data= (index_data)&(self.data.mask) … … 1478 1546 if dispersity !=None: 1479 1547 name= dispersity.__name__ 1480 if name == "GaussianDispersion" and self.enable_disp.GetValue(): 1548 if name == "GaussianDispersion" and \ 1549 self.enable_disp.GetValue(): 1481 1550 if hasattr(self,"text_disp_1" ): 1482 1551 if self.text_disp_1 !=None: … … 1516 1585 if dispersity !=None: 1517 1586 name= dispersity.__name__ 1518 if name == "GaussianDispersion" and self.enable_disp.GetValue(): 1587 if name == "GaussianDispersion" and \ 1588 self.enable_disp.GetValue(): 1519 1589 if hasattr(self,"text_disp_1" ): 1520 1590 if self.text_disp_1!=None: … … 1683 1753 else: 1684 1754 step = (self.dx_max - self.dx_min)/(len_data-1) 1685 data.dx = numpy.arange(self.dx_min,self.dx_max+step/1.1,step) 1755 data.dx = numpy.arange(self.dx_min,self.dx_max+step/1.1, 1756 step) 1686 1757 elif self.dx_min != None: 1687 1758 if self._is_2D(): data.dqx_data[data.dqx_data==0] = self.dx_min … … 1693 1764 # 2D need to set accuracy 1694 1765 if self._is_2D(): 1695 self.current_smearer.set_accuracy(accuracy = self.smear2d_accuracy) 1766 self.current_smearer.set_accuracy(accuracy = \ 1767 self.smear2d_accuracy) 1696 1768 1697 1769 if msg != None: … … 1701 1773 get_pin_max.SetBackgroundColour("white") 1702 1774 ## set smearing value whether or not the data contain the smearing info 1703 self.manager.set_smearer(smearer=self.current_smearer, qmin= float(self.qmin_x),qmax= float(self.qmax_x)) 1775 self.manager.set_smearer(smearer=self.current_smearer, qmin= \ 1776 float(self.qmin_x),qmax= float(self.qmax_x)) 1704 1777 return msg 1705 1778 … … 1794 1867 height = self.smear_slit_height.GetValue() 1795 1868 1796 # check and change the box bg color if it was pink but it should be white now 1869 # check and change the box bg color if it was pink 1870 # but it should be white now 1797 1871 # because this is the case that _set_slit_smear() will not handle 1798 1872 if height.lstrip().rstrip()=="": … … 1869 1943 #temp_smearer = self.current_smearer 1870 1944 ## set smearing value whether or not the data contain the smearing info 1871 self.manager.set_smearer(smearer=self.current_smearer, qmin= float(self.qmin_x), qmax= float(self.qmax_x)) 1945 self.manager.set_smearer(smearer=self.current_smearer, qmin= \ 1946 float(self.qmin_x), qmax= float(self.qmax_x)) 1872 1947 return msg 1873 1948 … … 2045 2120 self.param_toFit.remove(item) 2046 2121 2047 #Select parameters to fit for list of fittable parameters with dispersion 2122 #Select parameters to fit for list of fittable parameters 2123 # with dispersion 2048 2124 for item in self.fittable_param: 2049 2125 #Skip t ifhe angle parameters if 1D data … … 2068 2144 len_orient_para *= 2 2069 2145 #Set the value of checkbox that selected every checkbox or not 2070 if len(self.parameters)+len(self.fittable_param)-len_orient_para ==len(self.param_toFit): 2146 if len(self.parameters)+len(self.fittable_param)-len_orient_para ==\ 2147 len(self.param_toFit): 2071 2148 self.cb1.SetValue(True) 2072 2149 else: … … 2199 2276 2200 2277 for item in keys: 2201 if not item in self.disp_list and not item in self.model.orientation_params: 2278 if not item in self.disp_list and not item in \ 2279 self.model.orientation_params: 2202 2280 2203 2281 ##prepare a spot to store errors … … 2207 2285 iy += 1 2208 2286 ix = 0 2209 if self.model.__class__ in self.model_list_box["Multi-Functions"] \ 2287 if self.model.__class__ in \ 2288 self.model_list_box["Multi-Functions"] \ 2210 2289 and item in self.model.non_fittable: 2211 2290 non_fittable_name = wx.StaticText(self, -1, item ) … … 2217 2296 if len(self.model.fun_list) > 0: 2218 2297 num = item.split('_')[1][5:7] 2219 fun_box = wx.ComboBox(self, -1,size=(100,-1),style=wx.CB_READONLY, name = '%s'% item) 2298 fun_box = wx.ComboBox(self, -1,size=(100,-1), 2299 style=wx.CB_READONLY, name = '%s'% item) 2220 2300 self._set_fun_box_list(fun_box) 2221 2301 fun_box.SetSelection(0) 2222 #self.fun_box.SetToolTipString("A function describing the interface") 2302 #self.fun_box.SetToolTipString("A function 2303 # describing the interface") 2223 2304 wx.EVT_COMBOBOX(fun_box,-1, self._on_fun_box) 2224 2305 else: 2225 fun_box = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH,20), 2226 style=wx.TE_PROCESS_ENTER, name ='%s'% item) 2306 fun_box = self.ModelTextCtrl(self, -1, 2307 size=(_BOX_WIDTH,20), 2308 style=wx.TE_PROCESS_ENTER, name ='%s'% item) 2227 2309 fun_box.SetToolTipString("Hit 'Enter' after typing.") 2228 2310 fun_box.SetValue(format_number(value)) 2229 2311 sizer.Add(fun_box, (iy,ix),(1,1), wx.EXPAND) 2230 self.str_parameters.append([None,item, fun_box,None,None,None,None,None]) 2312 self.str_parameters.append([None,item, fun_box, 2313 None,None,None,None,None]) 2231 2314 2232 2315 … … 2257 2340 ix += 1 2258 2341 ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=0) 2259 sizer.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2342 sizer.Add(ctl2, (iy,ix),(1,1), 2343 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2260 2344 ctl2.Hide() 2261 2345 2262 2346 ix += 1 2263 ctl3 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 2264 text_enter_callback = self._onparamRangeEnter) 2347 ctl3 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), 2348 style=wx.TE_PROCESS_ENTER, 2349 text_enter_callback = self._onparamRangeEnter) 2265 2350 2266 sizer.Add(ctl3, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2351 sizer.Add(ctl3, (iy,ix),(1,1), 2352 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2267 2353 ctl3.Hide() 2268 2354 2269 2355 ix += 1 2270 ctl4 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 2271 text_enter_callback = self._onparamRangeEnter) 2272 sizer.Add(ctl4, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2356 ctl4 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), 2357 style=wx.TE_PROCESS_ENTER, 2358 text_enter_callback = self._onparamRangeEnter) 2359 sizer.Add(ctl4, (iy,ix),(1,1), 2360 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2273 2361 2274 2362 ctl4.Hide() … … 2280 2368 # Units 2281 2369 if self.model.details.has_key(item): 2282 units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT) 2370 units = wx.StaticText(self, -1, 2371 self.model.details[item][0], style=wx.ALIGN_LEFT) 2283 2372 else: 2284 2373 units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT) 2285 sizer.Add(units, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2374 sizer.Add(units, (iy,ix),(1,1), 2375 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2286 2376 2287 2377 ##[cb state, name, value, "+/-", error of fit, min, max , units] … … 2290 2380 2291 2381 iy+=1 2292 sizer.Add((10,10),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 2382 sizer.Add((10,10),(iy,ix),(1,1), 2383 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 2293 2384 2294 2385 # type can be either Guassian or Array … … 2304 2395 if item in self.model.orientation_params: 2305 2396 orient_angle = wx.StaticText(self, -1, '[For 2D only]:') 2306 sizer.Add(orient_angle,(iy, ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 2397 sizer.Add(orient_angle,(iy, ix),(1,1), 2398 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 2307 2399 if not self.data.__class__.__name__ =="Data2D": 2308 2400 orient_angle.Hide() … … 2353 2445 ix += 1 2354 2446 ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=0) 2355 sizer.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2447 sizer.Add(ctl2, (iy,ix),(1,1), 2448 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2356 2449 ctl2.Hide() 2357 2450 2358 2451 2359 2452 ix += 1 2360 ctl3 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 2361 text_enter_callback = self._onparamRangeEnter) 2453 ctl3 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), 2454 style=wx.TE_PROCESS_ENTER, 2455 text_enter_callback = self._onparamRangeEnter) 2362 2456 2363 sizer.Add(ctl3, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2457 sizer.Add(ctl3, (iy,ix),(1,1), 2458 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2364 2459 ctl3.Hide() 2365 2460 2366 2461 ix += 1 2367 ctl4 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, 2368 text_enter_callback = self._onparamRangeEnter) 2369 sizer.Add(ctl4, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2462 ctl4 = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), 2463 style=wx.TE_PROCESS_ENTER, 2464 text_enter_callback = self._onparamRangeEnter) 2465 sizer.Add(ctl4, (iy,ix),(1,1), 2466 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2370 2467 2371 2468 ctl4.Hide() 2372 2469 2373 if self.engine_type =="park" and self.data.__class__.__name__ =="Data2D": 2470 if self.engine_type =="park" and \ 2471 self.data.__class__.__name__ =="Data2D": 2374 2472 ctl3.Show(True) 2375 2473 ctl4.Show(True) … … 2378 2476 # Units 2379 2477 if self.model.details.has_key(item): 2380 units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT) 2478 units = wx.StaticText(self, -1, 2479 self.model.details[item][0], 2480 style=wx.ALIGN_LEFT) 2381 2481 else: 2382 2482 units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT) … … 2387 2487 units.Hide() 2388 2488 2389 sizer.Add(units, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2489 sizer.Add(units, (iy,ix),(1,1), 2490 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 2390 2491 2391 ##[cb state, name, value, "+/-", error of fit, min, max ,units]2492 ##[cb state, name, value, "+/-", error of fit,min,max,units] 2392 2493 self.parameters.append([cb,item, ctl1, 2393 2494 text2,ctl2, ctl3, ctl4,units])
Note: See TracChangeset
for help on using the changeset viewer.