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

Add property to EventSource for support of CTAO reference metadata #2644

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions docs/changes/2644.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Since not all ``EventSource`` plugins support providing the CTAO reference metadata,
the ``EventSource`` now has a property ``supports_reference_metadata`` which can
be overridden by subclasses to signal the support for reading reference metadata.

This avoids a warning for not being able to read reference metadata for
sources that cannot support it (yet), like the ``SimTelEventSource``.
9 changes: 8 additions & 1 deletion src/ctapipe/io/eventsource.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,14 @@ def __init__(self, input_url=None, config=None, parent=None, **kwargs):
if self.max_events:
self.log.info(f"Max events being read = {self.max_events}")

Provenance().add_input_file(str(self.input_url), role="DL0/Event")
add_meta = self.supports_reference_metadata
Provenance().add_input_file(
str(self.input_url), role="DL0/Event", add_meta=add_meta
)

@property
def supports_reference_metadata(self) -> bool:
return True

@staticmethod
@abstractmethod
Expand Down
6 changes: 4 additions & 2 deletions src/ctapipe/io/simteleventsource.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,6 @@ def read_atmosphere_profile_from_simtel(

if isinstance(simtelfile, str | Path):
context_manager = SimTelFile(simtelfile)
# FIXME: simtel files currently do not have CTAO reference
# metadata, should be set to True once we store metadata
Provenance().add_input_file(
filename=simtelfile,
role="ctapipe.atmosphere.AtmosphereDensityProfile",
Expand Down Expand Up @@ -568,6 +566,10 @@ def close(self):
def is_simulation(self):
return True

@property
def supports_reference_metadata(self) -> bool:
return False

@property
def datalevels(self):
return (DataLevel.R0, DataLevel.R1)
Expand Down