I'm trying to use a Butterworth filter in Python as described in this thread with these functions:
def butter_bandpass(lowcut, highcut, fs, order=5): nyq = 0.5 * fs low = lowcut / nyq high = highcut / nyq b, a = butter(order, [low, high], btype='band') return b, a def butter_bandpass_filter(data, lowcut, highcut, fs, order=5): b, a = butter_bandpass(lowcut, highcut, fs, order=order) y = lfilter(b, a, data) return y
The output of the FFT of my data without applying the filter gives the following plot:
However, after applying the filter above with:
lowcut = 1.0 highcut = 50.0 x2_Vtcr = butter_bandpass_filter(x_Vtcr, lowcut, highcut, fs, order=4)
where fs is the sampling frequency (250 in my case) I get as FFT:
It looks like the filter shifts the frequency to the left and I don't get the peak where it should be. Any idea as to why this is happening?