diff --git a/ctapipe/calib/camera/calibrator.py b/ctapipe/calib/camera/calibrator.py index 6fd3d1ec542..60cb1e4fe75 100644 --- a/ctapipe/calib/camera/calibrator.py +++ b/ctapipe/calib/camera/calibrator.py @@ -302,7 +302,7 @@ def __call__(self, event): Parameters ---------- event : container - A `~ctapipe.containers.ArrayEventContainer` event container + A `~ctapipe.containers.SubarrayEventContainer` event container """ for tel_event in event.tel.values(): self.calibrate_tel_event(tel_event) diff --git a/ctapipe/calib/camera/flatfield.py b/ctapipe/calib/camera/flatfield.py index 3a3139ebcf0..d461e69a04a 100644 --- a/ctapipe/calib/camera/flatfield.py +++ b/ctapipe/calib/camera/flatfield.py @@ -108,7 +108,7 @@ def calculate_relative_gain(self, event): Parameters ---------- - event: ctapipe.containers.ArrayEventContainer + event: ctapipe.containers.SubarrayEventContainer Returns: True if the mon.tel[tel_id].flatfield is updated, False otherwise diff --git a/ctapipe/calib/camera/pedestals.py b/ctapipe/calib/camera/pedestals.py index 56a859db62c..4c7ff3385d2 100644 --- a/ctapipe/calib/camera/pedestals.py +++ b/ctapipe/calib/camera/pedestals.py @@ -134,7 +134,7 @@ def calculate_pedestals(self, event): Parameters ---------- - event: ctapipe.containers.ArrayEventContainer + event: ctapipe.containers.SubarrayEventContainer Returns: True if the mon.tel[tel_id].pedestal is updated, False otherwise @@ -203,12 +203,12 @@ def _extract_charge(self, event) -> DL1TelescopeContainer: Parameters ---------- - event: ArrayEventContainer + event: SubarrayEventContainer general event container Returns ------- - DL1CameraContainer + DL1TelescopeContainer """ waveforms = event.tel[self.tel_id].r1.waveform selected_gain_channel = event.tel[self.tel_id].r1.selected_gain_channel diff --git a/ctapipe/containers.py b/ctapipe/containers.py index 7e2d2ab49c2..6a6a8be1c95 100644 --- a/ctapipe/containers.py +++ b/ctapipe/containers.py @@ -12,49 +12,51 @@ from .core import Container, Field, Map __all__ = [ - "SubarrayEventContainer", + "BaseHillasParametersContainer", + "BaseTimingParametersContainer", + "CameraHillasParametersContainer", + "CameraTimingParametersContainer", "ConcentrationContainer", + "CoreParametersContainer", "DL0TelescopeContainer", "DL1CameraCalibrationContainer", "DL1TelescopeContainer", "DL2SubarrayContainer", - "TelescopeCalibrationContainer", - "ArrayEventIndexContainer", + "DispContainer", "EventType", "FlatFieldContainer", "HillasParametersContainer", - "CoreParametersContainer", "ImageParametersContainer", + "IntensityStatisticsContainer", "LeakageContainer", - "TelescopeMonitoringContainer", "MorphologyContainer", - "BaseHillasParametersContainer", - "CameraHillasParametersContainer", - "CameraTimingParametersContainer", + "ObservationBlockContainer", + "ObservationBlockState", + "ObservingMode", "ParticleClassificationContainer", + "PeakTimeStatisticsContainer", "PedestalContainer", "PixelStatusContainer", "R0TelescopeContainer", "R1TelescopeContainer", + "ReconstructedShowerContainer", "ReconstructedEnergyContainer", "ReconstructedGeometryContainer", - "DispContainer", - "SimulationTelescopeContainer", + "SchedulingBlockContainer", "SimulatedShowerContainer", "SimulatedShowerDistribution", "SimulationConfigContainer", + "SimulationTelescopeContainer", + "StatisticsContainer", + "SubarrayEventContainer", + "SubarrayEventIndexContainer", + "SubarrayTriggerContainer", + "TelescopeCalibrationContainer", + "TelescopeEventContainer", "TelescopeEventIndexContainer", - "BaseTimingParametersContainer", + "TelescopeMonitoringContainer", "TimingParametersContainer", - "SubarrayTriggerContainer", "WaveformCalibrationContainer", - "StatisticsContainer", - "IntensityStatisticsContainer", - "PeakTimeStatisticsContainer", - "SchedulingBlockContainer", - "ObservationBlockContainer", - "ObservingMode", - "ObservationBlockState", ] @@ -246,7 +248,7 @@ class TelescopeEventType(enum.Enum): UNKNOWN = 255 -class ArrayEventIndexContainer(Container): +class SubarrayEventIndexContainer(Container): """index columns to include in event lists, common to all data levels""" default_prefix = "" # don't want to prefix these @@ -739,7 +741,7 @@ class SimulatedShowerContainer(Container): class SimulationTelescopeContainer(Container): """ - True images and parameters derived from them, analgous to the `DL1CameraContainer` + True images and parameters derived from them, analgous to the `DL1TelescopeContainer` but for simulated data. """ @@ -1359,7 +1361,7 @@ class SubarrayEventContainer(Container): count = Field(0, description="number of events processed") index = Field( - default_factory=ArrayEventIndexContainer, + default_factory=SubarrayEventIndexContainer, description="event indexing information", ) diff --git a/ctapipe/image/image_processor.py b/ctapipe/image/image_processor.py index fd9f7c2ab68..f84289860d1 100644 --- a/ctapipe/image/image_processor.py +++ b/ctapipe/image/image_processor.py @@ -14,6 +14,7 @@ IntensityStatisticsContainer, PeakTimeStatisticsContainer, SubarrayEventContainer, + TelescopeEventContainer, TimingParametersContainer, ) from ..core import QualityQuery, TelescopeComponent @@ -210,7 +211,7 @@ def _parameterize_image( # parameterization return default - def _process_telescope_event(self, tel_event): + def _process_telescope_event(self, tel_event: TelescopeEventContainer): """ Loop over telescopes and process the calibrated images into parameters """ diff --git a/ctapipe/image/muon/processor.py b/ctapipe/image/muon/processor.py index 1fac1270f6f..5eb11ac01de 100644 --- a/ctapipe/image/muon/processor.py +++ b/ctapipe/image/muon/processor.py @@ -124,7 +124,7 @@ def _process_telescope_event(self, tel_event): Parameters ---------- - event: ArrayEventContainer + event: SubarrayEventContainer Collection of all event information tel_id: int Telescope ID of the instrument that has measured the image diff --git a/ctapipe/io/eventsource.py b/ctapipe/io/eventsource.py index b545fdb3e8d..a151709cdec 100644 --- a/ctapipe/io/eventsource.py +++ b/ctapipe/io/eventsource.py @@ -28,7 +28,7 @@ class EventSource(Component): """ Parent class for EventSources. - EventSources read input files and generate `~ctapipe.containers.ArrayEventContainer` + EventSources read input files and generate `~ctapipe.containers.SubarrayEventContainer` instances when iterated over. A new EventSource should be created for each type of event file read @@ -72,7 +72,7 @@ class EventSource(Component): 0 1 - **NOTE**: EventSource implementations should not reuse the same ArrayEventContainer, + **NOTE**: EventSource implementations should not reuse the same SubarrayEventContainer, as these are mutable and may lead to errors when analyzing multiple events. diff --git a/ctapipe/io/hdf5eventsource.py b/ctapipe/io/hdf5eventsource.py index f2088cdae89..23b9035ed3a 100644 --- a/ctapipe/io/hdf5eventsource.py +++ b/ctapipe/io/hdf5eventsource.py @@ -12,7 +12,6 @@ from ctapipe.instrument.optics import FocalLengthKind from ..containers import ( - ArrayEventIndexContainer, CameraHillasParametersContainer, CameraTimingParametersContainer, ConcentrationContainer, @@ -41,6 +40,7 @@ SimulationSubarrayContainer, SimulationTelescopeContainer, SubarrayEventContainer, + SubarrayEventIndexContainer, SubarrayTriggerContainer, TelescopeEventContainer, TelescopeEventIndexContainer, @@ -138,8 +138,8 @@ class HDF5EventSource(EventSource): specifying the file to be read. Looping over the EventSource yields events from the _generate_events - method. An event equals an ArrayEventContainer instance. - See ctapipe.containers.ArrayEventContainer for details. + method. An event equals an SubarrayEventContainer instance. + See ctapipe.containers.SubarrayEventContainer for details. Attributes ---------- @@ -393,7 +393,7 @@ def _is_hillas_in_camera_frame(self): def _generator(self): """ - Yield ArrayEventContainer to iterate through events. + Yield SubarrayEventContainer to iterate through events. """ self.reader = HDF5TableReader(self.file_) @@ -562,7 +562,7 @@ def _generator(self): # Setup iterators for the array events events = HDF5TableReader(self.file_).read( "/dl0/event/subarray/trigger", - [SubarrayTriggerContainer, ArrayEventIndexContainer], + [SubarrayTriggerContainer, SubarrayEventIndexContainer], ignore_columns={"tel"}, ) telescope_trigger_reader = HDF5TableReader(self.file_).read( diff --git a/ctapipe/io/simteleventsource.py b/ctapipe/io/simteleventsource.py index 24e03764863..b2afea5995b 100644 --- a/ctapipe/io/simteleventsource.py +++ b/ctapipe/io/simteleventsource.py @@ -22,7 +22,6 @@ ) from ..calib.camera.gainselection import GainChannel, GainSelector from ..containers import ( - ArrayEventIndexContainer, CoordinateFrameType, DL0SubarrayContainer, DL0TelescopeContainer, @@ -43,6 +42,7 @@ SimulationSubarrayContainer, SimulationTelescopeContainer, SubarrayEventContainer, + SubarrayEventIndexContainer, SubarrayPointingContainer, SubarrayTriggerContainer, TelescopeCalibrationContainer, @@ -767,7 +767,7 @@ def _generate_events(self): simulation=SimulationSubarrayContainer(shower=shower), dl0=DL0SubarrayContainer(trigger=array_trigger), pointing=self._fill_array_pointing(), - index=ArrayEventIndexContainer(obs_id=obs_id, event_id=event_id), + index=SubarrayEventIndexContainer(obs_id=obs_id, event_id=event_id), ) event.meta["origin"] = "hessio" event.meta["input_url"] = self.input_url diff --git a/ctapipe/io/toymodel.py b/ctapipe/io/toymodel.py index e5abfceb1e4..bfc150552da 100644 --- a/ctapipe/io/toymodel.py +++ b/ctapipe/io/toymodel.py @@ -9,11 +9,11 @@ import numpy as np from ..containers import ( - ArrayEventIndexContainer, DL1TelescopeContainer, ObservationBlockContainer, SchedulingBlockContainer, SubarrayEventContainer, + SubarrayEventIndexContainer, ) from ..core import TelescopeComponent, traits from ..image import toymodel @@ -99,7 +99,7 @@ def _generator(self): def generate_event(self): event = SubarrayEventContainer( - index=ArrayEventIndexContainer(obs_id=1, event_id=self.event_id), + index=SubarrayEventIndexContainer(obs_id=1, event_id=self.event_id), dl0=None, dl2=None, simulation=None, diff --git a/ctapipe/reco/hillas_intersection.py b/ctapipe/reco/hillas_intersection.py index 72f44a2a7c3..3447ab91521 100644 --- a/ctapipe/reco/hillas_intersection.py +++ b/ctapipe/reco/hillas_intersection.py @@ -117,7 +117,7 @@ def __call__(self, event): Parameters ---------- - event : `~ctapipe.containers.ArrayEventContainer` + event : `~ctapipe.containers.SubarrayEventContainer` The event, needs to have dl1 parameters. Will be filled with the corresponding dl2 containers, reconstructed stereo geometry and telescope-wise impact position. diff --git a/ctapipe/reco/hillas_reconstructor.py b/ctapipe/reco/hillas_reconstructor.py index e8ea02ea693..68725debc43 100644 --- a/ctapipe/reco/hillas_reconstructor.py +++ b/ctapipe/reco/hillas_reconstructor.py @@ -135,7 +135,7 @@ def __call__(self, event): Parameters ---------- - event : `~ctapipe.containers.ArrayEventContainer` + event : `~ctapipe.containers.SubarrayEventContainer` The event, needs to have dl1 parameters. Will be filled with the corresponding dl2 containers, reconstructed stereo geometry and telescope-wise impact position. diff --git a/ctapipe/reco/preprocessing.py b/ctapipe/reco/preprocessing.py index d7fd8f5f958..2822a164783 100644 --- a/ctapipe/reco/preprocessing.py +++ b/ctapipe/reco/preprocessing.py @@ -75,7 +75,7 @@ def collect_features( Parameters ---------- - event : ArrayEventContainer + event : SubarrayEventContainer The event container from which to collect the features tel_id : int The telscope id for which to collect the features diff --git a/ctapipe/reco/reconstructor.py b/ctapipe/reco/reconstructor.py index 1803a13b4c4..af32ae73020 100644 --- a/ctapipe/reco/reconstructor.py +++ b/ctapipe/reco/reconstructor.py @@ -87,7 +87,7 @@ def __call__(self, event: SubarrayEventContainer): Parameters ---------- - event : `ctapipe.containers.ArrayEventContainer` + event : `ctapipe.containers.SubarrayEventContainer` The event, needs to have dl1 parameters. Will be filled with the corresponding dl2 containers, reconstructed stereo geometry and telescope-wise impact position. diff --git a/ctapipe/reco/shower_processor.py b/ctapipe/reco/shower_processor.py index 86e3b267d37..b9e0b64e416 100644 --- a/ctapipe/reco/shower_processor.py +++ b/ctapipe/reco/shower_processor.py @@ -75,7 +75,7 @@ def __call__(self, event: SubarrayEventContainer): Parameters ---------- - event : ctapipe.containers.ArrayEventContainer + event : ctapipe.containers.SubarrayEventContainer Top-level container for all event information. """ for reconstructor in self.reconstructors: diff --git a/ctapipe/reco/sklearn.py b/ctapipe/reco/sklearn.py index cd5390b9ac3..b12fb6f457b 100644 --- a/ctapipe/reco/sklearn.py +++ b/ctapipe/reco/sklearn.py @@ -161,7 +161,7 @@ def __call__(self, event: SubarrayEventContainer) -> None: Parameters ---------- - event: ArrayEventContainer + event: SubarrayEventContainer """ @abstractmethod @@ -680,7 +680,7 @@ def __call__(self, event: SubarrayEventContainer) -> None: Parameters ---------- - event: ArrayEventContainer + event: SubarrayEventContainer """ for tel_id, tel_event in event.tel.items(): table = collect_features(event, tel_id, self.instrument_table) diff --git a/ctapipe/tools/tests/test_apply_models.py b/ctapipe/tools/tests/test_apply_models.py index 46da23349d1..df49866af1b 100644 --- a/ctapipe/tools/tests/test_apply_models.py +++ b/ctapipe/tools/tests/test_apply_models.py @@ -2,10 +2,10 @@ import pytest from ctapipe.containers import ( - ArrayEventIndexContainer, ParticleClassificationContainer, ReconstructedEnergyContainer, ReconstructedGeometryContainer, + SubarrayEventIndexContainer, ) from ctapipe.core import run_tool from ctapipe.core.tool import ToolConfigurationError @@ -42,7 +42,8 @@ def test_apply_energy_regressor( table = read_table(output_path, f"/dl2/event/subarray/energy/{prefix}") for col in "obs_id", "event_id": assert ( - table[col].description == ArrayEventIndexContainer.fields[col].description + table[col].description + == SubarrayEventIndexContainer.fields[col].description ) for name, field in ReconstructedEnergyContainer.fields.items(): diff --git a/docs/api-reference/containers/index.rst b/docs/api-reference/containers/index.rst index 5be56a863e5..15cbdfc15f1 100644 --- a/docs/api-reference/containers/index.rst +++ b/docs/api-reference/containers/index.rst @@ -13,7 +13,7 @@ The `ctapipe.containers` module contains the data model definition of all ctapipe `~ctapipe.core.Container` classes, which provide the container definitions for all ctapipe data. -The base Container for an event is in `ctapipe.containers.ArrayEventContainer`. +The base Container for an event is in `ctapipe.containers.SubarrayEventContainer`. Reference/API diff --git a/docs/api-reference/io/index.rst b/docs/api-reference/io/index.rst index 82f18d7c908..73bdbfe7b9d 100644 --- a/docs/api-reference/io/index.rst +++ b/docs/api-reference/io/index.rst @@ -131,7 +131,7 @@ Writing Output Files: ===================== The `DataWriter` Component allows one to write a series of events (stored in -`ctapipe.containers.ArrayEventContainer`) to a standardized HDF5 format file +`ctapipe.containers.SubarrayEventContainer`) to a standardized HDF5 format file following the data model (see :ref:`datamodels`). This includes all related datasets such as the instrument and simulation configuration information, simulated shower and image information, observed images and parameters and reconstruction diff --git a/docs/user-guide/data_models/dl1.rst b/docs/user-guide/data_models/dl1.rst index f792d495074..126f14acd34 100644 --- a/docs/user-guide/data_models/dl1.rst +++ b/docs/user-guide/data_models/dl1.rst @@ -35,16 +35,16 @@ The following datasets will be written to the group ``/dl1/event/`` in the outp - (group) * - ``subarray/trigger`` - subarray trigger information - - :py:class:`~ctapipe.containers.EventIndexContainer` +, :py:class:`~ctapipe.containers.TriggerContainer` + - :py:class:`~ctapipe.containers.SubarrayEventIndexContainer` +, :py:class:`~ctapipe.containers.SubarrayTriggerContainer` * - ``telescope/`` - Per-telescope Per-event information - (group) * - ``telescope/parameters/tel_{TEL_ID:03d}`` - tables of image parameters (one per telescope) - - :py:class:`~ctapipe.containers.TelEventIndexContainer` +, :py:class:`~ctapipe.containers.ImageParametersContainer` + - :py:class:`~ctapipe.containers.TelescopeEventIndexContainer` +, :py:class:`~ctapipe.containers.ImageParametersContainer` * - ``telescope/images/tel_{TEL_ID:03d}`` - tables of telescope images (one per telescope) - - :py:class:`~ctapipe.containers.TelEventIndexContainer` +, :py:class:`~ctapipe.containers.DL1CameraContainer` + - :py:class:`~ctapipe.containers.TelescopeEventIndexContainer` +, :py:class:`~ctapipe.containers.DL1TelescopeContainer` -------------- DL2 Data Model @@ -65,26 +65,26 @@ output file, where ```` is the identifier of the algorithm (e.g. - Contents * - /geometry - shower geometry reconstruction - - :py:class:`~ctapipe.containers.EventIndexContainer`, :py:class:`~ctapipe.containers.ReconstructedGeometryContainer` + - :py:class:`~ctapipe.containers.SubarrayEventIndexContainer`, :py:class:`~ctapipe.containers.ReconstructedGeometryContainer` * - /energy - shower energy reconstruction - - :py:class:`~ctapipe.containers.EventIndexContainer`, :py:class:`~ctapipe.containers.ReconstructedEnergyContainer` + - :py:class:`~ctapipe.containers.SubarrayEventIndexContainer`, :py:class:`~ctapipe.containers.ReconstructedEnergyContainer` * - /classification - shower classification parameters - - :py:class:`~ctapipe.containers.EventIndexContainer`, :py:class:`~ctapipe.containers.ParticleClassificationContainer` + - :py:class:`~ctapipe.containers.SubarrayEventIndexContainer`, :py:class:`~ctapipe.containers.ParticleClassificationContainer` --------------------- Simulation Data Model --------------------- * - ``/simulation/event/subarray/shower`` - true shower parameters from Monte-Carlo simulation - - :py:class:`~ctapipe.containers.EventIndexContainer` +, :py:class:`~ctapipe.containers.SimulatedShowerContainer` + - :py:class:`~ctapipe.containers.SubarrayEventIndexContainer` +, :py:class:`~ctapipe.containers.SimulatedShowerContainer` * - ``/simulation/event/telescope/images/tel_{TEL_ID:03d}`` - simulated camera images - - :py:class:`~ctapipe.containers.EventIndexContainer` +, :py:class:`~ctapipe.containers.SimulatedCameraContainer` + - :py:class:`~ctapipe.containers.SubarrayEventIndexContainer` +, :py:class:`~ctapipe.containers.SimulatedCameraContainer` * - ``/simulation/event/telescope/parameters/tel_{TEL_ID:03d}`` - Parameters derived form the simulated camera images - - :py:class:`~ctapipe.containers.EventIndexContainer` +, :py:class:`~ctapipe.containers.ImageParametersContainer` + - :py:class:`~ctapipe.containers.SubarrayEventIndexContainer` +, :py:class:`~ctapipe.containers.ImageParametersContainer` * - ``/simulation/service/shower_distribution`` - simulated shower distribution histograms - :py:class:`~ctapipe.containers.SimulatedShowerDistribution`