11"""MAGIC-specific `Detector` class(es)."""
22
3- from typing import Dict , Callable
3+ from typing import Dict , Callable , Any
44import torch
55import os
66
@@ -18,6 +18,17 @@ class MAGIC(Detector):
1818 # By default, treat the telescope ID as a spatial-like z-coordinate
1919 xyz = ["x_cam" , "y_cam" , "tel_id" ]
2020
21+ def __init__ (self , use_charge_epsilon : bool = True , ** kwargs : Any ) -> None :
22+ """Construct detector for the MAGIC telescopes.
23+
24+ Args:
25+ use_charge_epsilon: Whether to add a small epsilon value to charge
26+ before taking log10 to avoid log(0). Defaults to True (uses
27+ 1e-6). Set to False if data is guaranteed to have zero-padding.
28+ """
29+ super ().__init__ (** kwargs )
30+ self ._charge_epsilon = 1e-6 if use_charge_epsilon else 0.0
31+
2132 def feature_map (self ) -> Dict [str , Callable ]:
2233 """Map standardization functions to each dimension.
2334
@@ -47,5 +58,4 @@ def _time(self, x: torch.tensor) -> torch.tensor:
4758
4859 def _charge (self , x : torch .tensor ) -> torch .tensor :
4960 """Add a small epsilon to avoid log(0)."""
50- epsilon = 1e-6
51- return torch .log10 (x + epsilon )
61+ return torch .log10 (x + self ._charge_epsilon )
0 commit comments