Coverage for python/lsst/obs/lsst/translators/lsstCam.py : 47%

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 main LSST Camera"""
13__all__ = ("LsstCamTranslator", )
15import logging
16import astropy.units as u
18# from astro_metadata_translator import cache_translation
19from astro_metadata_translator.translators.helpers import is_non_science
21from .lsst import LsstBaseTranslator
23log = logging.getLogger(__name__)
26def is_non_science_or_lab(self):
27 """Pseudo method to determine whether this is a lab or non-science
28 header.
30 Raises
31 ------
32 KeyError
33 If this is a science observation and on the mountain.
34 """
35 if is_non_science(self):
36 return
37 if not self._is_on_mountain():
38 return
39 raise KeyError("Required key is missing and this is a mountain science observation")
42class LsstCamTranslator(LsstBaseTranslator):
43 """Metadata translation for the main LSST Camera."""
45 name = "LSSTCam"
46 """Name of this translation class"""
48 supported_instrument = "LSSTCam"
49 """Supports the lsstCam instrument."""
51 _const_map = {
52 "telescope": "LSST",
53 # Migrate these to full translations once test data appears that
54 # includes them
55 "boresight_rotation_coord": "unknown",
56 "boresight_rotation_angle": None,
57 "boresight_airmass": None,
58 "tracking_radec": None,
59 "altaz_begin": None,
60 "object": "UNKNOWN",
61 "relative_humidity": None,
62 "temperature": None,
63 "pressure": None,
64 }
66 _trivial_map = {
67 "detector_group": "RAFTBAY",
68 "detector_name": "CCDSLOT",
69 "observation_id": "OBSID",
70 "exposure_time": ("EXPTIME", dict(unit=u.s)),
71 "detector_serial": "LSST_NUM",
72 "science_program": ("RUNNUM", dict(default="unknown"))
73 }
75 # Use Imsim raft definitions until a true lsstCam definition exists
76 cameraPolicyFile = "policy/lsstCam.yaml"
78 @classmethod
79 def can_translate(cls, header, filename=None):
80 """Indicate whether this translation class can translate the
81 supplied header.
83 Parameters
84 ----------
85 header : `dict`-like
86 Header to convert to standardized form.
87 filename : `str`, optional
88 Name of file being translated.
90 Returns
91 -------
92 can : `bool`
93 `True` if the header is recognized by this class. `False`
94 otherwise.
95 """
96 # INSTRUME keyword might be of two types
97 if "INSTRUME" in header:
98 instrume = header["INSTRUME"].lower()
99 if instrume == cls.supported_instrument.lower():
100 return True
101 return False