I have created a low pass Butterworth filter in python. What can be done so that I could reduce the cut off frequency to millihertz range? Is it possible even? Below is the code that I have used.
def butter_bandpass(cutoff_freq, fs, order=5):
nyq = 0.5 * fs
cutoff_freq = cutoff_freq / nyq
b, a = butter(order, cutoff_freq, btype='low')
w, h = freqz(b, a)
return b, a
def butter_bandpass_filter(data, time, cutoff_freq, fs, flag, order=5):
b, a = butter_bandpass(cutoff_freq, fs, order=order)
#zi = lfilter_zi(b, a)
y = lfilter(b, a, np.array(data))
return y
If the cutoff frequency is too small a fraction of Fs, a 5th order filter will become numerically unstable (rounding "errors" will create NaNs). Try lowering the sample rate Fs by extreme downsampling of the data.