RelativeLogNormalize#
- class RelativeLogNormalize(keys=('time',), scale=50.0, max_val=4000.0, out_min=-1.0, out_max=1.0)[source]#
Bases:
objectPer-event relative log normalization (e.g. for hit times).
For each key in
keys, subtracts the per-event minimum, clips to[0, max_val], applieslog1p(x / scale)normalized bylog1p(max_val / scale), then maps onto[out_min, out_max]. Useful for trigger-offset-removed timing where only relative spacing matters. RaisesValueErrorif a requested key is missing. Registered asRelativeLogNormalize— use this string as thetypein atransform=[...]config list.- Parameters:
keys (tuple) – Keys to transform; a single string is wrapped into a tuple. Defaults to
("time",).scale (float) – Log soft-knee scale (
log1p(x / scale)); must be positive. Defaults to50.0.max_val (float) – Upper clip applied before the log; must be positive. Defaults to
4000.0.out_min (float) – Lower bound of the output range. Defaults to
-1.0.out_max (float) – Upper bound of the output range; must exceed
out_min. Defaults to1.0.
Example
>>> import numpy as np >>> data = {"time": np.array([[100.], [150.], [4100.]], dtype="f4")} >>> RelativeLogNormalize(keys=("time",), scale=50.0)(data)["time"].round(3) array([[-1. ], [-0.685], [ 1. ]], dtype=float32) # per-event min->-1, clipped max->+1