Skip to content

Filters

filters

AbsoluteValueFilter

Bases: BaseFilter

Rectifies the signal by taking the magnitude of every sample.

type class-attribute instance-attribute

Python
type: Literal[ABSOLUTE_VALUE] = ABSOLUTE_VALUE

The discriminator type for Pydantic.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

ClipFilter

Bases: BaseFilter

Clamps the signal values within a specified range.

type class-attribute instance-attribute

Python
type: Literal[CLIP] = CLIP

The discriminator type for Pydantic.

min class-attribute instance-attribute

Python
min: float | None = None

Optional lower bound; values below this will be set to min.

max class-attribute instance-attribute

Python
max: float | None = None

Optional upper bound; values above this will be set to max.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

DeadbandFilter

Bases: BaseFilter

Suppresses noise around zero by forcing values below a threshold to zero.

type class-attribute instance-attribute

Python
type: Literal[DEADBAND] = DEADBAND

The discriminator type for Pydantic.

threshold class-attribute instance-attribute

Python
threshold: float = Field(default=0.01, ge=0)

Magnitude threshold; values where abs(x) <= threshold are set to 0.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

DerivativeFilter

Bases: BaseFilter

Computes the numerical rate of change using backward difference. Useful for deriving velocity from position or acceleration from velocity.

type class-attribute instance-attribute

Python
type: Literal[DERIVATIVE] = DERIVATIVE

The discriminator type for Pydantic.

dt class-attribute instance-attribute

Python
dt: float = Field(default=0.001, gt=0)

The time step between samples in seconds. Ignored when wrt_col is set.

wrt_col class-attribute instance-attribute

Python
wrt_col: str | None = Field(
    default=None, json_schema_extra={"ui_type": "col"}
)

Optional column to differentiate with respect to instead of a fixed dt.

HighPassFilter

Bases: BaseFilter

Removes low-frequency drift or steady-state offsets. Implemented as the complement of the Exponential Moving Average.

type class-attribute instance-attribute

Python
type: Literal[HIGH_PASS] = HIGH_PASS

The discriminator type for Pydantic.

alpha class-attribute instance-attribute

Python
alpha: float = Field(default=0.1, gt=0, le=1)

Smoothing factor used for the underlying low-pass component.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

IntegralFilter

Bases: BaseFilter

Computes the cumulative sum of the signal multiplied by the time step. Useful for deriving position from velocity or calculating energy.

type class-attribute instance-attribute

Python
type: Literal[INTEGRAL] = INTEGRAL

The discriminator type for Pydantic.

dt class-attribute instance-attribute

Python
dt: float = Field(default=0.001, gt=0)

The time step between samples in seconds. Ignored when wrt_col is set.

wrt_col class-attribute instance-attribute

Python
wrt_col: str | None = Field(
    default=None, json_schema_extra={"ui_type": "col"}
)

Optional column to integrate with respect to instead of a fixed dt.

LowPassFilter

Bases: BaseFilter

Applies a 1st-order Exponential Moving Average (EMA) to smooth the signal. Effective for removing high-frequency noise while introducing slight phase lag.

type class-attribute instance-attribute

Python
type: Literal[LOW_PASS] = LOW_PASS

The discriminator type for Pydantic.

alpha class-attribute instance-attribute

Python
alpha: float = Field(default=0.1, gt=0, le=1)

Smoothing factor (0 < alpha <= 1). Lower values result in heavier smoothing.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

MedianFilter

Bases: BaseFilter

Applies a sliding window median filter. Highly effective for removing impulse noise (spikes) without blurring edges.

type class-attribute instance-attribute

Python
type: Literal[MEDIAN] = MEDIAN

The discriminator type for Pydantic.

window class-attribute instance-attribute

Python
window: int = Field(default=10, gt=0)

Size of the sliding window in samples.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

NormalizeFilter

Bases: BaseFilter

Rescales the signal to the range [0, 1].

type class-attribute instance-attribute

Python
type: Literal[NORMALIZE] = NORMALIZE

The discriminator type for Pydantic.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

RollingMeanFilter

Bases: BaseFilter

Applies a sliding window average to the signal.

type class-attribute instance-attribute

Python
type: Literal[ROLLING_MEAN] = ROLLING_MEAN

The discriminator type for Pydantic.

window class-attribute instance-attribute

Python
window: int = Field(default=10, gt=0)

Size of the sliding window in samples.

center class-attribute instance-attribute

Python
center: bool = True

If True, centers the window on the current sample to minimize phase lag.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

SavitzkyGolayFilter

Bases: BaseFilter

Applies a Savitzky-Golay smoothing filter by fitting a polynomial to the data. Preserves signal features (like peaks and transients) better than a simple moving average.

type class-attribute instance-attribute

Python
type: Literal[SAVITZKY_GOLAY] = SAVITZKY_GOLAY

The discriminator type for Pydantic.

window class-attribute instance-attribute

Python
window: int = Field(default=11, gt=1)

Number of samples in the sliding window; must be an odd integer.

order class-attribute instance-attribute

Python
order: int = Field(default=2, ge=0)

The order of the polynomial used to fit the samples.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

ScaleFilter

Bases: BaseFilter

Applies a linear transformation: (value * factor) + offset.

type class-attribute instance-attribute

Python
type: Literal[SCALE] = SCALE

The discriminator type for Pydantic.

factor class-attribute instance-attribute

Python
factor: float = 1.0

Multiplicative gain applied to the signal.

offset class-attribute instance-attribute

Python
offset: float = 0.0

Additive constant applied after scaling.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

TaringFilter

Bases: BaseFilter

Offsets the entire signal so that the first sample is zero.

type class-attribute instance-attribute

Python
type: Literal[TARING] = TARING

The discriminator type for Pydantic.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

UnitFilter

Bases: BaseFilter

Unit conversion using Pint. Ensures dimensional consistency and applies necessary scaling/offsets.

type class-attribute instance-attribute

Python
type: Literal[UNIT] = UNIT

The discriminator type for Pydantic.

from_unit instance-attribute

Python
from_unit: SignalUnit

The original unit of the telemetry data (e.g., 'rad').

to_unit instance-attribute

Python
to_unit: SignalUnit

The target unit for analysis/display (e.g., 'deg').

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None

WrapFilter

Bases: BaseFilter

Keeps circular data (like Euler angles or radians) within a specific range. Ensures continuity when a signal crosses the upper or lower boundary.

type class-attribute instance-attribute

Python
type: Literal[WRAP] = WRAP

The discriminator type for Pydantic.

lb class-attribute instance-attribute

Python
lb: float = -pi

Lower boundary for the wrap operation.

ub class-attribute instance-attribute

Python
ub: float = pi

Upper boundary for the wrap operation.

apply_with_context

Python
apply_with_context(
    series: Series, df: DataFrame
) -> Series | None

Override for filters that need access to other columns. Receives the current (already-transformed) series and the original dataframe. Return None to fall back to apply(expr).

Source code in src/mujoco_mojo/utils/filters/filters.py
Python
def apply_with_context(
    self, series: pl.Series, df: pl.DataFrame
) -> pl.Series | None:
    """
    Override for filters that need access to other columns.
    Receives the current (already-transformed) series and the original dataframe.
    Return None to fall back to apply(expr).
    """
    return None