diff --git a/docs/changes/2644.feature.rst b/docs/changes/2644.feature.rst new file mode 100644 index 00000000000..5711d0a03ee --- /dev/null +++ b/docs/changes/2644.feature.rst @@ -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``. diff --git a/src/ctapipe/io/eventsource.py b/src/ctapipe/io/eventsource.py index b6edb9859fe..14822539e59 100644 --- a/src/ctapipe/io/eventsource.py +++ b/src/ctapipe/io/eventsource.py @@ -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 diff --git a/src/ctapipe/io/simteleventsource.py b/src/ctapipe/io/simteleventsource.py index 175914fbbe9..8daad5e5bb6 100644 --- a/src/ctapipe/io/simteleventsource.py +++ b/src/ctapipe/io/simteleventsource.py @@ -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", @@ -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)