torchsig.utils.dsp.low_pass_iterative_design

torchsig.utils.dsp.low_pass_iterative_design(cutoff: float, transition_bandwidth: float, sample_rate: float, desired_attenuation_db: float = 120) ndarray[source]

Iteratively designs a low-pass filter using the window method, adjusting the filter length to meet the desired stopband attenuation.

The filter design process starts with an initial filter design, and then iteratively increases the filter length based on the measured stopband attenuation. This process continues until the desired stopband attenuation is achieved or the maximum number of iterations is reached.

Parameters:
  • cutoff (float) – The cutoff frequency of the low-pass filter (in Hz).

  • transition_bandwidth (float) – The transition bandwidth of the filter (in Hz).

  • sample_rate (float) – The sample rate of the system (in Hz).

  • desired_attenuation_db (float, optional) – The desired stopband attenuation in decibels (dB). Defaults to 120 dB.

Returns:

The designed low-pass filter coefficients.

Return type:

np.ndarray

Raises:

Warning – If the filter design process exceeds the maximum number of iterations, a warning is raised and the initial filter design is returned.

Notes

The iterative design process adjusts the filter length based on the ratio of desired and measured stopband attenuation. If the process doesn’t converge within a reasonable number of iterations, the initial design is returned.