Coverage for python / lsst / obs / lsst / translators / lsstCamSim.py: 54%

35 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-04-17 09:26 +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. 

10 

11"""Metadata translation code for the Simulated LSST Camera""" 

12 

13__all__ = ("LsstCamSimTranslator",) 

14 

15import logging 

16import astropy 

17 

18from astro_metadata_translator import cache_translation 

19 

20from .lsstCam import LsstCamTranslator 

21from .lsst import SIMONYI_TELESCOPE 

22 

23log = logging.getLogger(__name__) 

24 

25 

26class LsstCamSimTranslator(LsstCamTranslator): 

27 """Metadata translation for the simulated LSST Camera.""" 

28 

29 name = "LSSTCamSim" 

30 """Name of this translation class""" 

31 

32 _const_map = { 

33 "instrument": "LSSTCamSim", 

34 "has_simulated_content": True, 

35 } 

36 

37 cameraPolicyFile = "policy/lsstCamSim.yaml" 

38 

39 # Allowed to use obstype for can_see_sky fallback. 

40 _can_check_obstype_for_can_see_sky = True 

41 

42 @classmethod 

43 def can_translate(cls, header, filename=None): 

44 """Indicate whether this translation class can translate the 

45 supplied header. 

46 

47 Parameters 

48 ---------- 

49 header : `dict`-like 

50 Header to convert to standardized form. 

51 filename : `str`, optional 

52 Name of file being translated. 

53 

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 

65 

66 return False 

67 

68 @classmethod 

69 def fix_header(cls, header, instrument, obsid, filename=None): 

70 """Fix Simulated LSSTCamSim headers. 

71 

72 Notes 

73 ----- 

74 Content will be added as needed. 

75 

76 Corrections are reported as debug level log messages. 

77 

78 See `~astro_metadata_translator.fix_header` for details of the general 

79 process. 

80 """ 

81 modified = False 

82 

83 # Currently, no fixes are required. 

84 

85 return modified 

86 

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 

91 

92 def _is_on_mountain(self): 

93 """Indicate whether these data are coming from the instrument 

94 installed on the mountain. 

95 

96 Returns 

97 ------- 

98 is : `bool` 

99 `True` if instrument is on the mountain. 

100 

101 Notes 

102 ----- 

103 Simulated LSSTCam is always on the mountain. 

104 """ 

105 return True 

106 

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