I have been trying to use scipy's butter function and it has been working fine when I am trying to get the lowpass coefficients:
from scipy import signal
[b, a] = signal.butter(10, 0.3)
I strictly want to create a bandpass for 0.5Hz - 5Hz, but when I try to get the bandpass coefficients in the following code it gives me an error: ValueError: Digital filter critical frequencies must be 0 < Wn < 1
from scipy import signal
[b, a] = signal.butter(2, [0.5,5], btype='bandpass')
I did find the following stackoverflow question, but I am still unsure about the issue and I followed the requirements for using the signal.butter function from the documentation.
By default, for a digital filter, the values given for
Wn
must be expressed as fractions of the Nyquist frequency, which is half the samping rate. Either scale the values yourself, or specify the sample rate by also giving thefs
argument, as in the following example