Changeset 6ff97c5 in sasview for fittingview/src
- Timestamp:
- Aug 26, 2011 9:40:32 AM (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:
- aefc09f
- Parents:
- ecf26e1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fittingview/src/sans/perspectives/fitting/fitpage.py
rbc0e08d r6ff97c5 12 12 from sans.guiframe.events import StatusEvent 13 13 from sans.guiframe.events import NewPlotEvent 14 from sans.guiframe.utils import format_number,check_float 14 from sans.guiframe.dataFitting import check_data_validity 15 from sans.guiframe.utils import format_number 16 from sans.guiframe.utils import check_float 15 17 16 18 (Chi2UpdateEvent, EVT_CHI2_UPDATE) = wx.lib.newevent.NewEvent() … … 60 62 self._set_paste_flag(False) 61 63 self.btFit.SetFocus() 64 self.enable_fit_button() 62 65 self.fill_data_combobox(data_list=self.data_list) 63 66 64 67 def enable_fit_button(self): 68 """ 69 Enable fit button if data is valid and model is valid 70 """ 71 flag = check_data_validity(self.data) & (self.model is not None) 72 self.btFit.Enable(flag) 73 65 74 def _fill_data_sizer(self): 66 75 """ … … 98 107 self.enable_datasource() 99 108 if data_list: 109 #find the maximum range covering all data 100 110 qmin, qmax, npts = self.compute_data_range(data_list[0]) 101 111 self.qmin_data_set, self.qmax_data_set = qmin, qmax … … 105 115 self.compute_data_set_range(data) 106 116 self.dataSource.Append(str(data.name), clientData=data) 107 108 print "fill_data_combox", self.qmin_data_set, self.qmax_data_set109 117 self.dataSource.SetSelection(0) 110 118 self.on_select_data(event=None) … … 1013 1021 self.qmax_x = float(self.qmax.GetValue()) 1014 1022 self._manager._reset_schedule_problem(value=0, uid=self.uid) 1015 self._manager.schedule_for_fit(uid=self.uid,value=1 , fitproblem=None)1023 self._manager.schedule_for_fit(uid=self.uid,value=1) 1016 1024 self._manager.set_fit_range(uid=self.uid,qmin=self.qmin_x, 1017 1025 qmax=self.qmax_x) … … 1060 1068 self._on_fit_complete() 1061 1069 1070 def rename_model(self): 1071 """ 1072 find a short name for model 1073 """ 1074 if self.model is not None: 1075 self.model.name = "M" + str(self.index_model) 1076 1062 1077 def _on_select_model(self, event=None): 1063 1078 """ … … 1086 1101 self.state.structurecombobox = self.structurebox.GetCurrentSelection() 1087 1102 self.state.formfactorcombobox = self.formfactorbox.GetCurrentSelection() 1088 1103 self.enable_fit_button() 1089 1104 if self.model != None: 1105 self.rename_model() 1090 1106 self._set_copy_flag(True) 1091 1107 self._set_paste_flag(True) … … 1100 1116 self.onSmear(None) 1101 1117 temp_smear = None 1102 if self.enable_smearer.GetValue():1118 if not self.disable_smearer.GetValue(): 1103 1119 # Set the smearer environments 1104 1120 temp_smear = self.smearer … … 1114 1130 evt = ModelEventbox(model=self.model, 1115 1131 smearer=temp_smear, 1132 enable_smearer=not self.disable_smearer.GetValue(), 1116 1133 qmin=float(self.qmin_x), 1117 1134 uid=self.uid, 1135 caption=self.window_caption, 1118 1136 qmax=float(self.qmax_x)) 1119 1137 … … 1185 1203 not self.enable2D: 1186 1204 self._manager.set_smearer(smearer=temp_smearer, 1187 enable2D=self.enable2D,1205 fid=self.data.id, 1188 1206 uid=self.uid, 1189 1207 qmin= float(self.qmin_x), 1190 1208 qmax= float(self.qmax_x), 1209 enable_smearer=not self.disable_smearer.GetValue(), 1191 1210 draw=True) 1192 1211 if flag: … … 1248 1267 Check validity of value enter in the Q range field 1249 1268 """ 1250 #if self.check_invalid_panel(): 1251 # return 1252 tcrtl= event.GetEventObject() 1269 tcrtl = event.GetEventObject() 1253 1270 #Clear msg if previously shown. 1254 1271 msg= "" … … 1282 1299 #Check if # of points for theory model are valid(>0). 1283 1300 # check for 2d 1284 if self.data is not None: 1285 if self.data.__class__.__name__ == "Data2D" or \ 1286 self.enable2D: 1287 # set mask 1288 radius= numpy.sqrt( self.data.qx_data*self.data.qx_data + 1289 self.data.qy_data*self.data.qy_data ) 1290 index_data = ((self.qmin_x <= radius)& \ 1291 (radius<= self.qmax_x)) 1292 index_data = (index_data)&(self.data.mask) 1293 index_data = (index_data)&(numpy.isfinite(self.data.data)) 1294 if len(index_data[index_data]) < 10: 1295 msg = "Cannot Plot :No or too little npts in" 1296 msg += " that data range!!! " 1297 wx.PostEvent(self.parent.parent, 1298 StatusEvent(status=msg)) 1299 return 1300 else: 1301 self.data.mask = index_data 1302 #self.Npts_fit.SetValue(str(len(self.data.mask))) 1303 self.set_npts2fit() 1301 if self.data.__class__.__name__ == "Data2D" or \ 1302 self.enable2D: 1303 # set mask 1304 radius= numpy.sqrt(self.data.qx_data*self.data.qx_data + 1305 self.data.qy_data*self.data.qy_data ) 1306 index_data = ((self.qmin_x <= radius)& \ 1307 (radius<= self.qmax_x)) 1308 index_data = (index_data)&(self.data.mask) 1309 index_data = (index_data)&(numpy.isfinite(self.data.data)) 1310 if len(index_data[index_data]) < 10: 1311 msg = "Cannot Plot :No or too little npts in" 1312 msg += " that data range!!! " 1313 wx.PostEvent(self.parent.parent, 1314 StatusEvent(status=msg)) 1315 return 1304 1316 else: 1305 index_data = ((self.qmin_x <= self.data.x)& \1306 (self.data.x <= self.qmax_x))1307 self. Npts_fit.SetValue(str(len(self.data.x[index_data])))1317 self.data.mask = index_data 1318 #self.Npts_fit.SetValue(str(len(self.data.mask))) 1319 self.set_npts2fit() 1308 1320 else: 1309 self.npts_x = self.Npts_total.GetValue() 1310 self._save_plotting_range() 1311 1321 index_data = ((self.qmin_x <= self.data.x)& \ 1322 (self.data.x <= self.qmax_x)) 1323 self.Npts_fit.SetValue(str(len(self.data.x[index_data]))) 1324 1325 self.npts_x = self.Npts_total.GetValue() 1326 self.create_default_data() 1327 self._save_plotting_range() 1312 1328 else: 1313 1329 tcrtl.SetBackgroundColour("pink") … … 1316 1332 1317 1333 self._draw_model() 1318 ##update chi21319 #self.compute_chisqr(smearer= temp_smearer)1320 #self._undo.Enable(True)1321 1334 self.save_current_state() 1322 1335 event = PageInfoEvent(page = self) … … 1673 1686 qmax = math.sqrt(x*x + y*y) 1674 1687 npts = len(data.data) 1675 print "compute single data range", qmin, qmax1676 1688 return qmin, qmax, npts 1677 1689 … … 1684 1696 group_id = None 1685 1697 flag = False 1698 if self.data is not None: 1699 group_id = self.data.group_id 1700 1686 1701 if self.data is None and data is not None: 1687 flag = True1702 flag = True 1688 1703 if data is not None: 1689 1704 id = data.id 1690 group_id = data.group_id1691 1705 if self.data is not None: 1692 1706 flag = (data.id != self.data.id) 1693 1707 self.data = data 1708 self.data.group_id = group_id 1694 1709 if self.data is None: 1695 1710 data_min = "" … … 1703 1718 self._set_bookmark_flag(True) 1704 1719 self._keep.Enable(True) 1720 1705 1721 self._set_save_flag(True) 1706 1722 self._set_preview_flag(True) … … 1756 1772 self.state.qmin = self.qmin_x 1757 1773 self.state.qmax = self.qmax_x 1758 1774 self.enable_fit_button() 1759 1775 #update model plot with new data information 1760 1776 if flag: … … 1766 1782 self.enable2D = False 1767 1783 self.model_view.SetLabel("1D Mode") 1768 1769 1784 self.model_view.Disable() 1770 1771 1785 #replace data plot on combo box selection 1772 1786 #by removing the previous selected data … … 1776 1790 wx.PostEvent(self._manager.parent, NewPlotEvent(plot=self.data, 1777 1791 title=str(self.data.title))) 1778 self._manager.store_data(uid=self.uid, data=data, 1779 data_list=self.data_list, 1792 self._manager.store_data(uid=self.uid, data_list=self.data_list, 1780 1793 caption=self.window_name) 1781 1794 self._draw_model() … … 2151 2164 get_pin_max.SetBackgroundColour("white") 2152 2165 ## set smearing value whether or not the data contain the smearing info 2166 2153 2167 self._manager.set_smearer(smearer=self.current_smearer, 2154 enable2D=self.enable2D,2168 fid=self.data.id, 2155 2169 qmin=float(self.qmin_x), 2156 2170 qmax= float(self.qmax_x), 2171 enable_smearer=not self.disable_smearer.GetValue(), 2157 2172 uid=self.uid) 2158 2173 return msg … … 2326 2341 ## set smearing value whether or not the data contain the smearing info 2327 2342 self._manager.set_smearer(smearer=self.current_smearer, 2328 enable2D=self.enable2D,2343 fid=self.data.id, 2329 2344 qmin=float(self.qmin_x), 2330 2345 qmax= float(self.qmax_x), 2346 enable_smearer=not self.disable_smearer.GetValue(), 2331 2347 uid=self.uid) 2332 2348 return msg … … 2415 2431 ## set smearing value whether or not the data contain the smearing info 2416 2432 self._manager.set_smearer(uid=self.uid, smearer=temp_smearer, 2417 enable2D=self.enable2D, 2418 qmin= float(self.qmin_x), 2419 qmax= float(self.qmax_x), draw=True) 2433 fid=self.data.id, 2434 qmin=float(self.qmin_x), 2435 qmax=float(self.qmax_x), 2436 enable_smearer=not self.disable_smearer.GetValue(), 2437 draw=True) 2420 2438 2421 2439 self.state.enable_smearer= self.enable_smearer.GetValue() … … 2426 2444 def on_complete_chisqr(self, event): 2427 2445 """ 2428 print result chisqr 2429 2446 Display result chisqr on the panel 2430 2447 :event: activated by fitting/ complete after draw 2431 2432 2448 """ 2433 2449 try: … … 2439 2455 output = event.output 2440 2456 self.tcChi.SetValue(str(format_number(output, True))) 2441 2442 2457 self.state.tcChi = self.tcChi.GetValue() 2443 2458 except: … … 2958 2973 self.model_view.SetLabel("1D Mode") 2959 2974 self.enable2D = False 2960 2975 self.create_default_data() 2961 2976 self.set_model_param_sizer(self.model) 2962 2977 self._set_sizer_dispersion()
Note: See TracChangeset
for help on using the changeset viewer.