pyhiperta.R0Reader.R0HDF5Dataset¶
- class pyhiperta.R0Reader.R0HDF5Dataset(R0_files: Path | str | Iterable[Path] | Iterable[str], batch_size: int, nb_first_slice_to_reject: int = None, nb_last_slice_to_reject: int = None)[source]¶
Bases:
object
HDF5 reader class inspired by pytorch datasets.
The main purpose of this class is to load shower waveforms in batch from hdf5 files, allowing to seamlessly iterate over batches independently of the number of files or the number of events per file.
- Parameters:
R0_files (Path or str or Iterable[Path] or Iterable[str]) – If R0_files is a string or a Path, it is expected to be the path to a single “.h5” R0 file, or to be the path to a folder containing the “.h5” R0 files to use. If it is an Iterable, each element is expected to be a string or path to a “.h5” data file.
batch_size (int) – Number of shower events to stack to create a batch.
nb_first_slice_to_reject (int, optionnal) – If provided, the first nb_first_slice_to_reject frames of the shower videos will be discarded when loading the waveforms. (This is required at the moment for LST data)
nb_last_slice_to_reject (int, optionnal) – If provided, the last nb_last_slice_to_reject frames of the shower videos will be discarded when loading the waveforms. (This is required at the moment for LST data)
- __init__(R0_files: Path | str | Iterable[Path] | Iterable[str], batch_size: int, nb_first_slice_to_reject: int = None, nb_last_slice_to_reject: int = None)[source]¶
Methods
__init__
(R0_files, batch_size[, ...])Return the number of frames in an event by reading the 1st event of 1st batch.
Read the camera geometry (pixel coordinates) from the first file of the dataset.
Read the per-pixel gains corresponding to the waveforms data.
Read the per-pixel pedestals corresponding to the waveform data.
Read the reference pulse shape arrays from the first file of the dataset.
- events_n_frames() int [source]¶
Return the number of frames in an event by reading the 1st event of 1st batch.
- read_camera_geometry() ndarray [source]¶
Read the camera geometry (pixel coordinates) from the first file of the dataset.
- Returns:
Camera pixel coordinates. geometry[0, :] are the x coordinates, geometry[1, :] are the y coordinates. Shape (2, N_pixels)
- Return type:
np.ndarray
- read_gains() ndarray [source]¶
Read the per-pixel gains corresponding to the waveforms data.
The high and low gains are stored thus read together.
- Returns:
The per-pixel gains values. gains[0, :] are the high gains, gains[1, :] the low gains. Shape: (2, N_pixels).
- Return type:
np.ndarray
Notes
At the moment, the gains are constant for all events of a telescope run. Therefore the gains are simply read from the first file.
- read_pedestals() ndarray [source]¶
Read the per-pixel pedestals corresponding to the waveform data.
The pedestals corresponding to each channel (gain) are stored and read stacked together.
- Returns:
The per-pixel pedestal values. pedestals[0, :] are the high gain pedestals, while pedestals[1, :] are the low gain pedestals. Shape: (2, N_pixels)
- Return type:
np.ndarray
Notes
At the moment, the pedestals are constant for all events of a telescope run. Therefore the pedestals are simply read from the first file.
- read_reference_pulse() Tuple[ndarray, ndarray] [source]¶
Read the reference pulse shape arrays from the first file of the dataset.
- Returns:
The first element are the “reference_pulse_sample_time”, the second are the “reference_pulse_shape_channel0” and “reference_pulse_shape_channel0”, stacked in a single array. reference_pulse_shape[0] si channel 0 and reference_pulse_shape[1] is channel 1.
- Return type:
Tuple[np.ndarray, np.ndarray]