I am designing an
FIR filter to attenuate the frequencies below
300Hz. I designed the filter using the
scipy functions and the code is as below.
from numpy import cos, sin, pi, absolute, arange from scipy.signal import kaiserord, lfilter, firwin, freqz from pylab import figure, clf, plot, xlabel, ylabel, xlim, ylim, title, grid, axes, show nyq_rate = 48000 / 2 width = 100 / nyq_rate ripple_db = 60.0 cutoff_hz = 300.0 N, beta = kaiserord(ripple_db, width) taps = firwin(N, cutoff_hz/nyq_rate, window=('kaiser', beta), pass_zero='highpass') w, h = freqz(taps, worN=512) plot((w/pi)*nyq_rate, absolute(h), linewidth=2) xlabel('Frequency (Hz)') ylabel('Gain') title('Frequency Response') ylim(-0.05, 1.05) grid(True) show()
When I a execute it, the following error pops up.
ValueError: A filter with an even number of coefficients must have zero response at the Nyquist frequency.
I am not sure what is going wrong. Any help is appreciated.