pyhiperta.R0Reader
Implements the reading/loading of R0 data (waveforms) and service data (gains/pedestals, etc.) from R0 hdf5 files.
Classes:
| Name | Description |
|---|---|
R0HDF5Dataset |
HDF5 reader class inspired by pytorch datasets. |
R0HDF5Dataset
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:
| Name | Type | Description | Default |
|---|---|---|---|
R0_files
|
Path or str or Iterable[Path] or Iterable[str]
|
If |
required |
batch_size
|
int
|
Number of shower events to stack to create a batch. |
required |
nb_first_slice_to_reject
|
(int, optionnal)
|
If provided, the first |
None
|
nb_last_slice_to_reject
|
(int, optionnal)
|
If provided, the last |
None
|
Methods:
| Name | Description |
|---|---|
__getitem__ |
Load a batch of waveforms from the dataset. |
__len__ |
Return the number of batches in the dataset. |
events_n_frames |
Return the number of frames in an event by reading the 1st event of 1st batch. |
read_camera_geometry |
Read the camera geometry (pixel coordinates) from the first file of the dataset. |
read_gains |
Read the per-pixel gains corresponding to the waveforms data. |
read_pedestals |
Read the per-pixel pedestals corresponding to the waveform data. |
read_reference_pulse |
Read the reference pulse shape arrays from the first file of the dataset. |
Source code in src/pyhiperta/R0Reader.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |
__getitem__
Load a batch of waveforms from the dataset.
The size of the batch should be batch_size unless there are not enough events left in the dataset
to load (for instance for the last batch, or if the batch size is greater than the number of events
in the dataset.)
The loaded waveforms are truncated at each ends by nb_first_slice_to_reject, respectively
nb_last_slice_to_reject.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
int
|
The index of the batch to load. |
required |
Returns:
| Type | Description |
|---|---|
Tuple[ndarray, ndarray]
|
waveforms[0] are the high gain waveforms of the batch, waveforms[1] are the low gain waveforms. Shape of the waveforms arrays: (N_batch, N_frames, N_pixels) |
Source code in src/pyhiperta/R0Reader.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |
__len__
events_n_frames
read_camera_geometry
Read the camera geometry (pixel coordinates) from the first file of the dataset.
Returns:
| Type | Description |
|---|---|
ndarray
|
Camera pixel coordinates. geometry[0, :] are the x coordinates, geometry[1, :] are the y coordinates. Shape (2, N_pixels) |
Source code in src/pyhiperta/R0Reader.py
read_gains
Read the per-pixel gains corresponding to the waveforms data.
The high and low gains are stored thus read together.
Returns:
| Type | Description |
|---|---|
ndarray
|
The per-pixel gains values. gains[0, :] are the high gains, gains[1, :] the low gains. Shape: (2, N_pixels). |
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.
Source code in src/pyhiperta/R0Reader.py
read_pedestals
Read the per-pixel pedestals corresponding to the waveform data.
The pedestals corresponding to each channel (gain) are stored and read stacked together.
Returns:
| Type | Description |
|---|---|
ndarray
|
The per-pixel pedestal values. pedestals[0, :] are the high gain pedestals, while pedestals[1, :] are the low gain pedestals. Shape: (2, N_pixels) |
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.
Source code in src/pyhiperta/R0Reader.py
read_reference_pulse
Read the reference pulse shape arrays from the first file of the dataset.
Returns:
| Type | Description |
|---|---|
Tuple[ndarray, ndarray]
|
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. |