fix toggle between relative and absolute residuals

This commit is contained in:
Dominik Demuth 2024-01-02 10:49:31 +01:00
parent fa296c9779
commit 9ca11bf05e

View File

@ -78,8 +78,7 @@ class QFitResult(QtWidgets.QDialog, Ui_Dialog):
self.logx_box.stateChanged.connect(lambda x: self.fit_plot.setLogMode(x=bool(x))) self.logx_box.stateChanged.connect(lambda x: self.fit_plot.setLogMode(x=bool(x)))
self.resid_plot.setXLink(self.fit_plot) self.resid_plot.setXLink(self.fit_plot)
self.abs_dev_button.clicked.connect(self._plot_residuals) self.buttonGroup.buttonToggled.connect(self._plot_residuals)
self.abs_dev_button.clicked.connect(self._plot_residuals)
self.set_results(results) self.set_results(results)
@ -231,18 +230,19 @@ class QFitResult(QtWidgets.QDialog, Ui_Dialog):
def _plot_residuals(self, idx: str = None): def _plot_residuals(self, idx: str = None):
print(idx) print(idx)
if idx is None: if idx is None or isinstance(idx, QtWidgets.QAbstractButton):
idx = self.sets_comboBox.currentData(QtCore.Qt.ItemDataRole.UserRole) idx = self.sets_comboBox.currentData(QtCore.Qt.ItemDataRole.UserRole)
print(idx, self._results.keys())
res = self._results[idx] res = self._results[idx]
if res.iscomplex: if res.iscomplex:
if self.rel_dev_button.isChecked(): if self.rel_dev_button.isChecked():
print('rel')
self.resid_graph.setData(x=res.x_data, y=res.residual.real/np_abs(res.y_data.real)) self.resid_graph.setData(x=res.x_data, y=res.residual.real/np_abs(res.y_data.real))
print(res.y_data.imag)
if all(np_isfinite(res.y_data.imag)): if all(np_isfinite(res.y_data.imag)):
self.resid_graph_imag.setData(x=res.x_data, y=res.residual.imag/np_abs(res.y_data.imag)) self.resid_graph_imag.setData(x=res.x_data, y=res.residual.imag/np_abs(res.y_data.imag))
else: else:
print('abs')
self.resid_graph.setData(x=res.x_data, y=res.residual.real) self.resid_graph.setData(x=res.x_data, y=res.residual.real)
self.resid_graph_imag.setData(x=res.x_data, y=res.residual.imag) self.resid_graph_imag.setData(x=res.x_data, y=res.residual.imag)