Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

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

12 

13__all__ = ("LsstComCamTranslator", ) 

14 

15import logging 

16 

17from .lsstCam import LsstCamTranslator 

18from .lsst import SIMONYI_TELESCOPE 

19 

20log = logging.getLogger(__name__) 

21 

22DETECTOR_SERIALS = { 

23 "S00": "ITL-3800C-229", 

24 "S01": "ITL-3800C-251", 

25 "S02": "ITL-3800C-215", 

26 "S10": "ITL-3800C-326", 

27 "S11": "ITL-3800C-283", 

28 "S12": "ITL-3800C-243", 

29 "S20": "ITL-3800C-319", 

30 "S21": "ITL-3800C-209", 

31 "S22": "ITL-3800C-206", 

32} 

33 

34 

35class LsstComCamTranslator(LsstCamTranslator): 

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

37 

38 name = "LSSTComCam" 

39 """Name of this translation class""" 

40 

41 _const_map = { 

42 "instrument": "LSSTComCam", 

43 } 

44 

45 # Use the comCam raft definition 

46 cameraPolicyFile = "policy/comCam.yaml" 

47 

48 @classmethod 

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

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

51 supplied header. 

52 

53 Looks for "COMCAM" instrument in case-insensitive manner but 

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

55 telescopes using commissioning cameras. 

56 

57 Parameters 

58 ---------- 

59 header : `dict`-like 

60 Header to convert to standardized form. 

61 filename : `str`, optional 

62 Name of file being translated. 

63 

64 Returns 

65 ------- 

66 can : `bool` 

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

68 otherwise. 

69 """ 

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

71 telescope = header["TELESCOP"] 

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

73 if instrument == "comcam" and telescope in (SIMONYI_TELESCOPE, "LSST"): 

74 return True 

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

76 # Some lab data reports that it is LSST_CAMERA 

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

78 return True 

79 

80 return False 

81 

82 @classmethod 

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

84 """Fix ComCam headers. 

85 

86 Notes 

87 ----- 

88 Fixes the following issues: 

89 

90 * If LSST_NUM is missing it is filled in by looking at the CCDSLOT 

91 value and assuming that the ComCam detectors are fixed. 

92 

93 Corrections are reported as debug level log messages. 

94 

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

96 process. 

97 """ 

98 modified = False 

99 

100 # Calculate the standard label to use for log messages 

101 log_label = cls._construct_log_prefix(obsid, filename) 

102 

103 if "LSST_NUM" not in header: 

104 slot = header.get("CCDSLOT", None) 

105 if slot in DETECTOR_SERIALS: 

106 header["LSST_NUM"] = DETECTOR_SERIALS[slot] 

107 modified = True 

108 log.debug("%s: Set LSST_NUM to %s", log_label, header["LSST_NUM"]) 

109 

110 return modified