Skip to content

Commit 9d89f51

Browse files
authored
Merge pull request #2763 from cta-observatory/naming_particle_class
Rename 'classification' field from ReconstructedContainer to 'particle_type'
2 parents 51f9eb2 + 93597e8 commit 9d89f51

File tree

11 files changed

+561
-304
lines changed

11 files changed

+561
-304
lines changed

docs/changes/2763.bugfix.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Fix naming mismatch between ``classification`` and ``particle_type`` group
2+
in ``HDF5EventSource``.
3+
Rename the ``classification`` field from ``ReconstructedContainer`` to
4+
``particle_type``.

docs/user-guide/data_format/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ output file, where ``<algorithm>`` is the identifier of the algorithm
107107
* - /energy
108108
- shower energy reconstruction
109109
- :py:class:`~ctapipe.containers.EventIndexContainer`, :py:class:`~ctapipe.containers.ReconstructedEnergyContainer`
110-
* - /classification
110+
* - /particle_type
111111
- shower classification parameters
112112
- :py:class:`~ctapipe.containers.EventIndexContainer`, :py:class:`~ctapipe.containers.ParticleClassificationContainer`
113113

src/ctapipe/containers.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import enum
6+
import warnings
67
from functools import partial
78

89
import numpy as np
@@ -1078,11 +1079,35 @@ class ReconstructedContainer(Container):
10781079
default_factory=partial(Map, ReconstructedEnergyContainer),
10791080
description="map of algorithm to reconstructed energy parameters",
10801081
)
1081-
classification = Field(
1082+
particle_type = Field(
10821083
default_factory=partial(Map, ParticleClassificationContainer),
10831084
description="map of algorithm to classification parameters",
10841085
)
10851086

1087+
@staticmethod
1088+
def _warn_classification_deprecated():
1089+
from ctapipe.utils.deprecation import CTAPipeDeprecationWarning
1090+
1091+
warnings.warn(
1092+
"The 'classification' field from 'ReconstructedContainer' was "
1093+
"renamed and will be deleted in future versions. Use "
1094+
"'particle_type' instead. "
1095+
"E.g. switch from 'event.dl2.{tel,stereo}.classification' to "
1096+
"'event.dl2.{tel,stereo}.particle_type'.",
1097+
CTAPipeDeprecationWarning,
1098+
stacklevel=3,
1099+
)
1100+
1101+
@property
1102+
def classification(self):
1103+
self._warn_classification_deprecated()
1104+
return self.particle_type
1105+
1106+
@classification.setter
1107+
def classification(self, value):
1108+
self._warn_classification_deprecated()
1109+
self.particle_type = value
1110+
10861111

10871112
class TelescopeReconstructedContainer(ReconstructedContainer):
10881113
"""Telescope-wise reconstructed quantities"""

src/ctapipe/io/datawriter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def _get_tel_index(event, tel_id):
4848
DATA_MODEL_CHANGE_HISTORY = """
4949
- v7.2.0: - Added new monitoring groups: DL1_TEL_[OPTICAL_PSF, MUON_THROUGHPUT, ILLUMINATOR_THROUGHPUT]_GROUP
5050
and DL2_SUBARRAY_[MONITORING, INTER_CALIBRATION, CROSS_CALIBRATION]_GROUP
51+
- Change field name in ``ReconstructedContainer`` from 'classification' to 'particle_type'.
5152
- v7.1.0: - Two new fields for the hillas parameters, uncertainties on psi and the transversal cog coordinate.
5253
- v7.0.0: - Use high resolution timestamps for times. CTAO high resolution times
5354
are stored as two uint32: seconds and quarter nanoseconds since 1970-01-01T00:00:00 TAI.
@@ -694,7 +695,7 @@ def _write_dl2_telescope_events(self, event: ArrayEventContainer):
694695
def _write_dl2_stereo_event(self, event: ArrayEventContainer):
695696
"""
696697
write per-telescope DL2 shower information to e.g.
697-
`/dl2/event/stereo/{geometry,energy,classification}/<algorithm_name>`
698+
`/dl2/event/stereo/{geometry,energy,particle_type}/<algorithm_name>`
698699
"""
699700
# pylint: disable=no-self-use
700701
for container_name, algorithm_map in event.dl2.stereo.items():

0 commit comments

Comments
 (0)