From 6bcf42d6a8d12eb65e815a6b4f75cb5afb73f4e9 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Mon, 26 Jun 2023 20:34:52 +0200 Subject: [PATCH] check even window length in tg calc; part of #91 --- src/gui_qt/dsc/glass_dialog.py | 2 +- src/nmreval/data/dsc.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gui_qt/dsc/glass_dialog.py b/src/gui_qt/dsc/glass_dialog.py index d30ea57..c7b2a26 100644 --- a/src/gui_qt/dsc/glass_dialog.py +++ b/src/gui_qt/dsc/glass_dialog.py @@ -129,7 +129,7 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog): self.graphicsView_2.addItem(tnmh_fit) self._plots[key] = (data_plot, tg_plot, glass, liquid, tangent, fictive_cp, tnmh_fit) - self._tg_value[key] = {'onset': (nan, nan), 'mid': (nan, nan), 'end': (nan, nan), 'inflection': (nan, nan)} # , 'fictive': (nan, nan)} + self._tg_value[key] = {'onset': (nan, nan), 'midpoint': (nan, nan), 'end': (nan, nan), 'inflection': (nan, nan)} # , 'fictive': (nan, nan)} if self._limitless: dist = max_x - min_x diff --git a/src/nmreval/data/dsc.py b/src/nmreval/data/dsc.py index f9c82fa..0d2aacd 100644 --- a/src/nmreval/data/dsc.py +++ b/src/nmreval/data/dsc.py @@ -47,7 +47,6 @@ class DSC(Points): region.y -= glass_extrapolation - plt.plot(region.x, regress2.slope * region.x + regress2.intercept) real_area = cumulative_trapezoid(region.y, region.x, initial=0) real_area -= real_area[-1] @@ -100,7 +99,10 @@ class DSC(Points): x = self.x[low_idx[0]:high_idx[1]] y = self.y[low_idx[0]:high_idx[1]] - yy = savgol_filter(y, window_length=min(len(x) // 20, 50), polyorder=1, deriv=1) / np.mean(np.diff(x)) + win_len = min(len(x) // 20, 51) + if win_len % 2 == 0: + win_len += 1 + yy = savgol_filter(y, window_length=win_len, polyorder=1, deriv=1) / np.mean(np.diff(x)) high_idx = (high_idx[0] - low_idx[0], high_idx[1] - low_idx[0]) low_idx = (0, low_idx[1] - low_idx[0])