Skip to content
Snippets Groups Projects
Commit e8c95562 authored by Peter Swain's avatar Peter Swain
Browse files

change: rename butterworth_filter ; lowpass_filter

Renamed butterworth_filter to flavin_filter.
parent ac00fff8
No related branches found
No related tags found
No related merge requests found
...@@ -105,24 +105,18 @@ def snr(fft_freqs, fft_power, cutoff_freq): ...@@ -105,24 +105,18 @@ def snr(fft_freqs, fft_power, cutoff_freq):
return snr return snr
def butterworth_filter(data, params=None): def lowpass_filter(data, cutoff, fs, N):
"""Apply Butterworth filter to time series arranged in rows.""" """Apply low-pass filter to a single time-series."""
# second-order-sections output data = data - np.mean(data)
# by default, using a digital filter sos = signal.butter(N, cutoff, btype="lowpass", fs=fs, output="sos")
if params is None: filtered_data = signal.sosfiltfilt(sos, data)
params = { return filtered_data + np.mean(data)
"order": 2,
"critical_freqs": (1 / 350),
"filter_type": "highpass", def flavin_filter(data, cutoff=1 / 350, fs=1 / 5, N=2):
"sampling_freq": 1 / 3, """Apply high-pass Butterworth filter to time series arranged in rows."""
} # use a digital filter assuming regularly spaced sampling
sos = signal.butter( sos = signal.butter(N=N, Wn=cutoff, btype="highpass", fs=fs, output="sos")
N=params["order"],
Wn=params["critical_freqs"],
btype=params["filter_type"],
fs=params["sampling_freq"],
output="sos",
)
# fill NaNs between data points # fill NaNs between data points
data = pd.DataFrame(data).interpolate(axis=1).to_numpy() data = pd.DataFrame(data).interpolate(axis=1).to_numpy()
# subtract time series by mean # subtract time series by mean
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment