EnergeticTranslation#

class EnergeticTranslation(p=0.95, ratio=0.05)[source]#

Bases: object

Randomly shift per-point energy by a shared scalar offset.

Energy analogue of ChromaticTranslation. With probability p and when "energy" is present, adds one random offset (drawn in +/- ratio) to every point’s energy, then clips to [-1, 1] (so it expects already log/linear-normalized energy); modifies data_dict["energy"] in place. Registered as EnergeticTranslation — use this string as the type in a transform=[...] config list.

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

  • ratio (float) – Half-width of the uniform offset added to energy. Defaults to 0.05.

Example

>>> import numpy as np
>>> np.random.seed(0)
>>> data = {"energy": np.array([[0.0], [0.5]], dtype="f4")}
>>> EnergeticTranslation(p=1.0, ratio=0.1)(data)["energy"].round(4)
array([[0.043 ],
       [0.543 ]], dtype=float32)  # one shared offset added to all points