Changeset b764ae5 in sasview for src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
- Timestamp:
- Sep 5, 2018 10:53:00 AM (6 years ago)
- Branches:
- ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- 444c221c
- Parents:
- f6c19cf
- git-author:
- Piotr Rozyczko <rozyczko@…> (09/05/18 10:48:38)
- git-committer:
- Piotr Rozyczko <rozyczko@…> (09/05/18 10:53:00)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
r5aad7a5 rb764ae5 61 61 62 62 logger = logging.getLogger(__name__) 63 64 63 65 64 class ToolTippedItemModel(QtGui.QStandardItemModel): … … 528 527 # Signals from separate tabs asking for replot 529 528 self.options_widget.plot_signal.connect(self.onOptionsUpdate) 530 self.options_widget.plot_signal.connect(self.onOptionsUpdate)531 529 532 530 # Signals from other widgets … … 1509 1507 raise ValueError('Fitting requires at least one parameter to optimize.') 1510 1508 1511 # Potential smearing added1512 # Remember that smearing_min/max can be None ->1513 # deal with it until Python gets discriminated unions1514 self.addWeightingToData(data)1515 1516 1509 # Get the constraints. 1517 1510 constraints = self.getComplexConstraintsForModel() … … 1530 1523 data = GuiUtils.dataFromItem(fit_index) 1531 1524 # Potential weights added directly to data 1532 self.addWeightingToData(data)1525 weighted_data = self.addWeightingToData(data) 1533 1526 try: 1534 fitter_single.set_model(model, fit_id, params_to_fit, data= data,1527 fitter_single.set_model(model, fit_id, params_to_fit, data=weighted_data, 1535 1528 constraints=constraints) 1536 1529 except ValueError as ex: 1537 1530 raise ValueError("Setting model parameters failed with: %s" % ex) 1538 1531 1539 qmin, qmax, _ = self.logic.computeRangeFromData( data)1540 fitter_single.set_data(data= data, id=fit_id, smearer=smearer, qmin=qmin,1532 qmin, qmax, _ = self.logic.computeRangeFromData(weighted_data) 1533 fitter_single.set_data(data=weighted_data, id=fit_id, smearer=smearer, qmin=qmin, 1541 1534 qmax=qmax) 1542 1535 fitter_single.select_problem_for_fit(id=fit_id, value=1) … … 1929 1922 Adds weighting contribution to fitting data 1930 1923 """ 1924 new_data = copy.deepcopy(data) 1931 1925 # Send original data for weighting 1932 1926 weight = FittingUtilities.getWeight(data=data, is2d=self.is2D, flag=self.weighting) 1933 1927 if self.is2D: 1934 data.err_data = weight1928 new_data.err_data = weight 1935 1929 else: 1936 data.dy = weight 1937 pass 1930 new_data.dy = weight 1931 1932 return new_data 1938 1933 1939 1934 def updateQRange(self): … … 2248 2243 completefn = self.methodCompleteForData() 2249 2244 smearer = self.smearing_widget.smearer() 2245 weight = FittingUtilities.getWeight(data=data, is2d=self.is2D, flag=self.weighting) 2246 2250 2247 # Awful API to a backend method. 2251 2248 calc_thread = self.methodCalculateForData()(data=data, … … 2256 2253 smearer=smearer, 2257 2254 state=None, 2258 weight= None,2255 weight=weight, 2259 2256 fid=None, 2260 2257 toggle_mode_on=False, … … 2344 2341 2345 2342 # Modify fitted_data with weighting 2346 self.addWeightingToData(fitted_data)2347 2348 self.createNewIndex( fitted_data)2343 weighted_data = self.addWeightingToData(fitted_data) 2344 2345 self.createNewIndex(weighted_data) 2349 2346 # Calculate difference between return_data and logic.data 2350 self.chi2 = FittingUtilities.calculateChi2( fitted_data, self.logic.data)2347 self.chi2 = FittingUtilities.calculateChi2(weighted_data, self.logic.data) 2351 2348 # Update the control 2352 2349 chi2_repr = "---" if self.chi2 is None else GuiUtils.formatNumber(self.chi2, high=True) 2353 2350 self.lblChi2Value.setText(chi2_repr) 2354 2351 2355 # self.communicate.plotUpdateSignal.emit([fitted_data])2356 2357 2352 # Plot residuals if actual data 2358 2353 if not self.data_is_loaded: 2359 2354 return 2360 2355 2361 residuals_plot = FittingUtilities.plotResiduals(self.data, fitted_data)2356 residuals_plot = FittingUtilities.plotResiduals(self.data, weighted_data) 2362 2357 residuals_plot.id = "Residual " + residuals_plot.id 2363 2358 self.createNewIndex(residuals_plot)
Note: See TracChangeset
for help on using the changeset viewer.