Commit 4fb6c149 authored by hazrmard's avatar hazrmard
Browse files

bugfix in modelretrain/butterworthsmoothing where filtfit function default...

bugfix in modelretrain/butterworthsmoothing where filtfit function default argument would give error if dataframe was too small
parent 3571caca
......@@ -15,6 +15,7 @@ test.txt
*.out
relearn.pkl
*.hdf5
*.h5f
_demo_source
results*/
......
......@@ -162,7 +162,11 @@ def butterworthsmoothing(df, column_names: list = None, Wn = 0.015):
N = 2 # Filter order
Wn = Wn # Cutoff frequency
B, A = signal.butter(N, Wn, output='ba')
# For cases when the provided dataframe is too small, filtering may
# give an error as the default signal padding > data length:
default_padlen = 3 * max(len(A), len(B)) # scipy.signal.filtfit docs
padlen = min(default_padlen, len(df)-1)
for i in column_names:
df[i] = signal.filtfilt(B, A, df[i])
df[i] = signal.filtfilt(B, A, df[i], padlen=padlen)
df.dropna(axis=0, how='any', inplace=True)
return df
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment