Ignore:
Timestamp:
Apr 19, 2017 7:07:46 AM (7 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
Branches:
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
Children:
e1e3e09
Parents:
cd2cc745
Message:

Added data weighting prototype

File:
1 edited

Legend:

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

    r83eb5208 r9d266d2  
    2525from sas.sasgui.perspectives.fitting.model_thread import Calc1D 
    2626from sas.sasgui.perspectives.fitting.model_thread import Calc2D 
     27from sas.sasgui.perspectives.fitting.utils import get_weight 
    2728 
    2829from UI.FittingWidgetUI import Ui_FittingWidgetUI 
     
    6768        # Parameters to fit 
    6869        self.parameters_to_fit = None 
     70        # Weight radio box group 
     71        self.weightingGroup = QtGui.QButtonGroup() 
    6972 
    7073        # Which tab is this widget displayed in? 
     
    231234        self.tabFitting.setTabEnabled(TAB_MAGNETISM, False) 
    232235        self.lblChi2Value.setText("---") 
    233         # group boxes 
     236        # Group boxes 
    234237        self.boxWeighting.setEnabled(False) 
    235238        self.cmdMaskEdit.setEnabled(False) 
     239        # Button groups 
     240        self.weightingGroup.addButton(self.rbWeighting1) 
     241        self.weightingGroup.addButton(self.rbWeighting2) 
     242        self.weightingGroup.addButton(self.rbWeighting3) 
     243        self.weightingGroup.addButton(self.rbWeighting4) 
    236244 
    237245    def initializeSignals(self): 
     
    260268        self.txtSmearUp.editingFinished.connect(self.onSmearUp) 
    261269        self.txtSmearDown.editingFinished.connect(self.onSmearDown) 
     270        # Button groups 
     271        self.weightingGroup.buttonClicked.connect(self.onWeightingChoice) 
    262272 
    263273        # Respond to change in parameters from the UI 
     
    353363        """ 
    354364        pass 
     365 
     366    def onWeightingChoice(self, button): 
     367        """ 
     368        Update weighting in the fit state 
     369        """ 
     370        button_id = button.group().checkedId() 
     371        button_id = abs(button_id + 2) 
     372        #self.fitPage.weighting = button_id 
     373        print button_id 
    355374 
    356375    def onPolyModelChange(self, item): 
     
    401420        params_to_fit = self.parameters_to_fit 
    402421 
     422        # Potential weights added 
     423        self.addWeightingToData(data) 
     424 
    403425        # These should be updating somehow? 
    404426        fit_id = 0 
     
    688710        checked_list = ['scale', '1.0', '0.0', 'inf', ''] 
    689711        FittingUtilities.addCheckedListToModel(model, checked_list) 
     712 
     713    def addWeightingToData(self, data): 
     714        """ 
     715        Adds weighting contribution to fitting data 
     716        """ 
     717        # Check the state of the Weighting radio buttons 
     718        button_id = self.weightingGroup.checkedId() 
     719        button_id = abs(button_id + 2) 
     720        if button_id == 0: 
     721            return 
     722        # Send original data for weighting 
     723        weight = get_weight(data=data, is2d=self.is2D, flag=button_id) 
     724        if self.is2D: 
     725            data.err_data = weight 
     726        else: 
     727            data.dy = weight 
    690728 
    691729    def updateQRange(self): 
Note: See TracChangeset for help on using the changeset viewer.