Skip to content

Commit

Permalink
Move reading of stereo data before skipping empty events in HDF5Event…
Browse files Browse the repository at this point in the history
…Source
  • Loading branch information
maxnoe committed Jan 6, 2023
1 parent a2f4367 commit 5d09d14
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions ctapipe/io/hdf5eventsource.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,16 +573,23 @@ def _generator(self):

data.trigger.tel[tel_index.tel_id] = tel_trigger

if self.is_simulation:
data.simulation.shower = next(mc_shower_reader)

for kind, readers in dl2_readers.items():
c = getattr(data.dl2.stereo, kind)
for algorithm, reader in readers.items():
c[algorithm] = next(reader)

# this needs to stay *after* reading the telescope trigger table
# and after reading all subarray event information, so that we don't
# go out of sync
if len(data.trigger.tels_with_trigger) == 0:
continue

self._fill_array_pointing(data, array_pointing_finder)
self._fill_telescope_pointing(data, tel_pointing_finder)

if self.is_simulation:
data.simulation.shower = next(mc_shower_reader)

for tel_id in data.trigger.tel.keys():
key = f"tel_{tel_id:03d}"
if self.allowed_tels and tel_id not in self.allowed_tels:
Expand Down Expand Up @@ -667,11 +674,6 @@ def _generator(self):
prefix = f"{algorithm}_tel_{c[algorithm].default_prefix}"
c[algorithm].prefix = prefix

for kind, readers in dl2_readers.items():
c = getattr(data.dl2.stereo, kind)
for algorithm, reader in readers.items():
c[algorithm] = next(reader)

yield data
counter += 1

Expand Down

0 comments on commit 5d09d14

Please sign in to comment.