Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DL2 data model and output #1673

Merged
merged 36 commits into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
164d36e
clean up DL2 containers, adding mono reco
kosack Apr 6, 2021
3bcf0a6
refactor DL1Writer to DataWriter
kosack Apr 6, 2021
35ecb7e
more general loop over reconstruction containers
kosack Apr 7, 2021
b7f89d8
allow multiple data levels in reference metadata headers
kosack Apr 7, 2021
000f6db
Merge branch 'master' of https://github.com/cta-observatory/ctapipe i…
kosack Apr 7, 2021
e2a0d3f
update docs
kosack Apr 7, 2021
3484a06
minor doc correction
kosack Apr 7, 2021
93b9846
update __all__
kosack Apr 7, 2021
6c23a30
fix metadata tests (now data level requires list)
kosack Apr 7, 2021
1cb55a0
fix metadata
kosack Apr 7, 2021
166080e
doc fix
kosack Apr 7, 2021
db79283
another doc fix
kosack Apr 7, 2021
132448b
renamed output_data_level to datalevels as in EventSource
kosack Apr 7, 2021
aa58531
fix test
kosack Apr 7, 2021
0567f64
change group names to telescope and subarray to match other data models
kosack Apr 7, 2021
a5de494
also test classification
kosack Apr 7, 2021
8391d5e
added Transform for variable list of tel ids to fixed-length mask
kosack Apr 7, 2021
92de75e
properly transform the tel_ids list to a mask
kosack Apr 7, 2021
455976a
Merge branch 'master' of https://github.com/cta-observatory/ctapipe i…
kosack Apr 27, 2021
14bd56e
Fix test after merge
kosack Apr 27, 2021
e8164d4
Merge branch 'master' of https://github.com/cta-observatory/ctapipe i…
kosack May 12, 2021
f3e4b06
fix test (telid 5 was not in event source)
kosack May 12, 2021
fe70894
Allow regexp in table name for TableWriter.exclude() (#1717)
kosack May 12, 2021
d47b8f8
clean up output and setup
kosack May 12, 2021
497415b
fixed doc reference to old DL1Writer
kosack May 12, 2021
8cb7983
fixed broken link
kosack May 12, 2021
22f498a
more doc fixes
kosack May 12, 2021
3384956
and a few more bad doc links
kosack May 12, 2021
d45855d
Precompile table regex for column exclusion, fixes #1719 (#1720)
maxnoe May 13, 2021
86043d0
changed metadata process id to str for merged runs
kosack May 13, 2021
4b09f79
fix notebook
kosack May 13, 2021
b576126
optimize imports
kosack May 14, 2021
ab2fcbd
use ENUM for DataLevel in metadata
kosack May 14, 2021
6a8798e
fix incorrect help strings
kosack May 14, 2021
03a68b4
remove incorrect R2 data level, add DL4-DL6 plus comments
kosack May 14, 2021
08f56ed
added added generic DL1 data level
kosack May 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 46 additions & 40 deletions ctapipe/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"DL1CameraCalibrationContainer",
"DL1CameraContainer",
"DL1Container",
"DL2Container",
"EventCalibrationContainer",
"EventCameraCalibrationContainer",
"EventIndexContainer",
Expand All @@ -38,7 +39,7 @@
"R1Container",
"ReconstructedContainer",
"ReconstructedEnergyContainer",
"ReconstructedShowerContainer",
"ReconstructedGeometryContainer",
"SimulatedCameraContainer",
"SimulatedShowerContainer",
"SimulatedShowerDistribution",
Expand Down Expand Up @@ -490,17 +491,19 @@ class TriggerContainer(Container):
container_prefix = ""
time = Field(NAN_TIME, "central average time stamp")
tels_with_trigger = Field(
[], "List of telescope ids that triggered the array event"
None, "List of telescope ids that triggered the array event"
)
event_type = Field(EventType.SUBARRAY, "Event type")
tel = Field(Map(TelescopeTriggerContainer), "telescope-wise trigger information")


class ReconstructedShowerContainer(Container):
class ReconstructedGeometryContainer(Container):
kosack marked this conversation as resolved.
Show resolved Hide resolved
"""
Standard output of algorithms reconstructing shower geometry
"""

container_prefix = ""

alt = Field(nan * u.deg, "reconstructed altitude", unit=u.deg)
alt_uncert = Field(nan * u.deg, "reconstructed altitude uncertainty", unit=u.deg)
az = Field(nan * u.deg, "reconstructed azimuth", unit=u.deg)
Expand All @@ -523,20 +526,20 @@ class ReconstructedShowerContainer(Container):
"was properly reconstructed by the algorithm"
),
)
tel_ids = Field(
[], ("list of the telescope ids used in the" " reconstruction of the shower")
)
average_intensity = Field(
nan, "average intensity of the intensities used for reconstruction"
)
goodness_of_fit = Field(nan, "measure of algorithm success (if fit)")
tel_ids = Field(None, "list of tel_ids used if stereo, or None if Mono")


class ReconstructedEnergyContainer(Container):
"""
Standard output of algorithms estimating energy
"""

container_prefix = ""

