Changeset b421b1a in sasview for sansview/perspectives/fitting
- Timestamp:
- Nov 8, 2009 1:09:25 AM (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:
- eacf1d66
- Parents:
- f9de20e
- Location:
- sansview/perspectives/fitting
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/basepage.py
rf9de20e rb421b1a 19 19 #Control panel width 20 20 if sys.platform.count("win32")>0: 21 PANEL_WIDTH = 4 4021 PANEL_WIDTH = 450 22 22 else: 23 23 PANEL_WIDTH = 500 … … 55 55 ## selected parameters to apply dispersion 56 56 self.disp_cb_dict ={} 57 57 58 ## smearer object 58 59 self.smearer = None … … 497 498 498 499 self.state.engine_type = self.engine_type 499 500 500 501 new_state = self.state.clone() 501 502 new_state.model.name = self.state.model.name … … 670 671 if hasattr(self,"cb1"): 671 672 self.state.cb1= self.cb1.GetValue() 673 672 674 except: 673 675 pass … … 704 706 self.state.values = copy.deepcopy(self.values) 705 707 self.state.weights = copy.deepcopy(self.weights) 708 706 709 ## save plotting range 707 710 self._save_plotting_range() … … 719 722 self._copy_parameters_state(self.orientation_params_disp, 720 723 self.state.orientation_params_disp) 721 722 724 self._copy_parameters_state(self.parameters, self.state.parameters) 723 725 self._copy_parameters_state(self.fittable_param, self.state.fittable_param) … … 743 745 self.enable2D= state.enable2D 744 746 self.engine_type = state.engine_type 747 745 748 #??? 746 749 self.disp_cb_dict = state.disp_cb_dict 747 self.disp_list =state.disp_list 748 749 750 self.disp_list = state.disp_list 751 750 752 ## set the state of the radio box 751 753 self.shape_rbutton.SetValue(state.shape_rbutton ) … … 817 819 818 820 else: 819 821 820 822 for k,v in self.state.disp_cb_dict.iteritems(): 821 823 self.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) … … 1016 1018 item_page_info = statelist[j] 1017 1019 ##change the state of the check box for simple parameters 1018 if item_page[0]!=None: 1019 1020 if item_page[0]!=None: 1020 1021 item_page[0].SetValue(item_page_info[0]) 1021 #print "item_page[0]",item_page[0].GetValue()1022 1022 1023 if item_page[2]!=None: 1023 1024 item_page[2].SetValue(item_page_info[2]) … … 1040 1041 if item_page_info[5][0]: 1041 1042 item_page[5].Show(True) 1042 item_page[5].SetValue(item_page_info[ 4][1])1043 item_page[5].SetValue(item_page_info[5][1]) 1043 1044 else: 1044 1045 item_page[5].Hide() … … 1404 1405 self._disp_obj_dict = {} 1405 1406 self.disp_cb_dict ={} 1407 1406 1408 f_id = self.formfactorbox.GetCurrentSelection() 1407 1409 #For MAC … … 1439 1441 self.state.parameters =[] 1440 1442 self.state.model =self.model 1441 1442 1443 self.disp_list =self.model.getDispParamList() 1443 1444 self.state.disp_list = self.disp_list 1444 1445 self.sizer4_4.Layout() 1445 self.sizer4.Layout()1446 1446 self.Layout() 1447 1447 self.SetScrollbars(20,20,25,65) … … 1493 1493 param_min= None 1494 1494 param_max= None 1495 1495 1496 if item[5]!= None: 1496 1497 if item[5].GetValue().lstrip().rstrip()!="": … … 1508 1509 wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) 1509 1510 if name in self.model.details.keys(): 1510 self.model.details[name][1: 3]= param_min,param_max1511 self.model.details[name][1:]= param_min,param_max 1511 1512 1512 1513 ## hide statictext +/- … … 1519 1520 1520 1521 value= float(item[2].GetValue()) 1522 #print "val", value,self.model.getParam(name) 1521 1523 # If the value of the parameter has changed, 1522 1524 # +update the model and set the is_modified flag … … 1549 1551 1550 1552 return 1551 #remove previous added details for dispersion parameters. 1552 #for item in self.model.dispersion.keys():#for item in self.model.details.keys(): 1553 # if item in self.model.fixed and item in self.model.details.keys(): 1554 # del self.model.details [item] 1555 1553 1556 1554 if self.enable_disp.GetValue(): 1557 1555 self.model_disp.Show(True) … … 1662 1660 self.disp_list should change type later .now only gaussian 1663 1661 """ 1664 1665 1662 n = self.disp_box.GetCurrentSelection() 1666 1663 name = self.disp_box.GetValue() -
sansview/perspectives/fitting/fitpage.py
rf9de20e rb421b1a 44 44 ## default fitengine type 45 45 self.engine_type = None 46 46 47 ## draw sizer 47 48 self._fill_datainfo_sizer() … … 137 138 item[6].Show(True) 138 139 self.Layout() 139 #self.SetScrollbars(20,20,25,65)140 self.SetScrollbars(20,20,25,65) 140 141 141 142 … … 283 284 ## the user didn't select dispersity display 284 285 return 285 286 286 287 self._reset_dispersity() 288 287 289 # Create the dispersion objects 288 290 for item in self.model.dispersion.keys(): … … 292 294 self.model.set_dispersion(item, disp_model) 293 295 self.state._disp_obj_dict[item]= disp_model 296 294 297 295 298 ix=0 … … 320 323 321 324 322 323 324 325 326 325 ix += 1 327 326 npts = wx.StaticText(self, -1, 'Npts') … … 337 336 for item in self.model.dispersion.keys(): 338 337 if not item in self.model.orientation_params: 339 self.disp_cb_dict[item]= None 338 #if not self.disp_cb_dict.has_key(item): 339 # self.disp_cb_dict[item]= None 340 340 name1=item+".width" 341 341 name2=item+".npts" 342 342 name3=item+".nsigmas" 343 343 if not self.model.details.has_key(name1): 344 self.model.details [name1] = ["",None, None, None]344 self.model.details [name1] = ["",None,None] 345 345 346 346 iy += 1 … … 365 365 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 366 366 text2.Hide() 367 ## txtcrtl to add error from fit 368 fit_errs = self.model.details[item][3] 369 367 370 368 ix = 3 371 369 ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER) 372 ctl2.SetValue(str(format_number(fit_errs)))370 #ctl2.SetValue(str(format_number(fit_errs))) 373 371 self.sizer4_4.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 374 if fit_errs==None or not numpy.isfinite(fit_errs):375 376 else:377 if not text2.IsShown():378 text2.Show(True)379 ctl2.Show(True)380 #Prepare add min and max in model.details. (Maybe Not correct way)381 param_min, param_max= self.model.details[name1][1: 3]372 #if fit_errs==None or not numpy.isfinite(fit_errs): 373 ctl2.Hide() 374 #else: 375 # if not text2.IsShown(): 376 # text2.Show(True) 377 # ctl2.Show(True) 378 #Prepare add min and max in model.details. 379 param_min, param_max= self.model.details[name1][1:] 382 380 ix = 4 383 381 ctl3 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, … … 440 438 for item in self.model.dispersion.keys(): 441 439 if item in self.model.orientation_params: 442 self.disp_cb_dict[item]= None440 443 441 name1=item+".width" 444 442 name2=item+".npts" 445 443 name3=item+".nsigmas" 446 444 if not self.model.details.has_key(name1): 447 self.model.details [name1] = ["",None, None, None] 445 self.model.details [name1] = ["",None,None] 446 447 448 448 iy += 1 449 449 for p in self.model.dispersion[item].keys(): … … 475 475 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 476 476 text2.Hide() 477 ## txtcrtl to add error from fit 478 fit_errs = self.model.details[item][3] 477 479 478 ix = 3 480 479 ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER) 481 ctl2.SetValue(str(format_number(fit_errs)))480 482 481 self.sizer4_4.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 483 if fit_errs==None or not numpy.isfinite(fit_errs) or self.data.__class__.__name__ !="Data2D": 484 ctl2.Hide() 485 else: 486 if not text2.IsShown(): 487 text2.Show(True) 488 ctl2.Show(True) 489 #if self.data.__class__.__name__ =="Data2D": 490 #ctl2.Show(True) 491 #elif ctl2.IsShown(): 492 #ctl2.Hide() 482 ctl2.Hide() 493 483 494 param_min, param_max= self.model.details[name1][1: 3]484 param_min, param_max= self.model.details[name1][1:] 495 485 ix = 4 496 486 ctl3 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, … … 571 561 ,None,None, None, None,None]) 572 562 #Display units text on panel 573 for item in self.model.dispersion.keys(): 574 if self.model.details[item][3]!= None and numpy.isfinite(self.model.details[item][3]): 575 if not self.text2_3.IsShown(): 576 self.text2_3.Show() 577 break 578 else: 579 self.text2_3.Hide() 563 for item in self.model.dispersion.keys(): 564 name = item +".width" 580 565 581 self.state.disp_cb_dict = copy.deepcopy(self.disp_cb_dict) 566 self.state.disp_cb_dict = copy.deepcopy(self.disp_cb_dict) 567 582 568 self.state.model = self.model.clone() 583 569 ## save state into … … 664 650 self._on_select_model_helper() 665 651 self.set_model_param_sizer(self.model) 666 652 667 653 self.enable_disp.SetValue(False) 668 654 self.disable_disp.SetValue(True) … … 742 728 """ 743 729 tcrtl= event.GetEventObject() 744 730 745 731 if check_float(tcrtl): 746 732 self._onparamEnter_helper() … … 808 794 reset the state 809 795 """ 796 self.reset_page_helper(state) 810 797 import sans.guiframe.gui_manager 811 812 self.reset_page_helper(state)813 798 evt = ModelEventbox(model=state.model) 814 799 wx.PostEvent(self.event_owner, evt) 800 815 801 self.manager._on_change_engine(engine=self.engine_type) 816 #Not improving anything yet. 817 #self.set_model_param_sizer(model=state.model) 802 818 803 819 804 def get_range(self): … … 889 874 self.param_toFit[0][4].Refresh() 890 875 else: 891 i=0 892 j=0 893 k=0 894 876 #i=0 895 877 if self.text2_3.IsShown(): 896 878 self.text2_3.Hide() 897 879 #print "fittable",self.print "fittable",self.fittable_param[p_name] 898 880 #Set the panel when fit result are list 881 899 882 for item in self.param_toFit: 900 883 ## reset error value to initial state … … 904 887 item[4].Hide() 905 888 906 if( out != None ) and len(out)<=len(self.param_toFit) and i < len(out):889 if( out != None ) and len(out)<=len(self.param_toFit):#and i < len(out): 907 890 item[2].SetValue(format_number(self.model.getParam(item[1]))) 908 891 item[2].Refresh() 909 910 if(cov !=None) and len(cov)<=len(self.param_toFit)and i < len(cov): 892 893 for ind in range(len(out)): 894 895 if item[1] == p_name[ind]: 896 break 897 898 if(cov !=None) and len(cov)<=len(self.param_toFit):#and i < len(cov): 911 899 try: 912 900 name= dispersity.__name__ … … 917 905 except: 918 906 pass 919 for j in range(len(out)): 920 921 if item[1] == p_name[j]: 922 break 923 ## unable to compare cov[j]==numpy.nan so switch to None 924 #Save errors to model.details[item][3] 925 self.model.details[item[1]][3] = cov[j] 926 927 if cov[j]==None or not numpy.isfinite(cov[j]): 907 if cov[ind]==None or not numpy.isfinite(cov[ind]): 928 908 929 909 if item[3].IsShown: … … 933 913 #k += 1 934 914 935 else: 936 k += 1 915 else: 937 916 item[3].Show(True) 938 917 item[3].Refresh() 939 918 item[4].Show(True) 940 item[4].SetValue(format_number(cov[ j]))919 item[4].SetValue(format_number(cov[ind])) 941 920 item[4].Refresh() 921 has_error = True 942 922 943 923 944 i+=1924 # i+=1 945 925 #Show error title when any errors displayed 946 if k != 0: # len(self.param_toFit):926 if has_error: 947 927 if not self.text2_3.IsShown(): 948 928 self.text2_3.Show(True) 949 950 self.text2_3.Layout() 929 ## save current state 930 self.save_current_state() 931 932 self.text2_3.Layout() 933 self.sizer3.Layout() 951 934 self.Layout() 952 935 self.Refresh() 953 936 954 937 def onSmear(self, event): … … 1154 1137 for item in self.fittable_param: 1155 1138 if item[0].GetValue(): 1139 #print item[0].GetValue() 1156 1140 if not (item in self.param_toFit): 1157 1141 self.param_toFit.append(item) … … 1205 1189 #list of dispersion paramaters 1206 1190 self.disp_list=self.model.getDispParamList() 1207 1191 1208 1192 keys.sort() 1209 1193 … … 1243 1227 self.text2_max.Show(True) 1244 1228 self.text2_min.Show(True) 1245 1229 1246 1230 for item in keys: 1247 1231 if not item in self.disp_list and not item in self.model.orientation_params: 1248 ##prepare a spot for error 1249 if len(self.model.details[item])<4: 1250 self.model.details[item].append(numpy.nan) 1232 1233 ##prepare a spot to store errors 1234 if not self.model.details.has_key(item): 1235 self.model.details [item] = ["",None,None] 1236 1251 1237 iy += 1 1252 1238 ix = 0 … … 1272 1258 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1273 1259 text2.Hide() 1274 ## txtcrtl to add error from fit1275 fit_errs = self.model.details[item][3]1276 1277 1260 ix += 1 1278 1261 ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER) 1279 1262 sizer.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1263 ctl2.Hide() 1280 1264 1281 ctl2.SetValue(str(format_number(fit_errs))) 1282 sizer.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1283 if fit_errs==None or not numpy.isfinite(fit_errs): 1284 ctl2.Hide() 1285 else: 1286 if not self.text2_3.IsShown(): 1287 self.text2_3.Show(True) 1288 if not text2.IsShown(): 1289 text2.Show(True) 1290 ctl2.Show(True) 1291 1292 param_min, param_max= self.model.details[item][1:3] 1265 param_min, param_max= self.model.details[item][1:] 1293 1266 ix += 1 1294 1267 ctl3 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, … … 1354 1327 for item in self.model.orientation_params: 1355 1328 if not item in self.disp_list: 1356 if len(self.model.details[item])<4: 1357 self.model.details[item].append(numpy.nan) 1329 1358 1330 iy += 1 1359 1331 ix = 0 … … 1387 1359 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1388 1360 text2.Hide() 1389 ## txtcrtl to add error from fit1390 fit_errs = self.model.details[item][3]1391 1361 ix += 1 1392 1362 ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER) … … 1395 1365 ctl2.Hide() 1396 1366 if self.data.__class__.__name__ !="Data2D": 1397 1367 ctl2.Hide() 1398 1368 else: 1399 if fit_errs!=None and numpy.isfinite(fit_errs):1400 1401 1402 1369 1370 if not text2.IsShown(): 1371 text2.Show(True) 1372 ctl2.Show(True) 1403 1373 1404 param_min, param_max= self.model.details[item][1: 3]1374 param_min, param_max= self.model.details[item][1:] 1405 1375 ix += 1 1406 1376 ctl3 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER, … … 1481 1451 #self._copy_parameters_state(self.fittable_param, self.state.fittable_param) 1482 1452 #self._copy_parameters_state(self.fixed_param, self.state.fixed_param) 1453 1483 1454 self.save_current_state_fit() 1484 1455 boxsizer1.Add(sizer) -
sansview/perspectives/fitting/pagestate.py
rc99a6c5 rb421b1a 123 123 obj.orientation_params = copy.deepcopy(self.orientation_params) 124 124 obj.orientation_params_disp = copy.deepcopy(self.orientation_params_disp) 125 126 125 obj.enable_disp = copy.deepcopy(self.enable_disp) 127 126 obj.disable_disp = copy.deepcopy(self.disable_disp) … … 134 133 for k , v in self.disp_cb_dict.iteritems(): 135 134 obj.disp_cb_dict[k]= v 135 136 136 obj.values = copy.deepcopy(self.values) 137 137 obj.weights = copy.deepcopy(self.weights) 138 138 obj.enable_smearer = copy.deepcopy(self.enable_smearer) 139 139 obj.disable_smearer = copy.deepcopy(self.disable_smearer) 140 140 141 141 obj.disp_box = copy.deepcopy(self.disp_box) 142 142 obj.qmin = copy.deepcopy(self.qmin)
Note: See TracChangeset
for help on using the changeset viewer.