Changeset 940aca7 in sasview for fittingview/src/sans/perspectives
- Timestamp:
- May 19, 2012 12:17:02 PM (13 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:
- baa915c
- Parents:
- d225e32
- Location:
- fittingview/src/sans/perspectives/fitting
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
fittingview/src/sans/perspectives/fitting/basepage.py
r19e614a r940aca7 113 113 self.enable2D = False 114 114 self.is_mac = ON_MAC 115 115 self.formfactorbox = None 116 self.structurebox = None 116 117 ##list of model parameters. each item must have same length 117 118 ## each item related to a given parameters … … 882 883 self.state.disp_list = copy.deepcopy(self.disp_list) 883 884 self.state.model = self.model.clone() 885 886 #model combobox: complex code because of mac's silent error 887 if self.structurebox != None: 888 if self.structurebox.IsShown(): 889 self.state.structurecombobox = 'None' 890 s_select = self.structurebox.GetSelection() 891 if s_select > 0: 892 self.state.structurecombobox = self.structurebox.\ 893 GetString(s_select) 894 if self.formfactorbox != None: 895 f_select = self.formfactorbox.GetSelection() 896 if f_select > 0: 897 self.state.formfactorcombobox = self.formfactorbox.\ 898 GetString(f_select) 899 884 900 #save radiobutton state for model selection 885 901 self.state.shape_rbutton = self.shape_rbutton.GetValue() … … 887 903 self.state.struct_rbutton = self.struct_rbutton.GetValue() 888 904 self.state.plugin_rbutton = self.plugin_rbutton.GetValue() 889 #model combobox890 self.state.structurebox = self.structurebox.GetLabel()891 self.state.formfactorbox = self.formfactorbox.GetLabel()892 905 893 906 self.state.enable2D = copy.deepcopy(self.enable2D) … … 1231 1244 structfactor_pos = 0 1232 1245 for ind_struct in range(self.structurebox.GetCount()): 1233 if self.structurebox.GetString(ind_struct) == (state.structurecombobox) > 0:1246 if self.structurebox.GetString(ind_struct) == (state.structurecombobox): 1234 1247 structfactor_pos = int(ind_struct) 1235 1248 break … … 1428 1441 self.state.struct_rbutton = self.struct_rbutton.GetValue() 1429 1442 self.state.plugin_rbutton = self.plugin_rbutton.GetValue() 1430 self.state.structure box = self.structurebox.GetLabel()1431 self.state.formfactor box = self.formfactorbox.GetLabel()1443 self.state.structurecombobox = self.structurebox.GetLabel() 1444 self.state.formfactorcombobox = self.formfactorbox.GetLabel() 1432 1445 1433 1446 ## post state to fit panel -
fittingview/src/sans/perspectives/fitting/batchfitpage.py
r978feaa r940aca7 38 38 self.window_caption = "BatchFit" 39 39 self._set_save_flag(False) 40 self._set_bookmark_flag(False) 40 41 41 42 def _fill_range_sizer(self): … … 365 366 self._set_paste_flag(True) 366 367 if self.data != None: 367 self._set_bookmark_flag( True)368 self._keep.Enable( True)368 self._set_bookmark_flag(False) 369 self._keep.Enable(False) 369 370 370 371 temp_smear = None … … 552 553 else: 553 554 if self.model != None: 554 self._set_bookmark_flag( True)555 self._keep.Enable( True)556 self._set_save_flag( True)555 self._set_bookmark_flag(False) 556 self._keep.Enable(False) 557 self._set_save_flag(False) 557 558 self._set_preview_flag(True) 558 559 """ -
fittingview/src/sans/perspectives/fitting/fit_thread.py
raff2913 r940aca7 26 26 completefn = None, 27 27 updatefn = None, 28 yieldtime = 0.0 1,29 worktime = 0.0 1,28 yieldtime = 0.03, 29 worktime = 0.03, 30 30 ftol = None, 31 31 reset_flag = False): -
fittingview/src/sans/perspectives/fitting/fitpage.py
rac2b835 r940aca7 1220 1220 is_data = check_data_validity(self.data) 1221 1221 if is_data: 1222 self._set_bookmark_flag( True)1223 self._keep.Enable( True)1222 self._set_bookmark_flag(not self.batch_on) 1223 self._keep.Enable(not self.batch_on) 1224 1224 self._set_save_flag(True) 1225 1225 # Reset smearer, model and data … … 1482 1482 if len(self.parameters) > 0: 1483 1483 for item in self.parameters: 1484 #Skip t ifhe angle parameters if 1D data 1485 if self.data.__class__.__name__ != "Data2D" and \ 1486 not self.enable2D: 1487 if item in self.orientation_params: 1484 if item[0].IsShown(): 1485 #Skip t ifhe angle parameters if 1D data 1486 if self.data.__class__.__name__ != "Data2D" and \ 1487 not self.enable2D: 1488 if item in self.orientation_params: 1489 continue 1490 if item in self.param_toFit: 1488 1491 continue 1489 if item in self.param_toFit: 1490 continue 1491 ## hide statictext +/- 1492 if len(item) < 4: 1493 continue 1494 if item[3] != None and item[3].IsShown(): 1495 item[3].Hide() 1496 ## hide textcrtl for error after fit 1497 if item[4] != None and item[4].IsShown(): 1498 item[4].Hide() 1492 ## hide statictext +/- 1493 if len(item) < 4: 1494 continue 1495 if item[3] != None and item[3].IsShown(): 1496 item[3].Hide() 1497 ## hide textcrtl for error after fit 1498 if item[4] != None and item[4].IsShown(): 1499 item[4].Hide() 1499 1500 1500 1501 if len(self.fittable_param) > 0: 1501 1502 for item in self.fittable_param: 1502 #Skip t ifhe angle parameters if 1D data 1503 if self.data.__class__.__name__ != "Data2D" and \ 1504 not self.enable2D: 1505 if item in self.orientation_params: 1503 if item[0].IsShown(): 1504 #Skip t ifhe angle parameters if 1D data 1505 if self.data.__class__.__name__ != "Data2D" and \ 1506 not self.enable2D: 1507 if item in self.orientation_params: 1508 continue 1509 if item in self.param_toFit: 1506 1510 continue 1507 if item in self.param_toFit: 1508 continue 1509 if len(item) < 4: 1510 continue 1511 ## hide statictext +/- 1512 if item[3] != None and item[3].IsShown(): 1513 item[3].Hide() 1514 ## hide textcrtl for error after fit 1515 if item[4] != None and item[4].IsShown(): 1516 item[4].Hide() 1511 if len(item) < 4: 1512 continue 1513 ## hide statictext +/- 1514 if item[3] != None and item[3].IsShown(): 1515 item[3].Hide() 1516 ## hide textcrtl for error after fit 1517 if item[4] != None and item[4].IsShown(): 1518 item[4].Hide() 1517 1519 return 1518 1520 … … 1847 1849 else: 1848 1850 if self.model != None: 1849 self._set_bookmark_flag( True)1850 self._keep.Enable( True)1851 self._set_bookmark_flag(not self.batch_on) 1852 self._keep.Enable(not self.batch_on) 1851 1853 1852 1854 self._set_save_flag(True) … … 1941 1943 #replace data plot on combo box selection 1942 1944 #by removing the previous selected data 1943 wx.PostEvent(self._manager.parent,1944 NewPlotEvent(action="remove",1945 group_id=self.graph_id, id=id))1945 #wx.PostEvent(self._manager.parent, 1946 # NewPlotEvent(action="remove", 1947 # group_id=self.graph_id, id=id)) 1946 1948 #plot the current selected data 1947 1949 wx.PostEvent(self._manager.parent, 1948 NewPlotEvent( plot=self.data,1950 NewPlotEvent(action="check", plot=self.data, 1949 1951 title=str(self.data.title))) 1950 1952 self._draw_model() … … 2077 2079 for item in self.param_toFit: 2078 2080 if len(item) > 5 and item != None: 2079 ## reset error value to initial state 2080 if not self.is_mac: 2081 item[3].Hide() 2082 item[4].Hide() 2083 for ind in range(len(out)): 2084 if item[1] == p_name[ind]: 2085 break 2086 if len(out) <= len(self.param_toFit) and out[ind] != None: 2087 val_out = format_number(out[ind], True) 2088 item[2].SetValue(val_out) 2089 2090 if(cov != None and len(cov) == len(out)): 2091 try: 2092 if dispersity != None: 2093 if self.enable_disp.GetValue(): 2094 if hasattr(self, "text_disp_1"): 2095 if self.text_disp_1 != None: 2096 if not self.text_disp_1.IsShown()\ 2097 and not self.is_mac: 2098 self.text_disp_1.Show(True) 2099 except: 2100 pass 2101 2102 if cov[ind] != None: 2103 if numpy.isfinite(float(cov[ind])): 2104 val_err = format_number(cov[ind], True) 2105 if not self.is_mac: 2106 item[3].Show(True) 2107 item[4].Show(True) 2108 item[4].SetValue(val_err) 2109 has_error = True 2081 if item[0].IsShown(): 2082 ## reset error value to initial state 2083 if not self.is_mac: 2084 item[3].Hide() 2085 item[4].Hide() 2086 for ind in range(len(out)): 2087 if item[1] == p_name[ind]: 2088 break 2089 if len(out) > 0 and out[ind] != None: 2090 val_out = format_number(out[ind], True) 2091 item[2].SetValue(val_out) 2092 2093 if(cov != None and len(cov) == len(out)): 2094 try: 2095 if dispersity != None: 2096 if self.enable_disp.GetValue(): 2097 if hasattr(self, "text_disp_1"): 2098 if self.text_disp_1 != None: 2099 if not self.text_disp_1.IsShown()\ 2100 and not self.is_mac: 2101 self.text_disp_1.Show(True) 2102 except: 2103 pass 2104 2105 if cov[ind] != None: 2106 if numpy.isfinite(float(cov[ind])): 2107 val_err = format_number(cov[ind], True) 2108 if not self.is_mac: 2109 item[3].Show(True) 2110 item[4].Show(True) 2111 item[4].SetValue(val_err) 2112 has_error = True 2110 2113 i += 1 2114 else: 2115 raise ValueError, "onsetValues: Invalid parameters..." 2111 2116 #Show error title when any errors displayed 2112 2117 if has_error: … … 2606 2611 for item in self.parameters: 2607 2612 if item[0].GetValue() and item not in self.param_toFit: 2608 self.param_toFit.append(item) 2613 if item[0].IsShown(): 2614 self.param_toFit.append(item) 2609 2615 for item in self.fittable_param: 2610 2616 if item[0].GetValue() and item not in self.param_toFit: 2611 self.param_toFit.append(item) 2617 if item[0].IsShown(): 2618 self.param_toFit.append(item) 2612 2619 self.save_current_state_fit() 2613 2620 … … 2616 2623 param2fit = [] 2617 2624 for item in self.param_toFit: 2618 if item[0] :2625 if item[0] and item[0].IsShown(): 2619 2626 param2fit.append(item[1]) 2620 2627 self.parent._manager.set_param2fit(self.uid, param2fit) … … 2628 2635 if self.cb1.GetValue(): 2629 2636 for item in self.parameters: 2630 ## for data2D select all to fit 2631 if self.data.__class__.__name__ == "Data2D" or \ 2632 self.enable2D: 2633 item[0].SetValue(True) 2634 self.param_toFit.append(item) 2635 else: 2636 ## for 1D all parameters except orientation 2637 if not item in self.orientation_params: 2637 if item[0].IsShown(): 2638 ## for data2D select all to fit 2639 if self.data.__class__.__name__ == "Data2D" or \ 2640 self.enable2D: 2638 2641 item[0].SetValue(True) 2639 2642 self.param_toFit.append(item) 2643 else: 2644 ## for 1D all parameters except orientation 2645 if not item in self.orientation_params: 2646 item[0].SetValue(True) 2647 self.param_toFit.append(item) 2648 else: 2649 item[0].SetValue(False) 2640 2650 #if len(self.fittable_param)>0: 2641 2651 for item in self.fittable_param: 2642 if self.data.__class__.__name__ == "Data2D" or \ 2643 self.enable2D: 2644 item[0].SetValue(True) 2645 self.param_toFit.append(item) 2646 try: 2647 if len(self.values[item[1]]) > 0: 2648 item[0].SetValue(False) 2649 except: 2650 pass 2651 2652 else: 2653 ## for 1D all parameters except orientation 2654 if not item in self.orientation_params_disp: 2652 if item[0].IsShown(): 2653 if self.data.__class__.__name__ == "Data2D" or \ 2654 self.enable2D: 2655 2655 item[0].SetValue(True) 2656 2656 self.param_toFit.append(item) … … 2660 2660 except: 2661 2661 pass 2662 2663 else: 2664 ## for 1D all parameters except orientation 2665 if not item in self.orientation_params_disp: 2666 item[0].SetValue(True) 2667 self.param_toFit.append(item) 2668 try: 2669 if len(self.values[item[1]]) > 0: 2670 item[0].SetValue(False) 2671 except: 2672 pass 2673 else: 2674 item[0].SetValue(False) 2662 2675 2663 2676 else: … … 2677 2690 param2fit = [] 2678 2691 for item in self.param_toFit: 2679 if item[0] :2692 if item[0] and item[0].IsShown(): 2680 2693 param2fit.append(item[1]) 2681 2694 self.parent._manager.set_param2fit(self.uid, param2fit) … … 2694 2707 continue 2695 2708 #Select parameters to fit for list of primary parameters 2696 if item[0].GetValue() :2709 if item[0].GetValue() and item[0].IsShown(): 2697 2710 if not (item in self.param_toFit): 2698 2711 self.param_toFit.append(item) … … 2710 2723 if item in self.orientation_params: 2711 2724 continue 2712 if item[0].GetValue() :2725 if item[0].GetValue() and item[0].IsShown(): 2713 2726 if not (item in self.param_toFit): 2714 2727 self.param_toFit.append(item) … … 2742 2755 param2fit = [] 2743 2756 for item in self.param_toFit: 2744 if item[0] :2757 if item[0] and item[0].IsShown(): 2745 2758 param2fit.append(item[1]) 2746 2759 self.parent._manager.set_param2fit(self.uid, param2fit) -
fittingview/src/sans/perspectives/fitting/fitting.py
rb9dd680 r940aca7 48 48 49 49 50 if sys.platform .count("darwin") == 0:50 if sys.platform == "win32": 51 51 ON_MAC = False 52 52 else: … … 73 73 self.weight = None 74 74 self.fit_panel = None 75 self.plot_panel = None 75 76 # Start with a good default 76 77 self.elapsed = 0.022 … … 460 461 461 462 """ 463 self.plot_panel = plotpanel 462 464 graph = plotpanel.graph 463 465 fit_option = "Select data for fitting" … … 483 485 else: 484 486 return [] 487 return [[fit_option, fit_hint, self._onSelect]] 485 488 return [] 486 489 … … 1281 1284 added to self.page_finder 1282 1285 """ 1283 self.panel = event.GetEventObject() 1286 panel = self.plot_panel 1287 if panel == None: 1288 raise ValueError, "Fitting:_onSelect: NonType panel" 1284 1289 Plugin.on_perspective(self, event=event) 1285 self.select_data( self.panel)1290 self.select_data(panel) 1286 1291 1287 1292 def select_data(self, panel): 1288 1293 """ 1289 1294 """ 1290 self.panel = panel 1291 for plottable in self.panel.graph.plottables: 1295 for plottable in panel.graph.plottables: 1292 1296 if plottable.__class__.__name__ in ["Data1D", "Theory1D"]: 1293 data_id = self.panel.graph.selected_plottable1294 if plottable == self.panel.plots[data_id]:1297 data_id = panel.graph.selected_plottable 1298 if plottable == panel.plots[data_id]: 1295 1299 data = plottable 1296 1300 self.add_fit_page(data=[data]) … … 1880 1884 1881 1885 if len(title) > 1: 1882 new_plot.title = "Model2D for "+ data_name1886 new_plot.title = "Model2D for %s "% model.name + data_name 1883 1887 new_plot.name = model.name + " [" + \ 1884 data_name + " -2D]"1888 data_name + "]" 1885 1889 theory_data = deepcopy(new_plot) 1886 theory_data.name = "Unknown"1887 1890 1888 1891 self.page_finder[page_id].set_theory_data(data=theory_data, … … 2128 2131 residuals.xaxis('\\rm{Q} ', 'A^{-1}') 2129 2132 residuals.yaxis('\\rm{Residuals} ', 'normalized') 2133 theory_name = str(theory_data.name.split()[0]) 2130 2134 new_plot = residuals 2131 new_plot.name = "Residuals for " + str(theory_data.name.split()[0]) + "[" + str(data.name) +"]" 2135 new_plot.name = "Residuals for " + str(theory_name) + "[" +\ 2136 str(data.name) +"]" 2132 2137 ## allow to highlight data when plotted 2133 2138 new_plot.interactive = True 2134 2139 ## when 2 data have the same id override the 1 st plotted 2135 new_plot.id = "res" + str(data_copy.id) 2140 new_plot.id = "res" + str(data_copy.id) + str(theory_name) 2136 2141 ##group_id specify on which panel to plot this data 2137 2142 group_id = self.page_finder[page_id].get_graph_id() -
fittingview/src/sans/perspectives/fitting/simfitpage.py
rf32d144 r940aca7 215 215 216 216 self._update_easy_setup_cb() 217 self.Layout() 217 218 self.Refresh() 218 219 … … 664 665 ## some model or parameters can be constrained 665 666 self._show_constraint() 667 self.sizer3.Layout() 668 self.Layout() 669 self.Refresh() 666 670 667 671 def _fill_sizer_fit(self):
Note: See TracChangeset
for help on using the changeset viewer.