CustomScaling#

class CustomScaling(
to_physical_fn: Callable[[int], float],
to_raw_fn: Callable[[float], int] | None = None,
)[source]#

Bases: ScalingFunction

User-defined scaling. to_raw_fn is optional; to_raw raises NotImplementedError without it.

Example

>>> CustomScaling(
...     to_physical_fn=lambda x: x / 4095 * 5.0 * 7.2,
...     to_raw_fn=lambda v: int(v / 7.2 / 5.0 * 4095),
... )

Methods

to_physical

Raw register value → physical units.

to_raw

Physical value → raw integer.