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 

18 

19log = logging.getLogger(__name__) 

20 

21DETECTOR_SERIALS = { 

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

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

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

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

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

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

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

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

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

31} 

32 

33 

34class LsstComCamTranslator(LsstCamTranslator): 

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

36 

37 name = "LSSTComCam" 

38 """Name of this translation class""" 

39 

40 _const_map = { 

41 "instrument": "LSST-ComCam", 

42 } 

43 

44 # Use the comCam raft definition 

45 cameraPolicyFile = "policy/comCam.yaml" 

46 

47 @classmethod 

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

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

50 supplied header. 

51 

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

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

54 telescopes using commissioning cameras. 

55 

56 Parameters 

57 ---------- 

58 header : `dict`-like 

59 Header to convert to standardized form. 

60 filename : `str`, optional 

61 Name of file being translated. 

62 

63 Returns 

64 ------- 

65 can : `bool` 

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

67 otherwise. 

68 """ 

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

70 telescope = header["TELESCOP"] 

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

72 if instrument == "comcam" and telescope == "LSST": 

73 return True 

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

75 # Some lab data reports that it is LSST_CAMERA 

76 if telcode == "CC" and telescope == "LSST": 

77 return True 

78 

79 return False 

80 

81 @classmethod 

82 def fix_header(cls, header): 

83 """Fix ComCam headers. 

84 

85 Notes 

86 ----- 

87 Fixes the following issues: 

88 

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

90 value and assuming that the ComCam detectors are fixed. 

91 

92 Corrections are reported as debug level log messages. 

93 """ 

94 modified = False 

95 

96 obsid = header.get("OBSID", "unknown") 

97 

98 if "LSST_NUM" not in header: 

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

100 if slot in DETECTOR_SERIALS: 

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

102 modified = True 

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

104 

105 return modified