Skip to content

Commit

Permalink
Start updating docs for new container structure
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnoe committed Jul 11, 2023
1 parent 2337085 commit 4a89afe
Show file tree
Hide file tree
Showing 23 changed files with 300 additions and 189 deletions.
2 changes: 1 addition & 1 deletion ctapipe/calib/camera/calibrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,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)
Expand Down
2 changes: 1 addition & 1 deletion ctapipe/calib/camera/flatfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions ctapipe/calib/camera/pedestals.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
46 changes: 24 additions & 22 deletions ctapipe/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]


Expand Down Expand Up @@ -182,7 +184,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
Expand Down Expand Up @@ -609,7 +611,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.
"""

Expand Down Expand Up @@ -1221,7 +1223,7 @@ class SubarrayEventContainer(Container):
count = Field(0, description="number of events processed")

index = Field(
default_factory=ArrayEventIndexContainer,
default_factory=SubarrayEventIndexContainer,
description="event indexing information",
)

Expand Down
3 changes: 2 additions & 1 deletion ctapipe/image/image_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
IntensityStatisticsContainer,
PeakTimeStatisticsContainer,
SubarrayEventContainer,
TelescopeEventContainer,
TimingParametersContainer,
)
from ..core import QualityQuery, TelescopeComponent
Expand Down Expand Up @@ -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
"""
Expand Down
2 changes: 1 addition & 1 deletion ctapipe/image/muon/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions ctapipe/io/eventsource.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions ctapipe/io/hdf5eventsource.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from ctapipe.instrument.optics import FocalLengthKind

from ..containers import (
ArrayEventIndexContainer,
CameraHillasParametersContainer,
CameraTimingParametersContainer,
ConcentrationContainer,
Expand Down Expand Up @@ -41,6 +40,7 @@
SimulationSubarrayContainer,
SimulationTelescopeContainer,
SubarrayEventContainer,
SubarrayEventIndexContainer,
SubarrayTriggerContainer,
TelescopeEventContainer,
TelescopeEventIndexContainer,
Expand Down Expand Up @@ -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
----------
Expand Down Expand Up @@ -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_)

Expand Down Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions ctapipe/io/simteleventsource.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
)
from ..calib.camera.gainselection import GainSelector
from ..containers import (
ArrayEventIndexContainer,
CoordinateFrameType,
DL0SubarrayContainer,
DL0TelescopeContainer,
Expand All @@ -42,6 +41,7 @@
SimulationSubarrayContainer,
SimulationTelescopeContainer,
SubarrayEventContainer,
SubarrayEventIndexContainer,
SubarrayPointingContainer,
SubarrayTriggerContainer,
TelescopeCalibrationContainer,
Expand Down Expand Up @@ -740,7 +740,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
Expand Down
4 changes: 2 additions & 2 deletions ctapipe/io/toymodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion ctapipe/reco/hillas_intersection.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,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.
Expand Down
2 changes: 1 addition & 1 deletion ctapipe/reco/hillas_reconstructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,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.
Expand Down
2 changes: 1 addition & 1 deletion ctapipe/reco/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ctapipe/reco/reconstructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion ctapipe/reco/shower_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions ctapipe/reco/sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def __call__(self, event: SubarrayEventContainer) -> None:
Parameters
----------
event: ArrayEventContainer
event: SubarrayEventContainer
"""

@abstractmethod
Expand Down Expand Up @@ -677,7 +677,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)
Expand Down
5 changes: 3 additions & 2 deletions ctapipe/tools/tests/test_apply_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion docs/ctapipe_api/containers/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/ctapipe_api/io/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 4a89afe

Please sign in to comment.