Changeset 55bb249c in sasview for fittingview/src/sans/perspectives
- Timestamp:
- Sep 7, 2011 6:24:56 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:
- 44f9c8b
- Parents:
- 7ad194fa
- Location:
- fittingview/src/sans/perspectives/fitting
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
fittingview/src/sans/perspectives/fitting/basepage.py
r2e95da4 r55bb249c 869 869 self.state.qmax_x = self.qmax_x 870 870 self.state.qmin_x = self.qmin_x 871 871 self.state.dI_noweight = copy.deepcopy(self.dI_noweight.GetValue()) 872 self.state.dI_didata = copy.deepcopy(self.dI_didata.GetValue()) 873 self.state.dI_sqrdata = copy.deepcopy(self.dI_sqrdata.GetValue()) 874 self.state.dI_idata = copy.deepcopy(self.dI_idata.GetValue()) 872 875 if hasattr(self,"enable_disp"): 873 876 self.state.enable_disp= self.enable_disp.GetValue() … … 950 953 copy.deepcopy(self.pinhole_smearer.GetValue()) 951 954 self.state.slit_smearer = copy.deepcopy(self.slit_smearer.GetValue()) 952 955 self.state.dI_noweight = copy.deepcopy(self.dI_noweight.GetValue()) 956 self.state.dI_didata = copy.deepcopy(self.dI_didata.GetValue()) 957 self.state.dI_sqrdata = copy.deepcopy(self.dI_sqrdata.GetValue()) 958 self.state.dI_idata = copy.deepcopy(self.dI_idata.GetValue()) 953 959 if hasattr(self,"disp_box"): 954 960 self.state.disp_box = self.disp_box.GetCurrentSelection() … … 1088 1094 self.pinhole_smearer.SetValue(state.pinhole_smearer) 1089 1095 self.slit_smearer.SetValue(state.slit_smearer) 1096 1097 self.dI_noweight.SetValue(state.dI_noweight) 1098 self.dI_didata.SetValue(state.dI_didata) 1099 self.dI_sqrdata.SetValue(state.dI_sqrdata) 1100 self.dI_idata.SetValue(state.dI_idata) 1101 1090 1102 ## we have two more options for smearing 1091 1103 if self.pinhole_smearer.GetValue(): self.onPinholeSmear(event=None) … … 1205 1217 self.pinhole_smearer.SetValue(state.pinhole_smearer) 1206 1218 self.slit_smearer.SetValue(state.slit_smearer) 1219 1220 self.dI_noweight.SetValue(state.dI_noweight) 1221 self.dI_didata.SetValue(state.dI_didata) 1222 self.dI_sqrdata.SetValue(state.dI_sqrdata) 1223 self.dI_idata.SetValue(state.dI_idata) 1224 1225 1207 1226 ## we have two more options for smearing 1208 1227 if self.pinhole_smearer.GetValue(): self.onPinholeSmear(event=None) 1209 1228 elif self.slit_smearer.GetValue(): self.onSlitSmear(event=None) 1210 1229 1211 1230 ## reset state of checkbox,textcrtl and dispersity parameters value 1212 1231 self._reset_parameters_state(self.fittable_param,state.fittable_param) … … 1766 1785 if not self.disable_smearer.GetValue(): 1767 1786 temp_smear= self.current_smearer 1787 weight = self.get_weight() 1768 1788 toggle_mode_on = self.model_view.IsEnabled() 1769 1789 self._manager.draw_model(self.model, … … 1776 1796 state = self.state, 1777 1797 enable2D=self.enable2D, 1778 update_chisqr=update_chisqr) 1798 update_chisqr=update_chisqr, 1799 weight=weight) 1779 1800 1780 1801 -
fittingview/src/sans/perspectives/fitting/fitpage.py
r2c60cb69 r55bb249c 47 47 self.is_2D = None 48 48 self.fit_started = False 49 self.weightbt_string = None 49 50 # get smear info from data 50 51 self._get_smear_info() … … 185 186 smear_message_none = "No smearing is selected..." 186 187 smear_message_dqdata = "The dQ data is being used for smearing..." 187 smear_message_2d = "Higher accuracy is very time-expensive. Use it with care..." 188 smear_message_new_ssmear = "Please enter only the value of interest to customize smearing..." 189 smear_message_new_psmear = "Please enter both; the dQ will be generated by interpolation..." 188 smear_message_2d = \ 189 "Higher accuracy is very time-expensive. Use it with care..." 190 smear_message_new_ssmear = \ 191 "Please enter only the value of interest to customize smearing..." 192 smear_message_new_psmear = \ 193 "Please enter both; the dQ will be generated by interpolation..." 190 194 smear_message_2d_x_title = "<dQp>[1/A]:" 191 195 smear_message_2d_y_title = "<dQs>[1/A]:" … … 207 211 smear_set_box= wx.StaticBox(self, -1,'Set Instrumental Smearing') 208 212 sizer_smearer_box = wx.StaticBoxSizer(smear_set_box, wx.HORIZONTAL) 209 sizer_smearer_box.SetMinSize((_DATA_BOX_WIDTH,85)) 213 sizer_smearer_box.SetMinSize((_DATA_BOX_WIDTH, 60)) 214 215 weighting_set_box= wx.StaticBox(self, -1,\ 216 'Set Weighting by Selecting dI Source') 217 weighting_box = wx.StaticBoxSizer(weighting_set_box, wx.HORIZONTAL) 218 sizer_weighting = wx.BoxSizer(wx.HORIZONTAL) 219 weighting_box.SetMinSize((_DATA_BOX_WIDTH, 40)) 220 #Filling the sizer containing weighting info. 221 self.dI_noweight = wx.RadioButton(self, -1, 'No Weighting', 222 style=wx.RB_GROUP) 223 self.dI_didata = wx.RadioButton(self, -1, 'Use dI Data') 224 self.dI_sqrdata = wx.RadioButton(self, -1, 'Use |sqrt(I Data)|') 225 self.dI_idata = wx.RadioButton(self, -1, 'Use |I Data|') 226 self.Bind(wx.EVT_RADIOBUTTON, self.onWeighting, 227 id=self.dI_noweight.GetId()) 228 self.Bind(wx.EVT_RADIOBUTTON, self.onWeighting, 229 id=self.dI_didata.GetId()) 230 self.Bind(wx.EVT_RADIOBUTTON, self.onWeighting, 231 id=self.dI_sqrdata.GetId()) 232 self.Bind(wx.EVT_RADIOBUTTON, self.onWeighting, 233 id=self.dI_idata.GetId()) 234 self.dI_didata.SetValue(True) 235 # add 4 types of weighting to the sizer 236 sizer_weighting.Add( self.dI_noweight,0, wx.LEFT, 10) 237 sizer_weighting.Add((14,10)) 238 sizer_weighting.Add( self.dI_didata) 239 sizer_weighting.Add((14,10)) 240 sizer_weighting.Add( self.dI_sqrdata) 241 sizer_weighting.Add((14,10)) 242 sizer_weighting.Add( self.dI_idata) 243 sizer_weighting.Add((10,10)) 244 self.dI_noweight.Enable(False) 245 self.dI_didata.Enable(False) 246 self.dI_sqrdata.Enable(False) 247 self.dI_idata.Enable(False) 248 weighting_box.Add(sizer_weighting) 249 210 250 sizer_fit = wx.GridSizer(2, 4, 2, 6) 211 251 212 252 # combobox for smear2d accuracy selection 213 self.smear_accuracy = wx.ComboBox(self, -1,size=(50,-1),style=wx.CB_READONLY) 253 self.smear_accuracy = wx.ComboBox(self, -1,size=(50,-1), 254 style=wx.CB_READONLY) 214 255 self._set_accuracy_list() 215 256 self.smear_accuracy.SetValue(self.smear2d_accuracy) 216 257 self.smear_accuracy.SetSelection(0) 217 self.smear_accuracy.SetToolTipString("'Higher' uses more Gaussian points for smearing computation.") 258 self.smear_accuracy.SetToolTipString(\ 259 "'Higher' uses more Gaussian points for smearing computation.") 218 260 219 261 wx.EVT_COMBOBOX(self.smear_accuracy,-1, self._on_select_accuracy) … … 226 268 227 269 #textcntrl for custom resolution 228 self.smear_pinhole_max = self.ModelTextCtrl(self, -1,size=(_BOX_WIDTH-25,20),style=wx.TE_PROCESS_ENTER, 229 text_enter_callback = self.onPinholeSmear) 230 self.smear_pinhole_min = self.ModelTextCtrl(self, -1,size=(_BOX_WIDTH-25,20),style=wx.TE_PROCESS_ENTER, 231 text_enter_callback = self.onPinholeSmear) 232 self.smear_slit_height= self.ModelTextCtrl(self, -1,size=(_BOX_WIDTH-25,20),style=wx.TE_PROCESS_ENTER, 233 text_enter_callback = self.onSlitSmear) 234 self.smear_slit_width = self.ModelTextCtrl(self, -1,size=(_BOX_WIDTH-25,20),style=wx.TE_PROCESS_ENTER, 235 text_enter_callback = self.onSlitSmear) 270 self.smear_pinhole_max = self.ModelTextCtrl(self, -1, 271 size=(_BOX_WIDTH-25,20),style=wx.TE_PROCESS_ENTER, 272 text_enter_callback = self.onPinholeSmear) 273 self.smear_pinhole_min = self.ModelTextCtrl(self, -1, 274 size=(_BOX_WIDTH-25,20),style=wx.TE_PROCESS_ENTER, 275 text_enter_callback = self.onPinholeSmear) 276 self.smear_slit_height= self.ModelTextCtrl(self, -1, 277 size=(_BOX_WIDTH-25,20),style=wx.TE_PROCESS_ENTER, 278 text_enter_callback = self.onSlitSmear) 279 self.smear_slit_width = self.ModelTextCtrl(self, -1, 280 size=(_BOX_WIDTH-25,20),style=wx.TE_PROCESS_ENTER, 281 text_enter_callback = self.onSlitSmear) 236 282 237 283 ## smear 238 self.smear_data_left= BGTextCtrl(self, -1, size=(_BOX_WIDTH-25,20), style=0) 284 self.smear_data_left= BGTextCtrl(self, -1, 285 size=(_BOX_WIDTH-25,20), style=0) 239 286 self.smear_data_left.SetValue(str(self.dq_l)) 240 self.smear_data_right = BGTextCtrl(self, -1, size=(_BOX_WIDTH-25,20), style=0) 287 self.smear_data_right = BGTextCtrl(self, -1, 288 size=(_BOX_WIDTH-25,20), style=0) 241 289 self.smear_data_right.SetValue(str(self.dq_r)) 242 290 … … 248 296 249 297 #Filling the sizer containing instruments smearing info. 250 self.disable_smearer = wx.RadioButton(self, -1, 'None', style=wx.RB_GROUP) 251 self.enable_smearer = wx.RadioButton(self, -1, 'Use dQ Data') 252 #self.enable_smearer.SetToolTipString("Click to use the loaded dQ data for smearing.") 253 self.pinhole_smearer = wx.RadioButton(self, -1, 'Custom Pinhole Smear') 254 #self.pinhole_smearer.SetToolTipString("Click to input custom resolution for pinhole smearing.") 298 self.disable_smearer = wx.RadioButton(self, -1, 299 'None', style=wx.RB_GROUP) 300 self.enable_smearer = wx.RadioButton(self, -1, 301 'Use dQ Data') 302 #self.enable_smearer.SetToolTipString( 303 #"Click to use the loaded dQ data for smearing.") 304 self.pinhole_smearer = wx.RadioButton(self, -1, 305 'Custom Pinhole Smear') 306 #self.pinhole_smearer.SetToolTipString 307 #("Click to input custom resolution for pinhole smearing.") 255 308 self.slit_smearer = wx.RadioButton(self, -1, 'Custom Slit Smear') 256 #self.slit_smearer.SetToolTipString("Click to input custom resolution for slit smearing.") 257 self.Bind(wx.EVT_RADIOBUTTON, self.onSmear, id=self.disable_smearer.GetId()) 258 self.Bind(wx.EVT_RADIOBUTTON, self.onSmear, id=self.enable_smearer.GetId()) 259 self.Bind(wx.EVT_RADIOBUTTON, self.onPinholeSmear, id=self.pinhole_smearer.GetId()) 260 self.Bind(wx.EVT_RADIOBUTTON, self.onSlitSmear, id=self.slit_smearer.GetId()) 309 #self.slit_smearer.SetToolTipString 310 #("Click to input custom resolution for slit smearing.") 311 self.Bind(wx.EVT_RADIOBUTTON, self.onSmear, 312 id=self.disable_smearer.GetId()) 313 self.Bind(wx.EVT_RADIOBUTTON, self.onSmear, 314 id=self.enable_smearer.GetId()) 315 self.Bind(wx.EVT_RADIOBUTTON, self.onPinholeSmear, 316 id=self.pinhole_smearer.GetId()) 317 self.Bind(wx.EVT_RADIOBUTTON, self.onSlitSmear, 318 id=self.slit_smearer.GetId()) 261 319 self.disable_smearer.SetValue(True) 262 320 … … 277 335 self.Npts_fit.SetToolTipString(\ 278 336 " Npts : number of points selected for fitting") 279 self.Npts_total = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 337 self.Npts_total = self.ModelTextCtrl(self, -1, 338 size=(_BOX_WIDTH, 20), 280 339 style=wx.TE_PROCESS_ENTER, 281 340 text_enter_callback=self._onQrangeEnter) … … 326 385 smear_message_new_ssmear, style=wx.ALIGN_LEFT) 327 386 self.smear_message_new_p = wx.StaticText(self, -1, 328 smear_message_new_psmear , style=wx.ALIGN_LEFT) 329 self.smear_description_2d_x = wx.StaticText(self, -1, smear_message_2d_x_title , style=wx.ALIGN_LEFT) 330 self.smear_description_2d_x.SetToolTipString(" dQp(parallel) in q_r direction.") 331 self.smear_description_2d_y = wx.StaticText(self, -1, smear_message_2d_y_title , style=wx.ALIGN_LEFT) 332 self.smear_description_2d_y.SetToolTipString(" dQs(perpendicular) in q_phi direction.") 333 self.smear_description_pin_min = wx.StaticText(self, -1, smear_message_pinhole_min_title , style=wx.ALIGN_LEFT) 334 self.smear_description_pin_max = wx.StaticText(self, -1, smear_message_pinhole_max_title , style=wx.ALIGN_LEFT) 335 self.smear_description_slit_height = wx.StaticText(self, -1, smear_message_slit_height_title , style=wx.ALIGN_LEFT) 336 self.smear_description_slit_width = wx.StaticText(self, -1, smear_message_slit_width_title , style=wx.ALIGN_LEFT) 387 smear_message_new_psmear , style=wx.ALIGN_LEFT) 388 self.smear_description_2d_x = wx.StaticText(self, -1, 389 smear_message_2d_x_title , style=wx.ALIGN_LEFT) 390 self.smear_description_2d_x.SetToolTipString(\ 391 " dQp(parallel) in q_r direction.") 392 self.smear_description_2d_y = wx.StaticText(self, -1, 393 smear_message_2d_y_title , style=wx.ALIGN_LEFT) 394 self.smear_description_2d_y.SetToolTipString(\ 395 " dQs(perpendicular) in q_phi direction.") 396 self.smear_description_pin_min = wx.StaticText(self, -1, 397 smear_message_pinhole_min_title , style=wx.ALIGN_LEFT) 398 self.smear_description_pin_max = wx.StaticText(self, -1, 399 smear_message_pinhole_max_title , style=wx.ALIGN_LEFT) 400 self.smear_description_slit_height = wx.StaticText(self, -1, 401 smear_message_slit_height_title , style=wx.ALIGN_LEFT) 402 self.smear_description_slit_width = wx.StaticText(self, -1, 403 smear_message_slit_width_title , style=wx.ALIGN_LEFT) 337 404 338 405 #arrange sizers … … 340 407 self.sizer_set_smearer.Add(sizer_smearer ) 341 408 self.sizer_set_smearer.Add((10,10)) 342 self.sizer_set_smearer.Add( self.smear_description_none,0, wx.CENTER, 10 ) 343 self.sizer_set_smearer.Add( self.smear_description_dqdata,0, wx.CENTER, 10 ) 344 self.sizer_set_smearer.Add( self.smear_description_2d,0, wx.CENTER, 10 ) 345 self.sizer_new_smear.Add( self.smear_description_type,0, wx.CENTER, 10 ) 346 self.sizer_new_smear.Add( self.smear_description_accuracy_type,0, wx.CENTER, 10 ) 409 self.sizer_set_smearer.Add( self.smear_description_none, 410 0, wx.CENTER, 10 ) 411 self.sizer_set_smearer.Add( self.smear_description_dqdata, 412 0, wx.CENTER, 10 ) 413 self.sizer_set_smearer.Add( self.smear_description_2d, 414 0, wx.CENTER, 10 ) 415 self.sizer_new_smear.Add( self.smear_description_type, 416 0, wx.CENTER, 10 ) 417 self.sizer_new_smear.Add( self.smear_description_accuracy_type, 418 0, wx.CENTER, 10 ) 347 419 self.sizer_new_smear.Add( self.smear_accuracy ) 348 self.sizer_new_smear.Add( self.smear_description_smear_type,0, wx.CENTER, 10 ) 420 self.sizer_new_smear.Add( self.smear_description_smear_type, 421 0, wx.CENTER, 10 ) 349 422 self.sizer_new_smear.Add((15,-1)) 350 self.sizer_new_smear.Add( self.smear_description_2d_x,0, wx.CENTER, 10 ) 351 self.sizer_new_smear.Add( self.smear_description_pin_min,0, wx.CENTER, 10 ) 352 self.sizer_new_smear.Add( self.smear_description_slit_height,0, wx.CENTER, 10 ) 353 354 self.sizer_new_smear.Add( self.smear_pinhole_min,0, wx.CENTER, 10 ) 355 self.sizer_new_smear.Add( self.smear_slit_height,0, wx.CENTER, 10 ) 356 self.sizer_new_smear.Add( self.smear_data_left,0, wx.CENTER, 10 ) 423 self.sizer_new_smear.Add( self.smear_description_2d_x, 424 0, wx.CENTER, 10 ) 425 self.sizer_new_smear.Add( self.smear_description_pin_min, 426 0, wx.CENTER, 10 ) 427 self.sizer_new_smear.Add( self.smear_description_slit_height, 428 0, wx.CENTER, 10 ) 429 430 self.sizer_new_smear.Add( self.smear_pinhole_min, 431 0, wx.CENTER, 10 ) 432 self.sizer_new_smear.Add( self.smear_slit_height, 433 0, wx.CENTER, 10 ) 434 self.sizer_new_smear.Add( self.smear_data_left, 435 0, wx.CENTER, 10 ) 357 436 self.sizer_new_smear.Add((20,-1)) 358 self.sizer_new_smear.Add( self.smear_description_2d_y,0, wx.CENTER, 10 ) 359 self.sizer_new_smear.Add( self.smear_description_pin_max,0, wx.CENTER, 10 ) 360 self.sizer_new_smear.Add( self.smear_description_slit_width,0, wx.CENTER, 10 ) 437 self.sizer_new_smear.Add( self.smear_description_2d_y, 438 0, wx.CENTER, 10 ) 439 self.sizer_new_smear.Add( self.smear_description_pin_max, 440 0, wx.CENTER, 10 ) 441 self.sizer_new_smear.Add( self.smear_description_slit_width, 442 0, wx.CENTER, 10 ) 361 443 362 444 self.sizer_new_smear.Add( self.smear_pinhole_max,0, wx.CENTER, 10 ) … … 370 452 371 453 # add all to chi2 sizer 372 sizer_smearer_box.Add(self.sizer_set_smearer) 454 sizer_smearer_box.Add(self.sizer_set_smearer) 373 455 sizer_chi2.Add(sizer_smearer_box) 456 sizer_chi2.Add((-1,5)) 457 sizer_chi2.Add(weighting_box) 374 458 sizer_chi2.Add((-1,5)) 375 459 … … 1024 1108 self._manager._reset_schedule_problem(value=0, uid=self.uid) 1025 1109 self._manager.schedule_for_fit(uid=self.uid,value=1) 1110 self._manager.set_fit_weight(uid=self.uid, 1111 weight=self.get_weight(), 1112 is2d = self.is_2D) 1026 1113 self._manager.set_fit_range(uid=self.uid,qmin=self.qmin_x, 1027 1114 qmax=self.qmax_x) … … 1031 1118 self.bind_fit_button() 1032 1119 1033 1120 def get_weight(self): 1121 """ 1122 Get weighting dI data 1123 """ 1124 button_list = [self.dI_noweight, 1125 self.dI_didata, 1126 self.dI_sqrdata, 1127 self.dI_idata] 1128 if self.is_2D: 1129 dy_data = self.data.err_data 1130 data = self.data.data 1131 else: 1132 dy_data = self.data.dy 1133 data = self.data.y 1134 dy = dy_data 1135 for item in button_list: 1136 if item.GetValue(): 1137 if button_list.index(item) == 0: 1138 dy = numpy.ones_like(dy_data) 1139 elif button_list.index(item) == 1: 1140 dy = dy_data 1141 elif button_list.index(item) == 2: 1142 dy = numpy.sqrt(data) 1143 elif button_list.index(item) == 3: 1144 dy = data 1145 break 1146 return dy 1147 1034 1148 def bind_fit_button(self): 1035 1149 """ … … 1735 1849 self.pinhole_smearer.Enable(True) 1736 1850 self.default_mask = copy.deepcopy(self.data.mask) 1851 if self.data.err_data == None or\ 1852 (self.data.err_data == 1).all() or\ 1853 (self.data.err_data == 0).all(): 1854 self.dI_didata.Enable(False) 1855 self.dI_noweight.SetValue(True) 1856 self.weightbt_string = self.dI_noweight.GetLabelText() 1857 else: 1858 self.dI_didata.Enable(True) 1859 self.dI_didata.SetValue(True) 1860 self.weightbt_string = self.dI_didata.GetLabelText() 1737 1861 else: 1738 1862 self.slit_smearer.Enable(True) 1739 self.pinhole_smearer.Enable(True) 1740 1863 self.pinhole_smearer.Enable(True) 1864 if self.data.dy == None or\ 1865 (self.data.dy == 1).all() or\ 1866 (self.data.dy == 0).all(): 1867 self.dI_didata.Enable(False) 1868 self.dI_noweight.SetValue(True) 1869 self.weightbt_string = self.dI_noweight.GetLabelText() 1870 else: 1871 self.dI_didata.Enable(True) 1872 self.dI_didata.SetValue(True) 1873 self.weightbt_string = self.dI_didata.GetLabelText() 1874 # Enable weighting radio uttons 1875 self.dI_noweight.Enable(True) 1876 self.dI_sqrdata.Enable(True) 1877 self.dI_idata.Enable(True) 1878 1741 1879 self.formfactorbox.Enable() 1742 1880 self.structurebox.Enable() … … 2010 2148 #msg = "Fit completed!dddd " 2011 2149 #wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 2012 2150 2151 def onWeighting(self, event): 2152 """ 2153 On Weighting radio button event, sets the weightbt_string 2154 """ 2155 self.weightbt_string = event.GetEventObject().GetLabelText() 2156 2013 2157 def onPinholeSmear(self, event): 2014 2158 """ -
fittingview/src/sans/perspectives/fitting/fitpanel.py
raefc09f r55bb249c 326 326 if self.batch_on: 327 327 self.batch_page_index += 1 328 caption = "BatchPage 328 caption = "BatchPage" + str(self.batch_page_index) 329 329 panel.set_index_model(self.batch_page_index) 330 330 else: 331 331 #Increment index of fit page 332 332 self.fit_page_index += 1 333 caption = "FitPage 333 caption = "FitPage" + str(self.fit_page_index) 334 334 panel.set_index_model(self.fit_page_index) 335 335 panel.populate_box(dict=self.model_list_box) -
fittingview/src/sans/perspectives/fitting/fitproblem.py
r3e3ab46 r55bb249c 87 87 """ 88 88 :return: fitting range 89 """ 90 def set_weight(self, weight=None): 91 """ 92 set fitting range 93 """ 94 def get_weight(self): 95 """ 96 get fitting weight 89 97 """ 90 98 def clear_model_param(self): … … 257 265 self[d.id].set_model(self.model) 258 266 self[d.id].set_range(self.qmin, self.qmax) 259 267 #self[d.id].set_smearer(self[d.id].get_smearer()) 260 268 def get_fit_data(self, fid): 261 269 """ … … 322 330 return self[fid].get_range() 323 331 324 332 def set_weight(self, weight, is2d, fid=None): 333 """ 334 fit weight 335 """ 336 if fid is None: 337 for value in self.itervalues(): 338 value.set_weight(weight, is2d) 339 else: 340 if fid in self.iterkeys(): 341 self[fid].value.set_weight(weight, is2d) 342 343 def get_weight(self, fid=None): 344 """ 345 return fit weight 346 """ 347 if fid in self.iterkeys(): 348 return self[fid].get_weight() 349 325 350 def clear_model_param(self, fid=None): 326 351 """ … … 381 406 self.qmin = None 382 407 self.qmax = None 408 # fit weight 409 self.weight = None 383 410 384 411 … … 459 486 :param data: list of data selected 460 487 """ 461 self.fit_data = data488 self.fit_data = copy.deepcopy(data) 462 489 463 490 def get_fit_data(self): … … 467 494 return self.fit_data 468 495 496 def set_weight(self, weight, is2d): 497 """ 498 Set weight array 499 """ 500 self.weight = weight 501 if is2d: 502 self.fit_data.err_data = self.weight 503 else: 504 self.fit_data.dy = self.weight 505 506 def get_weight(self): 507 """ 508 returns weight array 509 """ 510 return self.weight 511 469 512 def set_model_param(self,name,value=None): 470 513 """ -
fittingview/src/sans/perspectives/fitting/fitting.py
r53cf669 r55bb249c 69 69 self.fit_thread_list = {} 70 70 self.residuals = None 71 self.weight = None 71 72 self.fit_panel = None 72 73 # Start with a good default … … 430 431 """ 431 432 self.state_reader.write(filename=filepath, fitstate=fitstate) 432 433 434 def set_fit_weight(self, uid, weight, is2d=False, fid=None): 435 """ 436 Set the fit weights of a given page for all 437 its data by default. If fid is provide then set the range 438 only for the data with fid as id 439 :param uid: id corresponding to a fit page 440 :param fid: id corresponding to a fit problem (data, model) 441 :param weight: current dy data 442 """ 443 if uid in self.page_finder.keys(): 444 self.page_finder[uid].set_weight(weight=weight, is2d=is2d) 445 433 446 def set_fit_range(self, uid, qmin, qmax, fid=None): 434 447 """ … … 582 595 self.draw_model(model=model, data=data, page_id=uid, smearer=smear, 583 596 enable1D=enable1D, enable2D=enable2D, 584 qmin=qmin, qmax=qmax )597 qmin=qmin, qmax=qmax, weight=None) 585 598 self._mac_sleep(0.2) 586 599 … … 597 610 toggle_mode_on=False, 598 611 qmin=None, qmax=None, 599 update_chisqr=True ):612 update_chisqr=True, weight=None): 600 613 """ 601 614 Draw model. … … 613 626 614 627 """ 628 self.weight = weight 615 629 if issubclass(data.__class__, Data1D) or not enable2D: 616 630 ## draw model 1D with no loaded data … … 1429 1443 instead of calling expansive CalcChisqr in guithread 1430 1444 """ 1445 data = deepcopy(data) 1446 1431 1447 # default chisqr 1432 1448 chisqr = None … … 1440 1456 if index == None: 1441 1457 index = numpy.ones(len(data.data),ntype=bool) 1458 if self.weight != None: 1459 data.err_data = self.weight 1442 1460 # get rid of zero error points 1443 1461 index = index & (data.err_data != 0) … … 1451 1469 if index == None: 1452 1470 index = numpy.ones(len(data.y), ntype=bool) 1471 if self.weight != None: 1472 data.dy = self.weight 1453 1473 if data.dy == None or data.dy == []: 1454 1474 dy = numpy.ones(len(data.y)) … … 1468 1488 chisqr = numpy.average(residuals * residuals) 1469 1489 self._plot_residuals(page_id, data, index) 1490 #reset weight 1491 self.weight = None 1470 1492 return chisqr 1471 1493 -
fittingview/src/sans/perspectives/fitting/pagestate.py
rc21e87b r55bb249c 54 54 ["enable_disp","enable_disp","bool"], 55 55 ["disable_disp","disable_disp","bool"], 56 ["slit_smearer","slit_smearer","bool"], 56 ["dI_noweight","dI_noweight","bool"], 57 ["dI_didata","dI_didata","bool"], 58 ["dI_sqrdata","dI_sqrdata","bool"], 59 ["dI_idata","dI_idata","bool"], 57 60 ["enable2D","enable2D","bool"], 58 61 ["cb1","cb1","bool"], 59 62 ["tcChi","tcChi","float"], 60 ["smearer", "smearer", "float"],61 ["smear_type","smear_type", "string"],62 ["dq_l", "dq_l", "string"],63 ["dq_r","dq_r", "string"]]63 ["smearer", "smearer", "float"], 64 ["smear_type","smear_type", "string"], 65 ["dq_l", "dq_l", "string"], 66 ["dq_r","dq_r", "string"]] 64 67 65 68 list_of_model_attributes = [["values", "values"], … … 242 245 self.pinhole_smearer = False 243 246 self.slit_smearer = False 247 # weighting options 248 self.dI_noweight = False 249 self.dI_didata = True 250 self.dI_sqrdata = False 251 self.dI_idata = False 244 252 ## disperity selection 245 253 self.enable_disp = False … … 309 317 obj.slit_smearer = copy.deepcopy(self.slit_smearer) 310 318 obj.smear_type = copy.deepcopy(self.smear_type) 319 obj.dI_noweight = copy.deepcopy(self.dI_noweight) 320 obj.dI_didata = copy.deepcopy(self.dI_didata) 321 obj.dI_sqrdata = copy.deepcopy(self.dI_sqrdata) 322 obj.dI_idata = copy.deepcopy(self.dI_idata) 311 323 obj.dq_l = copy.deepcopy(self.dq_l) 312 324 obj.dq_r = copy.deepcopy(self.dq_r) … … 373 385 rep += "Dispersity disable : %s\n"%str(self.disable_disp) 374 386 rep += "Slit smearer enable: %s\n"%str(self.slit_smearer) 387 388 rep += "dI_noweight : %s\n"%str(self.dI_noweight) 389 rep += "dI_didata : %s\n"%str(self.dI_didata) 390 rep += "dI_sqrdata : %s\n"%str(self.dI_sqrdata) 391 rep += "dI_idata : %s\n"%str(self.dI_idata) 392 393 375 394 rep += "2D enable : %s\n"%str(self.enable2D) 376 395 rep += "All parameters checkbox selected: %s\n"%(self.cb1)
Note: See TracChangeset
for help on using the changeset viewer.