firwin2(numtaps, freq, gain, nfreqs=None, window='hamming', nyq=None, antisymmetric=False, fs=None)
From the given frequencies :None:None:`freq`
and corresponding gains :None:None:`gain`
, this function constructs an FIR filter with linear phase and (approximately) the given frequency response.
From the given set of frequencies and gains, the desired response is constructed in the frequency domain. The inverse FFT is applied to the desired response to create the associated convolution kernel, and the first :None:None:`numtaps`
coefficients of this kernel, scaled by :None:None:`window`
, are returned.
The FIR filter will have linear phase. The type of filter is determined by the value of 'numtaps` and :None:None:`antisymmetric`
flag. There are four possible combinations:
odd
:None:None:`numtaps`
,:None:None:`antisymmetric`
is False, type I filter is producedeven
:None:None:`numtaps`
,:None:None:`antisymmetric`
is False, type II filter is producedodd
:None:None:`numtaps`
,:None:None:`antisymmetric`
is True, type III filter is producedeven
:None:None:`numtaps`
,:None:None:`antisymmetric`
is True, type IV filter is produced
Magnitude response of all but type I filters are subjects to following constraints:
type II -- zero at the Nyquist frequency
type III -- zero at zero and Nyquist frequencies
type IV -- zero at zero frequency
The number of taps in the FIR filter. :None:None:`numtaps`
must be less than :None:None:`nfreqs`
.
The frequency sampling points. Typically 0.0 to 1.0 with 1.0 being Nyquist. The Nyquist frequency is half :None:None:`fs`
. The values in :None:None:`freq`
must be nondecreasing. A value can be repeated once to implement a discontinuity. The first value in :None:None:`freq`
must be 0, and the last value must be fs/2
. Values 0 and fs/2
must not be repeated.
The filter gains at the frequency sampling points. Certain constraints to gain values, depending on the filter type, are applied, see Notes for details.
The size of the interpolation mesh used to construct the filter. For most efficient behavior, this should be a power of 2 plus 1 (e.g, 129, 257, etc). The default is one more than the smallest power of 2 that is not less than :None:None:`numtaps`
. :None:None:`nfreqs`
must be greater than :None:None:`numtaps`
.
Window function to use. Default is "hamming". See scipy.signal.get_window
for the complete list of possible values. If None, no window function is applied.
Deprecated. Use `fs` instead. This is the Nyquist frequency. Each frequency in :None:None:`freq`
must be between 0 and :None:None:`nyq`
. Default is 1.
Whether resulting impulse response is symmetric/antisymmetric. See Notes for more details.
The sampling frequency of the signal. Each frequency in :None:None:`cutoff`
must be between 0 and fs/2
. Default is 2.
The filter coefficients of the FIR filter, as a 1-D array of length :None:None:`numtaps`
.
FIR filter design using the window method.
A lowpass FIR filter with a response that is 1 on [0.0, 0.5], and that decreases linearly on [0.5, 1.0] from 1 to 0:
>>> from scipy import signalSee :
... taps = signal.firwin2(150, [0.0, 0.5, 1.0], [1.0, 1.0, 0.0])
... print(taps[72:78]) [-0.02286961 -0.06362756 0.57310236 0.57310236 -0.06362756 -0.02286961]
The following pages refer to to this document either explicitly or contain code examples using this.
scipy.signal._fir_filter_design.firwin
scipy.signal._fir_filter_design.firwin2
scipy.signal._fir_filter_design.remez
scipy.signal._fir_filter_design.minimum_phase
scipy.signal._signaltools._freq_domain_conv
scipy.signal._signaltools.fftconvolve
scipy.signal._signaltools.choose_conv_method
scipy.signal._fir_filter_design.firls
scipy.signal._signaltools.convolve
scipy.signal._signaltools.correlate2d
scipy.signal._signaltools.convolve2d
scipy.signal._fir_filter_design.kaiserord
scipy.signal._signaltools.oaconvolve
scipy.signal._signaltools.correlate
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them