get_filter_units

function of dascore.units source

get_filter_units(
    arg1: pint.registry.Quantity | float[Quantity, float] ,
    arg2: pint.registry.Quantity | float[Quantity, float] ,
    to_unit: str | pint.registry.Quantity[str, Quantity] ,
    dim: None | str[None, str] = None,
)-> ‘tuple[float, float]’

Get a tuple for applying filter based on dimension coordinates.

Parameters

Parameter Description
arg1 The lower bound of the filter params
arg2 The upper bound of the filter params.
to_unit The units to which the filter should be applied. The returned
units will be 1/to_units.
dim The dimension name the opration is applied on. Only used for
raising a more helpful error message.

Examples

from dascore.units import get_filter_units, Hz, s
# Passing a tuple in Hz leaves the output in Hz
assert get_filter_units(1 * Hz, 10 * Hz, s) == (1., 10.)
assert get_filter_units(None, 10 * Hz, s) == (None, 10.)
assert get_filter_units(1 * Hz, 10 * Hz, s) == (1., 10.)
# Passing a tuple in seconds will convert to Hz and switch order, if needed.
assert get_filter_units(1 * s, 10 * s, s) == (0.1, 1.)
assert get_filter_units(None, 10 * s, s) == (None, 0.1)
assert get_filter_units(10 * s, None, s) == (0.1, None)