FIR filter design using the window method.
This function computes the coefficients of a finite impulse response filter. The filter will have linear phase; it will be Type I if numtaps is odd and Type II if numtaps is even.
Type II filters always have zero response at the Nyquist rate, so a ValueError exception is raised if firwin is called with numtaps even and having a passband whose right end is at the Nyquist rate.
Parameters : | numtaps : int
cutoff : float or 1D array_like
width : float or None
window : string or tuple of string and parameter values
pass_zero : bool
scale : bool
nyq : float
|
---|---|
Returns : | h : (numtaps,) ndarray
|
Raises : | ValueError :
|
See also
Examples
Low-pass from 0 to f:
>>> from scipy import signal
>>> signal.firwin(numtaps, f)
Use a specific window function:
>>> signal.firwin(numtaps, f, window='nuttall')
High-pass (‘stop’ from 0 to f):
>>> signal.firwin(numtaps, f, pass_zero=False)
Band-pass:
>>> signal.firwin(numtaps, [f1, f2], pass_zero=False)
Band-stop:
>>> signal.firwin(numtaps, [f1, f2])
Multi-band (passbands are [0, f1], [f2, f3] and [f4, 1]):
>>> signal.firwin(numtaps, [f1, f2, f3, f4])
Multi-band (passbands are [f1, f2] and [f3,f4]):
>>> signal.firwin(numtaps, [f1, f2, f3, f4], pass_zero=False)