Coverage for python / lsst / obs / lsst / translators / lsstCamSim.py: 54%
35 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-28 09:11 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-28 09:11 +0000
1# This file is currently part of obs_lsst but is written to allow it
2# to be migrated to the astro_metadata_translator package at a later date.
3#
4# This product includes software developed by the LSST Project
5# (http://www.lsst.org).
6# See the LICENSE file in this directory for details of code ownership.
7#
8# Use of this source code is governed by a 3-clause BSD-style
9# license that can be found in the LICENSE file.
11"""Metadata translation code for the Simulated LSST Camera"""
13__all__ = ("LsstCamSimTranslator",)
15import logging
16import astropy
18from astro_metadata_translator import cache_translation
20from .lsstCam import LsstCamTranslator
21from .lsst import SIMONYI_TELESCOPE
23log = logging.getLogger(__name__)
26class LsstCamSimTranslator(LsstCamTranslator):
27 """Metadata translation for the simulated LSST Camera."""
29 name = "LSSTCamSim"
30 """Name of this translation class"""
32 _const_map = {
33 "instrument": "LSSTCamSim",
34 "has_simulated_content": True,
35 }
37 cameraPolicyFile = "policy/lsstCamSim.yaml"
39 # Allowed to use obstype for can_see_sky fallback.
40 _can_check_obstype_for_can_see_sky = True
42 @classmethod
43 def can_translate(cls, header, filename=None):
44 """Indicate whether this translation class can translate the
45 supplied header.
47 Parameters
48 ----------
49 header : `dict`-like
50 Header to convert to standardized form.
51 filename : `str`, optional
52 Name of file being translated.
54 Returns
55 -------
56 can : `bool`
57 `True` if the header is recognized by this class. `False`
58 otherwise.
59 """
60 if "INSTRUME" in header and "TELESCOP" in header:
61 telescope = header["TELESCOP"]
62 instrument = header["INSTRUME"].lower()
63 if instrument == "lsstcamsim" and telescope in (SIMONYI_TELESCOPE, "LSST"):
64 return True
66 return False
68 @classmethod
69 def fix_header(cls, header, instrument, obsid, filename=None):
70 """Fix Simulated LSSTCamSim headers.
72 Notes
73 -----
74 Content will be added as needed.
76 Corrections are reported as debug level log messages.
78 See `~astro_metadata_translator.fix_header` for details of the general
79 process.
80 """
81 modified = False
83 # Currently, no fixes are required.
85 return modified
87 @classmethod
88 def observing_date_to_offset(cls, observing_date: astropy.time.Time) -> astropy.time.TimeDelta | None:
89 # Always use the 12 hour offset.
90 return cls._ROLLOVER_TIME
92 def _is_on_mountain(self):
93 """Indicate whether these data are coming from the instrument
94 installed on the mountain.
96 Returns
97 -------
98 is : `bool`
99 `True` if instrument is on the mountain.
101 Notes
102 -----
103 Simulated LSSTCam is always on the mountain.
104 """
105 return True
107 @cache_translation
108 def to_altaz_end(self):
109 # Tries to calculate the value. Simulated files for ops-rehearsal 3
110 # did not have the AZ/EL headers defined.
111 if self.are_keys_ok(["ELEND", "AZEND"]):
112 return super().to_altaz_end()
113 # Do not attempt to calculate anything in this situation since it is
114 # never going to be correct.
115 return None