I use a butterworth bandpass:
def butter_bandpass_prep(lowcut, highcut, fs, order=5):
"""Butterworth bandpass auxilliary function."""
nyq = 0.5 * fs # Minimal frequency (nyquist criterion)
low = lowcut / nyq
high = highcut / nyq
b, a = sp.signal.butter(order, [low, high], btype='band')
return b, a
def butter_bandpass(src, lowcut, highcut, fs, order=5):
"""Butterworth bandpass filter."""
b, a = butter_bandpass_prep(lowcut, highcut, fs, order=order)
dst = sp.signal.filtfilt(b, a, src)
return dst
I general it seems to work well, but at the margins I always get some unrealistic values. It seems as if the filtered margin-values drop to zero... Is there a way to prevent that from happening? Thank you a lot!