Ignore:
Timestamp:
Sep 7, 2018 11:09:07 AM (6 years ago)
Author:
Torin Cooper-Bennun <torin.cooper-bennun@…>
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:
5181e9b
Parents:
9ba91b7 (diff), f0365a2e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'ESS_GUI' into ESS_GUI_iss1033

File:
1 edited

Legend:

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

    r9ba91b7 r254199c  
    15071507        # update charts 
    15081508        self.onPlot() 
     1509        #self.recalculatePlotData() 
     1510 
    15091511 
    15101512        # Read only value - we can get away by just printing it here 
     
    15941596            param_repr = GuiUtils.formatNumber(param_dict[param_name][0], high=True) 
    15951597            self._model_model.item(row, 1).setText(param_repr) 
     1598            self.kernel_module.setParam(param_name, param_dict[param_name][0]) 
    15961599            if self.has_error_column: 
    15971600                error_repr = GuiUtils.formatNumber(param_dict[param_name][1], high=True) 
     
    16351638            poly_item.insertColumn(2, [QtGui.QStandardItem("")]) 
    16361639 
    1637         # block signals temporarily, so we don't end up 
    1638         # updating charts with every single model change on the end of fitting 
    1639         self._model_model.blockSignals(True) 
    1640  
    16411640        if not self.has_error_column: 
    16421641            # create top-level error column 
     
    16451644            self.iterateOverModel(createErrorColumn) 
    16461645 
    1647             # we need to enable signals for this, otherwise the final column mysteriously disappears (don't ask, I don't 
    1648             # know) 
    1649             self._model_model.blockSignals(False) 
    16501646            self._model_model.insertColumn(2, error_column) 
    1651             self._model_model.blockSignals(True) 
    16521647 
    16531648            FittingUtilities.addErrorHeadersToModel(self._model_model) 
     
    16581653            self.has_error_column = True 
    16591654 
     1655        # block signals temporarily, so we don't end up 
     1656        # updating charts with every single model change on the end of fitting 
     1657        self._model_model.itemChanged.disconnect() 
    16601658        self.iterateOverModel(updateFittedValues) 
    16611659        self.iterateOverModel(updatePolyValues) 
    1662  
    1663         self._model_model.blockSignals(False) 
     1660        self._model_model.itemChanged.connect(self.onMainParamsChange) 
    16641661 
    16651662        # Adjust the table cells width. 
     
    16961693            param_repr = GuiUtils.formatNumber(param_dict[param_name][0], high=True) 
    16971694            self._poly_model.item(row_i, 1).setText(param_repr) 
     1695            self.kernel_module.setParam(param_name, param_dict[param_name][0]) 
    16981696            if self.has_poly_error_column: 
    16991697                error_repr = GuiUtils.formatNumber(param_dict[param_name][1], high=True) 
    17001698                self._poly_model.item(row_i, 2).setText(error_repr) 
    1701  
    17021699 
    17031700        def createErrorColumn(row_i): 
     
    17201717        # block signals temporarily, so we don't end up 
    17211718        # updating charts with every single model change on the end of fitting 
    1722         self._poly_model.blockSignals(True) 
     1719        self._poly_model.itemChanged.disconnect() 
    17231720        self.iterateOverPolyModel(updateFittedValues) 
    1724         self._poly_model.blockSignals(False) 
     1721        self._poly_model.itemChanged.connect(self.onPolyModelChange) 
    17251722 
    17261723        if self.has_poly_error_column: 
     
    17321729 
    17331730        # switch off reponse to model change 
    1734         self._poly_model.blockSignals(True) 
    17351731        self._poly_model.insertColumn(2, error_column) 
    1736         self._poly_model.blockSignals(False) 
    17371732        FittingUtilities.addErrorPolyHeadersToModel(self._poly_model) 
    17381733 
     
    17671762            param_repr = GuiUtils.formatNumber(param_dict[param_name][0], high=True) 
    17681763            self._magnet_model.item(row, 1).setText(param_repr) 
     1764            self.kernel_module.setParam(param_name, param_dict[param_name][0]) 
    17691765            if self.has_magnet_error_column: 
    17701766                error_repr = GuiUtils.formatNumber(param_dict[param_name][1], high=True) 
     
    17861782        # block signals temporarily, so we don't end up 
    17871783        # updating charts with every single model change on the end of fitting 
    1788         self._magnet_model.blockSignals(True) 
     1784        self._magnet_model.itemChanged.disconnect() 
    17891785        self.iterateOverMagnetModel(updateFittedValues) 
    1790         self._magnet_model.blockSignals(False) 
     1786        self._magnet_model.itemChanged.connect(self.onMagnetModelChange) 
    17911787 
    17921788        if self.has_magnet_error_column: 
     
    17981794 
    17991795        # switch off reponse to model change 
    1800         self._magnet_model.blockSignals(True) 
    18011796        self._magnet_model.insertColumn(2, error_column) 
    1802         self._magnet_model.blockSignals(False) 
    18031797        FittingUtilities.addErrorHeadersToModel(self._magnet_model) 
    18041798 
     
    18121806        self.cmdPlot.setText("Show Plot") 
    18131807        # Force data recalculation so existing charts are updated 
     1808        self.showPlot() 
    18141809        self.recalculatePlotData() 
    1815         self.showPlot() 
    18161810 
    18171811    def onSmearingOptionsUpdate(self): 
     
    20792073        self.shell_names = self.shellNamesList() 
    20802074 
    2081         # Get new rows for QModel 
    2082         new_rows = FittingUtilities.addParametersToModel(self.model_parameters, self.kernel_module, self.is2D) 
    2083  
    20842075        # Add heading row 
    20852076        FittingUtilities.addHeadingRowToModel(self._model_model, model_name) 
    20862077 
    2087         # Update QModel 
    2088         for row in new_rows: 
    2089             self._model_model.appendRow(row) 
     2078        # Update the QModel 
     2079        FittingUtilities.addParametersToModel( 
     2080                self.model_parameters, 
     2081                self.kernel_module, 
     2082                self.is2D, 
     2083                self._model_model, 
     2084                self.lstParams) 
    20902085 
    20912086    def fromStructureFactorToQModel(self, structure_factor): 
     
    20962091            return 
    20972092 
    2098         s_kernel = self.models[structure_factor]() 
    2099         p_kernel = self.kernel_module 
    2100  
    2101         if p_kernel is None: 
    2102             # Not a product model, just S(Q) 
    2103             self.kernel_module = s_kernel 
    2104             params = modelinfo.ParameterTable(self.kernel_module._model_info.parameters.kernel_parameters) 
    2105             new_rows = FittingUtilities.addSimpleParametersToModel(params, self.is2D) 
     2093        if self.kernel_module is None: 
     2094            # Structure factor is the only selected model; build it and show all its params 
     2095            self.kernel_module = self.models[structure_factor]() 
     2096            s_params = self.kernel_module._model_info.parameters 
     2097            s_params_orig = s_params 
     2098 
    21062099        else: 
     2100            s_kernel = self.models[structure_factor]() 
     2101            p_kernel = self.kernel_module 
     2102 
    21072103            p_pars_len = len(p_kernel._model_info.parameters.kernel_parameters) 
    21082104            s_pars_len = len(s_kernel._model_info.parameters.kernel_parameters) 
     
    21132109 
    21142110            # S(Q) params from the product model are not necessarily the same as those from the S(Q) model; any 
    2115             # conflicting names with P(Q) params will cause a rename; we also lose radius_effective (for now...) 
    2116  
    2117             # TODO: merge rest of beta approx implementation in 
    2118             # This is to ensure compatibility when we merge beta approx support in...! 
    2119  
    2120             # radius_effective is always s_params[0] 
    2121  
    2122             # if radius_effective_mode is in all_params, then all_params contains radius_effective and we want to 
    2123             # keep it in the model 
    2124  
    2125             # if radius_effective_mode is NOT in all_params, then radius_effective should NOT be kept, because the user 
    2126             # cannot specify it themselves; but, make sure we only remove it if it's actually there in the first place 
    2127             # (sasmodels master removes it already) 
     2111            # conflicting names with P(Q) params will cause a rename 
     2112 
    21282113            if "radius_effective_mode" in all_param_names: 
    21292114                # Show all parameters 
     
    21382123                    s_params = modelinfo.ParameterTable(all_params[p_pars_len:p_pars_len+s_pars_len-1]) 
    21392124 
    2140             # Get new rows for QModel 
    2141             # Any renamed parameters are stored as data in the relevant item, for later handling 
    2142             new_rows = FittingUtilities.addSimpleParametersToModel(s_params, self.is2D, s_params_orig) 
    2143  
    2144             # TODO: merge rest of beta approx implementation in 
    2145             # These parameters are not part of P(Q) nor S(Q), but are added only to the product model (e.g. specifying 
    2146             # structure factor calculation mode) 
    2147             # product_params = all_params[p_pars_len+s_pars_len:] 
    2148  
    21492125        # Add heading row 
    21502126        FittingUtilities.addHeadingRowToModel(self._model_model, structure_factor) 
    21512127 
    2152         # Update QModel 
    2153         for row in new_rows: 
    2154             self._model_model.appendRow(row) 
    2155             # disable fitting of parameters not listed in self.kernel_module (probably radius_effective) 
    2156             # if row[0].text() not in self.kernel_module.params.keys(): 
    2157             #     row_num = self._model_model.rowCount() - 1 
    2158             #     FittingUtilities.markParameterDisabled(self._model_model, row_num) 
     2128        # Get new rows for QModel 
     2129        # Any renamed parameters are stored as data in the relevant item, for later handling 
     2130        FittingUtilities.addSimpleParametersToModel( 
     2131                s_params, 
     2132                self.is2D, 
     2133                s_params_orig, 
     2134                self._model_model, 
     2135                self.lstParams) 
    21592136 
    21602137    def haveParamsToFit(self): 
     
    28132790            self._model_model.removeRows(first_row, remove_rows) 
    28142791 
    2815         new_rows = FittingUtilities.addShellsToModel(self.model_parameters, self._model_model, index, first_row) 
     2792        new_rows = FittingUtilities.addShellsToModel( 
     2793                self.model_parameters, 
     2794                self._model_model, 
     2795                index, 
     2796                first_row, 
     2797                self.lstParams) 
     2798 
    28162799        self._num_shell_params = len(new_rows) 
    2817  
    28182800        self.current_shell_displayed = index 
    28192801 
Note: See TracChangeset for help on using the changeset viewer.