Coverage for python/lsst/obs/lsst/translators/comCam.py : 33%

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.
11"""Metadata translation code for the LSST Commissioning Camera"""
13__all__ = ("LsstComCamTranslator", )
15import logging
17from .lsstCam import LsstCamTranslator
18from .lsst import SIMONYI_TELESCOPE
20log = logging.getLogger(__name__)
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}
35class LsstComCamTranslator(LsstCamTranslator):
36 """Metadata translation for the LSST Commissioning Camera."""
38 name = "LSSTComCam"
39 """Name of this translation class"""
41 _const_map = {
42 "instrument": "LSST-ComCam",
43 }
45 # Use the comCam raft definition
46 cameraPolicyFile = "policy/comCam.yaml"
48 @classmethod
49 def can_translate(cls, header, filename=None):
50 """Indicate whether this translation class can translate the
51 supplied header.
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.
57 Parameters
58 ----------
59 header : `dict`-like
60 Header to convert to standardized form.
61 filename : `str`, optional
62 Name of file being translated.
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
80 return False
82 @classmethod
83 def fix_header(cls, header):
84 """Fix ComCam headers.
86 Notes
87 -----
88 Fixes the following issues:
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.
93 Corrections are reported as debug level log messages.
94 """
95 modified = False
97 obsid = header.get("OBSID", "unknown")
99 if "LSST_NUM" not in header:
100 slot = header.get("CCDSLOT", None)
101 if slot in DETECTOR_SERIALS:
102 header["LSST_NUM"] = DETECTOR_SERIALS[slot]
103 modified = True
104 log.debug("%s: Set LSST_NUM to %s", obsid, header["LSST_NUM"])
106 return modified