Skip to content

Low Pass Filter

__init__(cut_off=600, order=6, fs=128000, type='butter')

Initializes a low-pass filter with a cutoff frequency \(f_{cut}\) and an order \(N\), used to remove high frequency components from the received signal.

Parameters:

Name Type Description Default
cut_off float

Cutoff frequency \(f_{cut}\) of the filter.

600
order int

Order \(N\) of the filter.

6
fs int

Sampling frequency \(f_s\).

128000
type str

Filter type. Default is "butter".

'butter'

Raises:

Type Description
ValueError

If the filter type is invalid.

Examples:

>>> import argos3
>>> import numpy as np 
>>> 
>>> fs = 128000
>>> t = np.arange(10000) / fs
>>> 
>>> signal1 = np.cos(2 * np.pi * 1000 * t)
>>> signal2 = np.cos(2 * np.pi * 4000 * t) 
>>> 
>>> lpf = argos3.LPF(cut_off=1500, order=6, fs=fs, type="butter")
>>> 
>>> signal = signal1 + signal2
>>> 
>>> signal_filtered = lpf.apply_filter(signal)
  • Time Domain Example: pageplot
  • Frequency Domain Example: pageplot

butterworth_filter(fNyquist=0.5)

Calculates the Butterworth filter coefficients using the scipy.signal library. The continuous-time transfer function \(H(s)\) of a Butterworth filter is given by the expression below.

\[ H(s) = \frac{1}{1 + \left(\frac{s}{2 \pi f_{cut}}\right)^{2n}} \]
Where
  • \(s\): Complex variable in the Laplace domain.
  • \(2 \pi f_{cut}\): Cutoff frequency of the filter.
  • \(n\): Order of the filter.

Parameters:

Name Type Description Default
fNyquist float

Nyquist factor. Default is 0.5 * fs.

0.5

Returns:

Name Type Description
b ndarray

Coefficients \(b\) corresponding to the transfer function of the Butterworth filter.

a ndarray

Coefficients \(a\) corresponding to the transfer function of the Butterworth filter.

Examples:

  • Pole-Zero Plot: pageplot

calc_impulse_response(impulse_len=1024)

To obtain the impulse response in the time domain, a unit impulse is applied as input. For a Butterworth filter, the calculation is given by the expression below.

\[ h(t) = \mathcal{L}^{-1}\left\{H(f)\right\} \]
Where
  • \(h(t)\): Impulse response of the filter.
  • \(H(f)\): Transfer function of the filter.
  • \(\mathcal{L}^{-1}\): Inverse Laplace transform.

Parameters:

Name Type Description Default
impulse_len int

Length of the impulse vector.

1024

Returns:

Name Type Description
impulse_response tuple[ndarray, ndarray]

Impulse response and time vector.

Examples:

  • Impulse Response: pageplot

apply_filter(signal)

Applies the low-pass filter with impulse response \(h(t)\) to the input signal \(s(t)\), using the scipy.signal.filtfilt function. The filtering process is given by the expression below.

\[ x(t) = s(t) \ast h(t) \]
Where
  • \(x(t)\): Filtered signal.
  • \(s(t)\): Input signal.
  • \(h(t)\): Impulse response of the filter.

Parameters:

Name Type Description Default
signal ndarray

Input signal \(s(t)\).

required

Returns:

Name Type Description
signal_filtered ndarray

Filtered signal \(x(t)\).