From 9aab28d593ced17aa23cdb63a712801ca4ef7f7d Mon Sep 17 00:00:00 2001 From: dominik Date: Thu, 28 Jul 2022 20:20:49 +0200 Subject: [PATCH] bugs: fit display did not work when not all functions are checked; FC calc_relax changed x axis --- nmreval/distributions/loggaussian.py | 3 +-- nmreval/gui_qt/fit/fitwindow.py | 11 +++++++---- nmreval/models/fieldcycling.py | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/nmreval/distributions/loggaussian.py b/nmreval/distributions/loggaussian.py index 5aa3664..c6bc1c6 100644 --- a/nmreval/distributions/loggaussian.py +++ b/nmreval/distributions/loggaussian.py @@ -23,8 +23,7 @@ class LogGaussian(Distribution): bounds = [(0, 10)] @staticmethod - def distribution(tau, tau0, *args): - sigma = args[0] + def distribution(tau, tau0, sigma: float): return np.exp(-0.5*(np.log(tau/tau0)/sigma)**2)/np.sqrt(2*np.pi)/sigma @staticmethod diff --git a/nmreval/gui_qt/fit/fitwindow.py b/nmreval/gui_qt/fit/fitwindow.py index 445686b..99abc5f 100644 --- a/nmreval/gui_qt/fit/fitwindow.py +++ b/nmreval/gui_qt/fit/fitwindow.py @@ -82,7 +82,9 @@ class QFitDialog(QtWidgets.QWidget, Ui_FitDialog): self._current_function = None else: - self._current_function = self.functionwidget.use_combobox.currentData() + f_tree = self.functionwidget.functree + func_idx = f_tree.currentItem().data(0, f_tree.counterRole) + self._current_function = self.functionwidget.functions[func_idx] @QtCore.pyqtSlot(int) def show_function_parameter(self, function_id: int, function_idx: int = None): @@ -457,9 +459,10 @@ class QFitDialog(QtWidgets.QWidget, Ui_FitDialog): def set_parameter_iter(self, fit_id: str | None, param: List[float], functions: List, cnt: int = 0): for model_p in functions: - cnt += self.param_widgets[model_p['cnt']].set_parameter(fit_id, param[cnt:]) - if model_p['children']: - cnt += self.set_parameter_iter(fit_id, param, model_p['children'], cnt=cnt) + if model_p['active']: + cnt += self.param_widgets[model_p['cnt']].set_parameter(fit_id, param[cnt:]) + if model_p['children']: + cnt += self.set_parameter_iter(fit_id, param, model_p['children'], cnt=cnt) return cnt diff --git a/nmreval/models/fieldcycling.py b/nmreval/models/fieldcycling.py index ed59cf7..dbc2ebd 100644 --- a/nmreval/models/fieldcycling.py +++ b/nmreval/models/fieldcycling.py @@ -25,7 +25,7 @@ class _AbstractFC: def _calc_relax(cls, x, c, *args, xaxis='freq', yaxis='chi', is_bpp=True, **kwargs): _x = x if xaxis == 'freq': - _x *= 2*np.pi + _x = 2*np.pi * x if is_bpp: r1 = cls.relax.t1(_x, *args, prefactor=c, inverse=False)