Skip to content

Commit

Permalink
Merge pull request #2386 from TjarkMiener/r0r1_merger
Browse files Browse the repository at this point in the history
R0 and R1 waveform merging
  • Loading branch information
kosack authored Sep 6, 2023
2 parents 45bf408 + 28789b9 commit 20f2032
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
22 changes: 22 additions & 0 deletions ctapipe/io/hdf5merger.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class NodeType(enum.Enum):
"/simulation/event/telescope/impact": NodeType.TEL_GROUP,
"/simulation/event/telescope/images": NodeType.TEL_GROUP,
"/simulation/event/telescope/parameters": NodeType.TEL_GROUP,
"/r0/event/telescope": NodeType.TEL_GROUP,
"/r1/event/telescope": NodeType.TEL_GROUP,
"/dl1/event/subarray/trigger": NodeType.TABLE,
"/dl1/event/telescope/trigger": NodeType.TABLE,
"/dl1/event/telescope/images": NodeType.TEL_GROUP,
Expand Down Expand Up @@ -115,6 +117,16 @@ class HDF5Merger(Component):
help="Whether to include parameters calculated on true images in merged output",
).tag(config=True)

r0_waveforms = traits.Bool(
True,
help="Whether to include r0 waveforms in merged output",
).tag(config=True)

r1_waveforms = traits.Bool(
True,
help="Whether to include r1 waveforms in merged output",
).tag(config=True)

dl1_images = traits.Bool(
True,
help="Whether to include dl1 images in merged output",
Expand Down Expand Up @@ -296,6 +308,16 @@ def _append(self, other):
):
self._append_table_group(other, other.root[key])

# R0
key = "/r0/event/telescope/"
if self.telescope_events and self.r0_waveforms and key in other.root:
self._append_table_group(other, other.root[key])

# R1
key = "/r1/event/telescope/"
if self.telescope_events and self.r1_waveforms and key in other.root:
self._append_table_group(other, other.root[key])

# DL1
key = "/dl1/event/subarray/trigger"
if key in other.root:
Expand Down
12 changes: 12 additions & 0 deletions ctapipe/tools/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ class MergeTool(Tool):
"Include telescope-wise data",
"Exclude telescope-wise data",
),
**flag(
"r0-waveforms",
"HDF5Merger.r0_waveforms",
"Include r0 waveforms",
"Exclude r0 waveforms",
),
**flag(
"r1-waveforms",
"HDF5Merger.r1_waveforms",
"Include r1 waveforms",
"Exclude r1 waveforms",
),
**flag(
"dl1-images",
"HDF5Merger.dl1_images",
Expand Down
1 change: 1 addition & 0 deletions docs/changes/2386.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for including r1 and r0 waveforms in the ``ctapipe-merge`` tool.

0 comments on commit 20f2032

Please sign in to comment.