From 3ed7368bb0303e9accaf745872821818acb23ceb Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Tue, 11 Jul 2023 18:06:17 +0200 Subject: [PATCH] fix even savgol window length manuallz --- src/nmreval/data/dsc.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/nmreval/data/dsc.py b/src/nmreval/data/dsc.py index afdefb4..5450696 100644 --- a/src/nmreval/data/dsc.py +++ b/src/nmreval/data/dsc.py @@ -98,7 +98,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])