From 95cda8533644d63019c1fb1227ab2ec085fdbc8f Mon Sep 17 00:00:00 2001 From: Tim Jenness Date: Thu, 21 Mar 2024 10:23:04 -0700 Subject: [PATCH] Allow translator subclass to specify list of on-sky observation types --- python/astro_metadata_translator/translator.py | 14 ++++++++++++-- .../astro_metadata_translator/translators/decam.py | 4 ++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/python/astro_metadata_translator/translator.py b/python/astro_metadata_translator/translator.py index f37a604a..47b1461e 100644 --- a/python/astro_metadata_translator/translator.py +++ b/python/astro_metadata_translator/translator.py @@ -141,6 +141,16 @@ class MetadataTranslator: `PropertyDefinition`. """ + _sky_observation_types: tuple[str, ...] = ("science", "object") + """Observation types that correspond to an observation where the detector + can see sky photons. This is used by the default implementation of + ``can_see_sky`` determination.""" + + _non_sky_observation_types: tuple[str, ...] = ("bias", "dark") + """Observation types that correspond to an observation where the detector + can not see sky photons. This is used by the default implementation of + ``can_see_sky`` determination.""" + # Static typing requires that we define the standard dynamic properties # statically. if TYPE_CHECKING: @@ -1245,9 +1255,9 @@ def to_can_see_sky(self) -> bool | None: if obs_type is not None: obs_type = obs_type.lower() - if obs_type in ("science", "object"): + if obs_type in self._sky_observation_types: return True - if obs_type in ("bias", "dark"): + if obs_type in self._non_sky_observation_types: return False return None diff --git a/python/astro_metadata_translator/translators/decam.py b/python/astro_metadata_translator/translators/decam.py index d84162b0..3e01ed85 100644 --- a/python/astro_metadata_translator/translators/decam.py +++ b/python/astro_metadata_translator/translators/decam.py @@ -80,6 +80,10 @@ class DecamTranslator(FitsTranslator): # the same offset used by the Vera Rubin Observatory of 12 hours. _observing_day_offset = astropy.time.TimeDelta(12 * 3600, format="sec", scale="tai") + # List from Frank Valdes (2024-03-21). + _sky_observation_types: tuple[str, ...] = ("science", "object", "standard", "sky flat") + _non_sky_observation_types: tuple[str, ...] = ("zero", "dark", "dome flat") + # Unique detector names are currently not used but are read directly from # header. # The detector_group could be N or S with detector_name corresponding