Skip to content

Commit 5d985bc

Browse files
authored
Merge pull request #2965 from cta-observatory/update_monitoring_data_format
Add data quality-related subgroup definitions to HDF5 data format
2 parents 91f5def + 2bc1fa8 commit 5d985bc

6 files changed

Lines changed: 54 additions & 2 deletions

File tree

docs/changes/2965.datamodel.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add data quality monitoring groups to the HDF5 data format specification.

src/ctapipe/io/datawriter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ def _get_tel_index(event, tel_id):
4444
# (meaning readers need to update scripts)
4545
# - increase the minor number if new columns or datasets are added
4646
# - increase the patch number if there is a small bugfix to the model.
47-
DATA_MODEL_VERSION = "v7.3.0"
47+
DATA_MODEL_VERSION = "v7.4.0"
4848
DATA_MODEL_CHANGE_HISTORY = """
49+
- v7.4.0: - Add new data quality and top-level monitoring groups for DL0 and DL1 data.
4950
- v7.3.0: - Add possibility to attach monitoring data to the event HDF5 file.
5051
- Add the event type to the telescope trigger container.
5152
- v7.2.0: - Added new monitoring groups: DL1_TEL_[OPTICAL_PSF, MUON_THROUGHPUT, ILLUMINATOR_THROUGHPUT]_GROUP

src/ctapipe/io/hdf5dataformat.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@
2323
"SIMULATION_PARAMETERS_GROUP",
2424
"R0_TEL_GROUP",
2525
"R1_TEL_GROUP",
26+
"DL0_TEL_MONITORING_GROUP",
27+
"DL0_SUBARRAY_MONITORING_GROUP",
28+
"DL0_TEL_QUALITY_GROUP",
29+
"DL0_SUBARRAY_QUALITY_GROUP",
30+
"DL1_TEL_MONITORING_GROUP",
31+
"DL1_SUBARRAY_MONITORING_GROUP",
32+
"DL1_SUBARRAY_QUALITY_GROUP",
33+
"DL1_TEL_QUALITY_GROUP",
2634
"DL1_SUBARRAY_GROUP",
2735
"DL1_SUBARRAY_TRIGGER_TABLE",
2836
"DL1_TEL_GROUP",
@@ -101,6 +109,14 @@
101109
DL2_SUBARRAY_PARTICLETYPE_GROUP = "/dl2/event/subarray/particle_type"
102110

103111
# Monitoring group
112+
DL0_TEL_MONITORING_GROUP = "/dl0/monitoring/telescope"
113+
DL0_SUBARRAY_MONITORING_GROUP = "/dl0/monitoring/subarray"
114+
DL0_TEL_QUALITY_GROUP = "/dl0/monitoring/telescope/quality"
115+
DL0_SUBARRAY_QUALITY_GROUP = "/dl0/monitoring/subarray/quality"
116+
DL1_TEL_MONITORING_GROUP = "/dl1/monitoring/telescope"
117+
DL1_SUBARRAY_MONITORING_GROUP = "/dl1/monitoring/subarray"
118+
DL1_TEL_QUALITY_GROUP = "/dl1/monitoring/telescope/quality"
119+
DL1_SUBARRAY_QUALITY_GROUP = "/dl1/monitoring/subarray/quality"
104120
DL0_TEL_POINTING_GROUP = "/dl0/monitoring/telescope/pointing"
105121
DL1_SUBARRAY_POINTING_GROUP = "/dl1/monitoring/subarray/pointing"
106122
DL1_TEL_POINTING_GROUP = "/dl1/monitoring/telescope/pointing"

src/ctapipe/io/hdf5eventsource.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
"v7.1.0",
107107
"v7.2.0",
108108
"v7.3.0",
109+
"v7.4.0",
109110
]
110111

111112

src/ctapipe/io/hdf5merger.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@
1414
from ..utils.arrays import recarray_drop_columns
1515
from . import metadata
1616
from .hdf5dataformat import (
17+
DL0_SUBARRAY_QUALITY_GROUP,
1718
DL0_TEL_POINTING_GROUP,
19+
DL0_TEL_QUALITY_GROUP,
1820
DL1_CAMERA_COEFFICIENTS_GROUP,
1921
DL1_COLUMN_NAMES,
2022
DL1_IMAGE_STATISTICS_TABLE,
2123
DL1_PIXEL_STATISTICS_GROUP,
2224
DL1_SUBARRAY_POINTING_GROUP,
25+
DL1_SUBARRAY_QUALITY_GROUP,
2326
DL1_SUBARRAY_TRIGGER_TABLE,
2427
DL1_TEL_CALIBRATION_GROUP,
2528
DL1_TEL_ILLUMINATOR_THROUGHPUT_GROUP,
@@ -29,6 +32,7 @@
2932
DL1_TEL_OPTICAL_PSF_GROUP,
3033
DL1_TEL_PARAMETERS_GROUP,
3134
DL1_TEL_POINTING_GROUP,
35+
DL1_TEL_QUALITY_GROUP,
3236
DL1_TEL_TRIGGER_TABLE,
3337
DL2_EVENT_STATISTICS_GROUP,
3438
DL2_SUBARRAY_CROSS_CALIBRATION_GROUP,
@@ -53,6 +57,7 @@
5357
COMPATIBLE_DATA_MODEL_VERSIONS = [
5458
"v7.2.0",
5559
"v7.3.0",
60+
"v7.4.0",
5661
]
5762

5863

@@ -475,9 +480,11 @@ def _append_monitoring_data(self, other):
475480
"""Append monitoring data (pointing, calibration, throughput, pixel statistics)."""
476481
self._append_monitoring_subarray_groups(other)
477482
self._append_monitoring_dl2_groups(other)
483+
self._append_quality_subarray_groups(other)
478484
if self.telescope_events:
479485
self._append_monitoring_telescope_groups(other)
480486
self._append_pixel_statistics(other)
487+
self._append_quality_telescope_groups(other)
481488

482489
def _append_monitoring_subarray_groups(self, other):
483490
"""Append monitoring subarray groups."""
@@ -523,6 +530,32 @@ def _append_pixel_statistics(self, other):
523530
other, other.root[key], once=self.single_ob
524531
)
525532

533+
def _append_quality_telescope_groups(self, other):
534+
"""Append quality telescope groups.
535+
536+
Traverses ``DL0_TEL_QUALITY_GROUP`` and ``DL1_TEL_QUALITY_GROUP`` and
537+
appends all subgroups, which have the structure
538+
``{quality_group}/{metric}/{tel_XXX}``.
539+
"""
540+
for root_group in (DL0_TEL_QUALITY_GROUP, DL1_TEL_QUALITY_GROUP):
541+
if root_group not in other.root:
542+
continue
543+
for metric_group in other.root[root_group]._f_iter_nodes("Group"):
544+
self._append_table_group(other, metric_group, once=self.single_ob)
545+
546+
def _append_quality_subarray_groups(self, other):
547+
"""Append quality subarray groups.
548+
549+
Traverses ``DL0_SUBARRAY_QUALITY_GROUP`` and ``DL1_SUBARRAY_QUALITY_GROUP``
550+
and appends all subgroups, which have the structure
551+
``{quality_group}/{array_element}/{metric}``.
552+
"""
553+
for root_group in (DL0_SUBARRAY_QUALITY_GROUP, DL1_SUBARRAY_QUALITY_GROUP):
554+
if root_group not in other.root:
555+
continue
556+
for elem_group in other.root[root_group]._f_iter_nodes("Group"):
557+
self._append_table_group(other, elem_group, once=self.single_ob)
558+
526559
def _append_statistics_data(self, other):
527560
"""Append processing statistics data."""
528561
# quality query statistics

src/ctapipe/io/tests/test_hdf5eventsource.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_is_compatible(compatible_file, request):
3131
def test_metadata(dl1_file):
3232
with HDF5EventSource(input_url=dl1_file) as source:
3333
assert source.is_simulation
34-
assert source.datamodel_version == (7, 3, 0)
34+
assert source.datamodel_version == (7, 4, 0)
3535
assert set(source.datalevels) == {
3636
DataLevel.DL1_IMAGES,
3737
DataLevel.DL1_PARAMETERS,

0 commit comments

Comments
 (0)