SpectralInterpolationFilter#

class myoverse.datasets.filters.temporal.SpectralInterpolationFilter(input_is_chunked, is_output=False, name=None, run_checks=True, *, bandwidth=(47.5, 52.5), number_of_harmonics=3, sampling_frequency=2000, interpolation_window=15, interpolation_poly_order=3, remove_dc=True)[source]#

Filter that removes certain frequency bands from the signal and interpolates the gaps.

This is ideal for removing power line interference or other narrowband noise. The filter works by: 1. Computing FFT of the signal 2. Setting the magnitude of the specified frequency bands to interpolated values 3. Preserving the phase information 4. Converting back to time domain

Warning

When used for real-time applications, performance depends on chunk size. Smaller chunks reduce latency but may decrease frequency resolution and interpolation quality, especially for narrow frequency bands.

Parameters:
  • input_is_chunked (bool) – Whether the input is chunked or not.

  • is_output (bool) – Whether the filter is an output filter.

  • name (str | None) – Name of the filter, by default None.

  • run_checks (bool) –

    Whether to run the checks when filtering. By default, True. If False can potentially speed up performance.

    Warning

    If False, the user is responsible for ensuring that the input array is valid.

  • bandwidth (tuple[float, float]) – Frequency band to remove (min_freq, max_freq) in Hz, by default (47.5, 52.5)

  • number_of_harmonics (int) – Number of harmonics to remove, by default 3

  • sampling_frequency (float) – Sampling frequency in Hz, by default 2000

  • interpolation_window (int) – Window size for interpolation, must be an odd number, by default 15

  • interpolation_poly_order (int) – Polynomial order for interpolation, must be less than interpolation_window, by default 3

  • remove_dc (bool) – Whether to remove the DC component (set FFT[0] to 0), by default True

Methods

__init__(input_is_chunked[, is_output, ...])

_filter(input_array, **kwargs)

Apply the filter to the input array.

_get_indices_to_interpolate(freqs)

Get the indices of the frequency bins to interpolate.