Coverage for python/lsst/obs/lsst/translators/comCamSim.py: 53%

28 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2024-03-19 02:40 -0700

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 Commissioning Camera""" 

12 

13__all__ = ("LsstComCamSimTranslator", ) 

14 

15import logging 

16 

17from .lsstCam import LsstCamTranslator 

18from .lsst import SIMONYI_TELESCOPE 

19 

20log = logging.getLogger(__name__) 

21 

22 

23class LsstComCamSimTranslator(LsstCamTranslator): 

24 """Metadata translation for the LSST Commissioning Camera.""" 

25 

26 name = "LSSTComCamSim" 

27 """Name of this translation class""" 

28 

29 _const_map = { 

30 "instrument": "LSSTComCamSim", 

31 } 

32 

33 cameraPolicyFile = 'policy/comCamSim.yaml' 

34 

35 @classmethod 

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

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

38 supplied header. 

39 

40 Looks for "COMCAMSIM" instrument in case-insensitive manner but 

41 must be on LSST telescope. This avoids confusion with other 

42 telescopes using commissioning cameras. 

43 

44 Parameters 

45 ---------- 

46 header : `dict`-like 

47 Header to convert to standardized form. 

48 filename : `str`, optional 

49 Name of file being translated. 

50 

51 Returns 

52 ------- 

53 can : `bool` 

54 `True` if the header is recognized by this class. `False` 

55 otherwise. 

56 """ 

57 if "INSTRUME" in header and "TELESCOP" in header: 

58 telescope = header["TELESCOP"] 

59 instrument = header["INSTRUME"].lower() 

60 if instrument == "comcamsim" and telescope in (SIMONYI_TELESCOPE, "LSST"): 

61 return True 

62 telcode = header.get("TELCODE", None) 

63 # Some lab data reports that it is LSST_CAMERA 

64 if telcode == "CC" and telescope in (SIMONYI_TELESCOPE, "LSST"): 

65 return True 

66 

67 return False 

68 

69 @classmethod 

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

71 """Fix Simulated ComCam headers. 

72 

73 Notes 

74 ----- 

75 Content will be added as needed. 

76 

77 Corrections are reported as debug level log messages. 

78 

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

80 process. 

81 """ 

82 modified = False 

83 

84 return modified 

85 

86 def _is_on_mountain(self): 

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

88 installed on the mountain. 

89 Returns 

90 ------- 

91 is : `bool` 

92 `True` if instrument is on the mountain. 

93 

94 Notes 

95 ----- 

96 TODO: DM-33387 This is currently a terrible hack and MUST be removed 

97 once CAP-807 and CAP-808 are done. 

98 Until then, ALL non-calib ComCam data will look like it is on sky. 

99 """ 

100 return True