Source code for ezmsg.sigproc.decimate
"""Decimation (downsample with anti-alias filtering)."""
import typing
import ezmsg.core as ez
from ezmsg.baseproc import BaseTransformerUnit, suppress_axis_deprecation
from ezmsg.util.messages.axisarray import AxisArray
from .cheby import ChebyshevFilterSettings, ChebyshevFilterTransformer
from .downsample import Downsample, DownsampleSettings
from .filter import BACoeffs, SOSCoeffs
from .util.deprecation import warn_axis_deprecated
[docs]
class ChebyForDecimate(BaseTransformerUnit[ChebyshevFilterSettings, AxisArray, AxisArray, ChebyForDecimateTransformer]):
SETTINGS = ChebyshevFilterSettings
[docs]
class DecimateSettings(DownsampleSettings):
"""Settings for :obj:`Decimate`.
Adds the anti-aliasing filter's ``axis`` on top of the downsampler's
settings. The filter has one because a filter legitimately runs along any
dimension; the downsampler does not, because its phase counter only means
something along the dimension messages accumulate along. Leave ``axis``
matching the stream's stream dimension -- filtering one dimension and
decimating another is not decimation.
"""
axis: str | None = None
""".. deprecated:: 3.8
Scheduled for removal in 4.0. The dimension messages accumulate along
now comes from :attr:`~ezmsg.util.messages.axisarray.AxisArray.stream_dim`;
see :mod:`ezmsg.sigproc.util.deprecation`."""
def __post_init__(self) -> None:
warn_axis_deprecated(self)
[docs]
class Decimate(ez.Collection):
"""
A :obj:`Collection` chaining a :obj:`Filter` node configured as a lowpass Chebyshev filter
and a :obj:`Downsample` node.
"""
SETTINGS = DecimateSettings
INPUT_SIGNAL = ez.InputTopic(AxisArray)
OUTPUT_SIGNAL = ez.OutputTopic(AxisArray)
FILTER = ChebyForDecimate()
DOWNSAMPLE = Downsample()
[docs]
def network(self) -> ez.NetworkDefinition:
return (
(self.INPUT_SIGNAL, self.FILTER.INPUT_SIGNAL),
(self.FILTER.OUTPUT_SIGNAL, self.DOWNSAMPLE.INPUT_SIGNAL),
(self.DOWNSAMPLE.OUTPUT_SIGNAL, self.OUTPUT_SIGNAL),
)