ComputeAnchors#
- class ComputeAnchors(cfg: dict | None = None)[source]#
Bases:
objectCompute geometric anchors once per event and attach them to the sample.
Reads
data_dict["coord"]anddata_dict["energy"]and calls the packagecompute_anchorshelper (withANCHOR_DEFAULT_CFGmerged withcfg) to detect salient structures (e.g. endpoints, branches, Bragg peaks), writing the resulting dict todata_dict["anchors"]. These anchors can later bias view sampling (seeMultiViewGenerator). A no-op when the helper is unavailable or whencoord/energyare missing. Registered asComputeAnchors— use this string as thetypein atransform=[...]config list.- Parameters:
cfg (dict, optional) – Overrides merged on top of
ANCHOR_DEFAULT_CFG. Defaults toNone(empty dict).
Example
>>> import numpy as np >>> rng = np.random.default_rng(0) >>> data = {"coord": rng.random((50, 3), dtype="f4"), ... "energy": rng.random((50, 1), dtype="f4")} >>> out = ComputeAnchors()(data) >>> list(out["anchors"].keys()) # dict of detected salient structures ['endpoints', 'branches_track', 'branches_shower', 'bragg', 'led'] # each value is an (M, 3) array of anchor coordinates; M varies per event