comnum.butterworth_lowpass#

comnum.butterworth_lowpass(x, fs_hz, fc_hz, *, order=5)#

A Butterworth low-pass IIR filter of order order and 3-dB cut-off fc_hz at the sampling rate fs_hz (bilinear transform with the cut-off prewarped, a cascade of second-order sections of unit DC gain), run forward from rest: the anti-aliasing filter of a receiver, such as the fifth-order filter at 40 % of the sampling rate of Ip & Kahn (J. Lightw. Technol. 26(20), 2008).

Parameters:
  • x (array_like) – the samples (real or complex).

  • fs_hz (float) – the sampling rate (Hz).

  • fc_hz (float) – the 3-dB cut-off (Hz), in (0, fs_hz / 2).

  • order (int) – the order, 1 to 32.

Returns:

the filtered samples (complex128), as many as x.

Return type:

numpy.ndarray

Raises:

ValueError – for an order outside 1 to 32 or a cut-off outside (0, fs/2).

Examples

>>> import comnum, numpy as np
>>> y = comnum.butterworth_lowpass(np.ones(300), 1e3, 100.0, order=5)
>>> round(float(abs(y[-1])), 6)
1.0