Changeset 254199c in sasview for src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
- Timestamp:
- Sep 7, 2018 11:09:07 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:
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
r9ba91b7 r254199c 1507 1507 # update charts 1508 1508 self.onPlot() 1509 #self.recalculatePlotData() 1510 1509 1511 1510 1512 # Read only value - we can get away by just printing it here … … 1594 1596 param_repr = GuiUtils.formatNumber(param_dict[param_name][0], high=True) 1595 1597 self._model_model.item(row, 1).setText(param_repr) 1598 self.kernel_module.setParam(param_name, param_dict[param_name][0]) 1596 1599 if self.has_error_column: 1597 1600 error_repr = GuiUtils.formatNumber(param_dict[param_name][1], high=True) … … 1635 1638 poly_item.insertColumn(2, [QtGui.QStandardItem("")]) 1636 1639 1637 # block signals temporarily, so we don't end up1638 # updating charts with every single model change on the end of fitting1639 self._model_model.blockSignals(True)1640 1641 1640 if not self.has_error_column: 1642 1641 # create top-level error column … … 1645 1644 self.iterateOverModel(createErrorColumn) 1646 1645 1647 # we need to enable signals for this, otherwise the final column mysteriously disappears (don't ask, I don't1648 # know)1649 self._model_model.blockSignals(False)1650 1646 self._model_model.insertColumn(2, error_column) 1651 self._model_model.blockSignals(True)1652 1647 1653 1648 FittingUtilities.addErrorHeadersToModel(self._model_model) … … 1658 1653 self.has_error_column = True 1659 1654 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() 1660 1658 self.iterateOverModel(updateFittedValues) 1661 1659 self.iterateOverModel(updatePolyValues) 1662 1663 self._model_model.blockSignals(False) 1660 self._model_model.itemChanged.connect(self.onMainParamsChange) 1664 1661 1665 1662 # Adjust the table cells width. … … 1696 1693 param_repr = GuiUtils.formatNumber(param_dict[param_name][0], high=True) 1697 1694 self._poly_model.item(row_i, 1).setText(param_repr) 1695 self.kernel_module.setParam(param_name, param_dict[param_name][0]) 1698 1696 if self.has_poly_error_column: 1699 1697 error_repr = GuiUtils.formatNumber(param_dict[param_name][1], high=True) 1700 1698 self._poly_model.item(row_i, 2).setText(error_repr) 1701 1702 1699 1703 1700 def createErrorColumn(row_i): … … 1720 1717 # block signals temporarily, so we don't end up 1721 1718 # updating charts with every single model change on the end of fitting 1722 self._poly_model. blockSignals(True)1719 self._poly_model.itemChanged.disconnect() 1723 1720 self.iterateOverPolyModel(updateFittedValues) 1724 self._poly_model. blockSignals(False)1721 self._poly_model.itemChanged.connect(self.onPolyModelChange) 1725 1722 1726 1723 if self.has_poly_error_column: … … 1732 1729 1733 1730 # switch off reponse to model change 1734 self._poly_model.blockSignals(True)1735 1731 self._poly_model.insertColumn(2, error_column) 1736 self._poly_model.blockSignals(False)1737 1732 FittingUtilities.addErrorPolyHeadersToModel(self._poly_model) 1738 1733 … … 1767 1762 param_repr = GuiUtils.formatNumber(param_dict[param_name][0], high=True) 1768 1763 self._magnet_model.item(row, 1).setText(param_repr) 1764 self.kernel_module.setParam(param_name, param_dict[param_name][0]) 1769 1765 if self.has_magnet_error_column: 1770 1766 error_repr = GuiUtils.formatNumber(param_dict[param_name][1], high=True) … … 1786 1782 # block signals temporarily, so we don't end up 1787 1783 # updating charts with every single model change on the end of fitting 1788 self._magnet_model. blockSignals(True)1784 self._magnet_model.itemChanged.disconnect() 1789 1785 self.iterateOverMagnetModel(updateFittedValues) 1790 self._magnet_model. blockSignals(False)1786 self._magnet_model.itemChanged.connect(self.onMagnetModelChange) 1791 1787 1792 1788 if self.has_magnet_error_column: … … 1798 1794 1799 1795 # switch off reponse to model change 1800 self._magnet_model.blockSignals(True)1801 1796 self._magnet_model.insertColumn(2, error_column) 1802 self._magnet_model.blockSignals(False)1803 1797 FittingUtilities.addErrorHeadersToModel(self._magnet_model) 1804 1798 … … 1812 1806 self.cmdPlot.setText("Show Plot") 1813 1807 # Force data recalculation so existing charts are updated 1808 self.showPlot() 1814 1809 self.recalculatePlotData() 1815 self.showPlot()1816 1810 1817 1811 def onSmearingOptionsUpdate(self): … … 2079 2073 self.shell_names = self.shellNamesList() 2080 2074 2081 # Get new rows for QModel2082 new_rows = FittingUtilities.addParametersToModel(self.model_parameters, self.kernel_module, self.is2D)2083 2084 2075 # Add heading row 2085 2076 FittingUtilities.addHeadingRowToModel(self._model_model, model_name) 2086 2077 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) 2090 2085 2091 2086 def fromStructureFactorToQModel(self, structure_factor): … … 2096 2091 return 2097 2092 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 2106 2099 else: 2100 s_kernel = self.models[structure_factor]() 2101 p_kernel = self.kernel_module 2102 2107 2103 p_pars_len = len(p_kernel._model_info.parameters.kernel_parameters) 2108 2104 s_pars_len = len(s_kernel._model_info.parameters.kernel_parameters) … … 2113 2109 2114 2110 # 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 2128 2113 if "radius_effective_mode" in all_param_names: 2129 2114 # Show all parameters … … 2138 2123 s_params = modelinfo.ParameterTable(all_params[p_pars_len:p_pars_len+s_pars_len-1]) 2139 2124 2140 # Get new rows for QModel2141 # Any renamed parameters are stored as data in the relevant item, for later handling2142 new_rows = FittingUtilities.addSimpleParametersToModel(s_params, self.is2D, s_params_orig)2143 2144 # TODO: merge rest of beta approx implementation in2145 # These parameters are not part of P(Q) nor S(Q), but are added only to the product model (e.g. specifying2146 # structure factor calculation mode)2147 # product_params = all_params[p_pars_len+s_pars_len:]2148 2149 2125 # Add heading row 2150 2126 FittingUtilities.addHeadingRowToModel(self._model_model, structure_factor) 2151 2127 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) 2159 2136 2160 2137 def haveParamsToFit(self): … … 2813 2790 self._model_model.removeRows(first_row, remove_rows) 2814 2791 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 2816 2799 self._num_shell_params = len(new_rows) 2817 2818 2800 self.current_shell_displayed = index 2819 2801
Note: See TracChangeset
for help on using the changeset viewer.