Ignore:
Timestamp:
Sep 5, 2018 10:53:00 AM (6 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
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)
Message:

processEvents() helps with proper chart generation. - SASVIEW-890
Fixed weighing in fitting - SASVIEW-1017
Fixed error bars after fitting - SASVIEW-1004

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Perspectives/Fitting/FittingWidget.py

    r5aad7a5 rb764ae5  
    6161 
    6262logger = logging.getLogger(__name__) 
    63  
    6463 
    6564class ToolTippedItemModel(QtGui.QStandardItemModel): 
     
    528527        # Signals from separate tabs asking for replot 
    529528        self.options_widget.plot_signal.connect(self.onOptionsUpdate) 
    530         self.options_widget.plot_signal.connect(self.onOptionsUpdate) 
    531529 
    532530        # Signals from other widgets 
     
    15091507            raise ValueError('Fitting requires at least one parameter to optimize.') 
    15101508 
    1511         # Potential smearing added 
    1512         # Remember that smearing_min/max can be None -> 
    1513         # deal with it until Python gets discriminated unions 
    1514         self.addWeightingToData(data) 
    1515  
    15161509        # Get the constraints. 
    15171510        constraints = self.getComplexConstraintsForModel() 
     
    15301523            data = GuiUtils.dataFromItem(fit_index) 
    15311524            # Potential weights added directly to data 
    1532             self.addWeightingToData(data) 
     1525            weighted_data = self.addWeightingToData(data) 
    15331526            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, 
    15351528                             constraints=constraints) 
    15361529            except ValueError as ex: 
    15371530                raise ValueError("Setting model parameters failed with: %s" % ex) 
    15381531 
    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, 
    15411534                            qmax=qmax) 
    15421535            fitter_single.select_problem_for_fit(id=fit_id, value=1) 
     
    19291922        Adds weighting contribution to fitting data 
    19301923        """ 
     1924        new_data = copy.deepcopy(data) 
    19311925        # Send original data for weighting 
    19321926        weight = FittingUtilities.getWeight(data=data, is2d=self.is2D, flag=self.weighting) 
    19331927        if self.is2D: 
    1934             data.err_data = weight 
     1928            new_data.err_data = weight 
    19351929        else: 
    1936             data.dy = weight 
    1937         pass 
     1930            new_data.dy = weight 
     1931 
     1932        return new_data 
    19381933 
    19391934    def updateQRange(self): 
     
    22482243            completefn = self.methodCompleteForData() 
    22492244        smearer = self.smearing_widget.smearer() 
     2245        weight = FittingUtilities.getWeight(data=data, is2d=self.is2D, flag=self.weighting) 
     2246 
    22502247        # Awful API to a backend method. 
    22512248        calc_thread = self.methodCalculateForData()(data=data, 
     
    22562253                                               smearer=smearer, 
    22572254                                               state=None, 
    2258                                                weight=None, 
     2255                                               weight=weight, 
    22592256                                               fid=None, 
    22602257                                               toggle_mode_on=False, 
     
    23442341 
    23452342        # 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) 
    23492346        # 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) 
    23512348        # Update the control 
    23522349        chi2_repr = "---" if self.chi2 is None else GuiUtils.formatNumber(self.chi2, high=True) 
    23532350        self.lblChi2Value.setText(chi2_repr) 
    23542351 
    2355         # self.communicate.plotUpdateSignal.emit([fitted_data]) 
    2356  
    23572352        # Plot residuals if actual data 
    23582353        if not self.data_is_loaded: 
    23592354            return 
    23602355 
    2361         residuals_plot = FittingUtilities.plotResiduals(self.data, fitted_data) 
     2356        residuals_plot = FittingUtilities.plotResiduals(self.data, weighted_data) 
    23622357        residuals_plot.id = "Residual " + residuals_plot.id 
    23632358        self.createNewIndex(residuals_plot) 
Note: See TracChangeset for help on using the changeset viewer.