energy = Field(nan * u.TeV, "reconstructed energy", unit=u.TeV)
energy_uncert = Field(nan * u.TeV, "reconstructed energy uncertainty", unit=u.TeV)
is_valid = Field(
Expand All @@ -547,67 +550,70 @@ class ReconstructedEnergyContainer(Container):
"algorithm"
),
)
tel_ids = Field(
[],
(
"array containing the telescope ids used in the"
" reconstruction of the shower"
),
)
goodness_of_fit = Field(0.0, "goodness of the algorithm fit")
goodness_of_fit = Field(nan, "goodness of the algorithm fit")
tel_ids = Field(None, "list of tel_ids used if stereo, or None if Mono")


class ParticleClassificationContainer(Container):
"""
Standard output of gamma/hadron classification algorithms
"""

container_prefix = ""

# TODO: Do people agree on this? This is very MAGIC-like.
# TODO: Perhaps an integer classification to support different classes?
# TODO: include an error on the prediction?
prediction = Field(
0.0,
nan,
(
"prediction of the classifier, defined between "
"[0,1], where values close to 0 are more "
"gamma-like, and values close to 1 more "
"hadron-like"
),
)
is_valid = Field(
False,
(
"classificator validity flag. True if the "
"predition was successful within the algorithm "
"validity range"
),
)

# TODO: KPK: is this different than the list in the reco
# container? Why repeat?
tel_ids = Field(
[],
(
"array containing the telescope ids used "
"in the reconstruction of the shower"
),
)
goodness_of_fit = Field(0.0, "goodness of the algorithm fit")
is_valid = Field(False, "true if classification parameters are valid")
goodness_of_fit = Field(nan, "goodness of the algorithm fit")
tel_ids = Field(None, "list of tel_ids used if stereo, or None if Mono")


class ReconstructedContainer(Container):
""" collect reconstructed shower info from multiple algorithms """
""" Reconstructed shower info from multiple algorithms """

# Note: there is a reason why the hiererchy is
# `event.dl2.stereo.geometry[algorithm]` and not
# `event.dl2[algorithm].stereo.geometry` and that is because when writing
# the data, the former makes it easier to only write information that a
# particular reconstructor generates, e.g. only write the geometry in cases
# where energy is not yet computed. Some algorithms will compute all three,
# but most will compute only fill or two of these sub-Contaiers:

shower = Field(
Map(ReconstructedShowerContainer), "Map of algorithm name to shower info"
geometry = Field(
Map(ReconstructedGeometryContainer),
"map of algorithm to reconstructed shower parameters",
)
energy = Field(
Map(ReconstructedEnergyContainer), "Map of algorithm name to energy info"
Map(ReconstructedEnergyContainer),
"map of algorithm to reconstructed energy parameters",
)
classification = Field(
Map(ParticleClassificationContainer),
"Map of algorithm name to classification info",
"map of algorithm to classification parameters",
)


class DL2Container(Container):
"""Reconstructed Shower information for a given reconstruction algorithm,
including optionally both per-telescope mono reconstruction and per-shower
stereo reconstructions
"""

tel = Field(
Map(ReconstructedContainer),
"map of tel_id to single-telescope reconstruction (DL2a)",
)
stereo = Field(ReconstructedContainer(), "Stereo Shower reconstruction results")


class TelescopePointingContainer(Container):
Expand Down Expand Up @@ -885,7 +891,7 @@ class ArrayEventContainer(Container):
r1 = Field(R1Container(), "R1 Calibrated Data")
dl0 = Field(DL0Container(), "DL0 Data Volume Reduced Data")
dl1 = Field(DL1Container(), "DL1 Calibrated image")
dl2 = Field(ReconstructedContainer(), "Reconstructed Shower Information")
dl2 = Field(DL2Container(), "DL2 reconstruction info")
simulation = Field(
None, "Simulated Event Information", type=SimulatedEventContainer
)
Expand Down
4 changes: 2 additions & 2 deletions ctapipe/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from .tableio import TableWriter, TableReader
from .datalevels import DataLevel
from .astropy_helpers import read_table
from .dl1writer import DL1Writer
from .datawriter import DataWriter

from ..core.plugins import detect_and_import_io_plugins

Expand All @@ -27,5 +27,5 @@
"DL1EventSource",
"DataLevel",
"read_table",
"DL1Writer",
"DataWriter",
]
22 changes: 14 additions & 8 deletions ctapipe/io/datalevels.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@
class DataLevel(Enum):
"""Enum of the different Data Levels"""

R0 = auto()
R1 = auto()
R2 = auto()
DL0 = auto()
DL1_IMAGES = auto()
DL1_PARAMETERS = auto()
DL2 = auto()
DL3 = auto()
R0 = auto() # Raw data in camera or simulation format
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if you put it with a colon above, it actually works for the sphinx docs:

#: Raw data in ...
R0 = auto()

R1 = auto() # Raw data in common format, with preliminary calibration
DL0 = auto() # raw archived data in common format, with optional zero suppression
DL1 = auto() # processed data
DL1_IMAGES = auto() # processed data up to camera images
DL1_PARAMETERS = auto() # parameters derived from camera images
DL2 = auto() # reconstructed data
DL3 = auto() # reduced reconstructed data

# the rest are not generated by ctapipe, but are listed here in case this
# code is used elsewhere:
DL4 = auto() # binned datasets
DL5 = auto() # science datasets (fluxes)
DL6 = auto() # derived science data (catalogs, etc.)
Loading