class sdr.IIR

Implements an infinite impulse response (IIR) filter.

This class is a wrapper for the scipy.signal.lfilter() function. It supports one-time filtering and streamed filtering.

Notes

An IIR filter is defined by its feedforward coefficients \(b_i\) and feedback coefficients \(a_j\). These coefficients define the difference equation

\[y[n] = \frac{1}{a_0} \left( \sum_{i=0}^{M} b_i x[n-i] - \sum_{j=1}^{N} a_j y[n-j] \right) .\]

The transfer function of the filter is

\[H(z) = \frac{\sum\limits_{i=0}^{M} b_i z^{-i}}{\sum\limits_{j=0}^{N} a_j z^{-j}} .\]

Examples

See the IIR filters example.

Constructors

IIR(b: ArrayLike, a: ArrayLike, streaming: bool = False)

Creates an IIR filter with feedforward coefficients \(b_i\) and feedback coefficients \(a_j\).

classmethod ZerosPoles(zeros: ArrayLike, poles, ...) Self

Creates an IIR filter from its zeros, poles, and gain.

Methods

filter(x: ArrayLike) ndarray

Filters the input signal \(x[n]\) with the IIR filter.

frequency_response(...) tuple[ndarray, ndarray]

Returns the frequency response \(H(f)\) of the IIR filter.

frequency_response_log(...) tuple[ndarray, ndarray]

Returns the frequency response \(H(f)\) of the IIR filter on a logarithmic frequency axis.

impulse_response(N: int = 100) ndarray

Returns the impulse response \(h[n]\) of the IIR filter. The impulse response \(h[n]\) is the filter output when the input is an impulse \(\delta[n]\).

reset()

Streaming-mode only: Resets the filter state.

step_response(N: int = 100) ndarray

Returns the step response \(s[n]\) of the IIR filter. The step response \(s[n]\) is the filter output when the input is a unit step \(u[n]\).

Properties

property a_taps : ndarray

The feedback taps \(a_j\).

property b_taps : ndarray

The feedforward taps \(b_i\).

property gain : float

The gain of the IIR filter.

property order : int

The order of the IIR filter, \(N\).

property poles : ndarray

The poles of the IIR filter.

property streaming : bool

Indicates whether the filter is in streaming mode.

property zeros : ndarray

The zeros of the IIR filter.