scipy 1.8.0 Pypi GitHub Homepage
Other Docs
NotesParametersReturnsBackRef
iirfilter(N, Wn, rp=None, rs=None, btype='band', analog=False, ftype='butter', output='ba', fs=None)

Design an Nth-order digital or analog filter and return the filter coefficients.

Notes

The 'sos' output parameter was added in 0.16.0.

Parameters

N : int

The order of the filter.

Wn : array_like

A scalar or length-2 sequence giving the critical frequencies.

For digital filters, :None:None:`Wn` are in the same units as :None:None:`fs`. By default, :None:None:`fs` is 2 half-cycles/sample, so these are normalized from 0 to 1, where 1 is the Nyquist frequency. (:None:None:`Wn` is thus in half-cycles / sample.)

For analog filters, :None:None:`Wn` is an angular frequency (e.g., rad/s).

rp : float, optional

For Chebyshev and elliptic filters, provides the maximum ripple in the passband. (dB)

rs : float, optional

For Chebyshev and elliptic filters, provides the minimum attenuation in the stop band. (dB)

btype : {'bandpass', 'lowpass', 'highpass', 'bandstop'}, optional

The type of filter. Default is 'bandpass'.

analog : bool, optional

When True, return an analog filter, otherwise a digital filter is returned.

ftype : str, optional

The type of IIR filter to design:

output : {'ba', 'zpk', 'sos'}, optional

Filter form of the output:

fs : float, optional

The sampling frequency of the digital system.

versionadded

Returns

b, a : ndarray, ndarray

Numerator (b) and denominator (a) polynomials of the IIR filter. Only returned if output='ba' .

z, p, k : ndarray, ndarray, float

Zeros, poles, and system gain of the IIR filter transfer function. Only returned if output='zpk' .

sos : ndarray

Second-order sections representation of the IIR filter. Only returned if output=='sos' .

IIR digital and analog filter design given order and critical points.

See Also

bessel
butter

Filter design using order and critical points

buttord

Find order and critical points from passband and stopband spec

cheb1ord
cheb2ord
cheby1
cheby2
ellip
ellipord
iirdesign

General filter design using passband and stopband spec

Examples

Generate a 17th-order Chebyshev II analog bandpass filter from 50 Hz to 200 Hz and plot the frequency response:

>>> from scipy import signal
... import matplotlib.pyplot as plt
>>> b, a = signal.iirfilter(17, [2*np.pi*50, 2*np.pi*200], rs=60,
...  btype='band', analog=True, ftype='cheby2')
... w, h = signal.freqs(b, a, 1000)
... fig = plt.figure()
... ax = fig.add_subplot(1, 1, 1)
... ax.semilogx(w / (2*np.pi), 20 * np.log10(np.maximum(abs(h), 1e-5)))
... ax.set_title('Chebyshev Type II bandpass frequency response')
... ax.set_xlabel('Frequency [Hz]')
... ax.set_ylabel('Amplitude [dB]')
... ax.axis((10, 1000, -100, 10))
... ax.grid(which='both', axis='both')
... plt.show()

Create a digital filter with the same properties, in a system with sampling rate of 2000 Hz, and plot the frequency response. (Second-order sections implementation is required to ensure stability of a filter of this order):

>>> sos = signal.iirfilter(17, [50, 200], rs=60, btype='band',
...  analog=False, ftype='cheby2', fs=2000,
...  output='sos')
... w, h = signal.sosfreqz(sos, 2000, fs=2000)
... fig = plt.figure()
... ax = fig.add_subplot(1, 1, 1)
... ax.semilogx(w, 20 * np.log10(np.maximum(abs(h), 1e-5)))
... ax.set_title('Chebyshev Type II bandpass frequency response')
... ax.set_xlabel('Frequency [Hz]')
... ax.set_ylabel('Amplitude [dB]')
... ax.axis((10, 1000, -100, 10))
... ax.grid(which='both', axis='both')
... plt.show()
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

scipy.signal._filter_design.freqs scipy.signal._filter_design.ellipord scipy.signal._filter_design.iirfilter scipy.signal._filter_design.cheb1ord scipy.signal._filter_design.buttord scipy.signal._filter_design.gammatone scipy.signal._filter_design.freqs_zpk scipy.signal._filter_design.cheb2ord scipy.signal._filter_design.iirdesign

Local connectivity graph

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


GitHub : /scipy/signal/_filter_design.py#2324
type: <class 'function'>
Commit: