EnergyJitter#

class EnergyJitter(p=0.5, jitter_ratio=0.005, min_val=0.0)[source]#

Bases: object

Apply multiplicative per-point jitter to energy.

With probability p and when "energy" is present, scales each point’s energy by 1 + U(-jitter_ratio, jitter_ratio) then lower-clips to min_val; modifies data_dict["energy"] in place. Registered as EnergyJitter — use this string as the type in a transform=[...] config list.

Parameters:
  • p (float) – Probability of applying the transform. Defaults to 0.5.

  • jitter_ratio (float) – Half-width of the multiplicative jitter applied to energy. Defaults to 0.005.

  • min_val (float) – Lower clip applied after jittering. Defaults to 0.0.

Example

>>> import numpy as np
>>> np.random.seed(0)
>>> data = {"energy": np.array([[1.0], [2.0]], dtype="f4")}
>>> EnergyJitter(p=1.0, jitter_ratio=0.1)(data)["energy"].round(4)
array([[1.043 ],
       [2.0411]], dtype=float32)  # each point scaled by 1 +/- jitter