Merge pull request 'show sub-functions in fitresult; closes #26' (#28) from fitting into master

Reviewed-on: #28
This commit is contained in:
Dominik Demuth 2023-04-02 15:42:05 +00:00
commit 1c98676bee

View File

@ -1,6 +1,6 @@
from math import isnan from math import isnan
from pyqtgraph import mkBrush from pyqtgraph import mkBrush, mkPen
from nmreval.utils.text import convert from nmreval.utils.text import convert
@ -160,6 +160,11 @@ class QFitResult(QtWidgets.QDialog, Ui_Dialog):
res = self._results[idx] res = self._results[idx]
iscomplex = res.iscomplex iscomplex = res.iscomplex
sub_funcs = res.sub(res.x)
for item in self.fitplot.curves[::-1]:
if item not in [self.data_graph, self.data_graph_imag, self.fit_graph, self.fit_graph_imag]:
self.fitplot.removeItem(item)
if iscomplex: if iscomplex:
self.data_graph.setData(x=res.x_data, y=res.y_data.real) self.data_graph.setData(x=res.x_data, y=res.y_data.real)
self.data_graph_imag.setData(x=res.x_data, y=res.y_data.imag) self.data_graph_imag.setData(x=res.x_data, y=res.y_data.imag)
@ -167,6 +172,13 @@ class QFitResult(QtWidgets.QDialog, Ui_Dialog):
self.fit_graph_imag.setData(x=res.x, y=res.y.imag) self.fit_graph_imag.setData(x=res.x, y=res.y.imag)
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)
for f in sub_funcs:
item = PlotItem(x=f.x, y=f.y.real)
self.fitplot.addItem(item)
item = PlotItem(x=f.x, y=f.y.imag)
self.fitplot.addItem(item)
else: else:
self.resid_graph.setData(x=res.x_data, y=res.residual) self.resid_graph.setData(x=res.x_data, y=res.residual)
self.resid_graph_imag.setData(x=[], y=[]) self.resid_graph_imag.setData(x=[], y=[])
@ -175,6 +187,10 @@ class QFitResult(QtWidgets.QDialog, Ui_Dialog):
self.fit_graph.setData(x=res.x, y=res.y) self.fit_graph.setData(x=res.x, y=res.y)
self.fit_graph_imag.setData(x=[], y=[]) self.fit_graph_imag.setData(x=[], y=[])
for f in sub_funcs:
item = PlotItem(x=f.x, y=f.y, pen=mkPen({'style': 2}))
self.fitplot.addItem(item)
self.fitplot.setLogMode(x=res.islog) self.fitplot.setLogMode(x=res.islog)
self.residplot.setLogMode(x=res.islog) self.residplot.setLogMode(x=res.islog)
@ -279,7 +295,6 @@ class QFitResult(QtWidgets.QDialog, Ui_Dialog):
plot_fits = self.curve_checkbox.isChecked() plot_fits = self.curve_checkbox.isChecked()
parts = self.partial_checkBox.checkState() == QtCore.Qt.Checked parts = self.partial_checkBox.checkState() == QtCore.Qt.Checked
extrapolate = [None, None, None] extrapolate = [None, None, None]