Coverage for python/lsst/obs/lsst/translators/imsim.py : 59%

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 ImSim headers"""
13__all__ = ("LsstImSimTranslator", )
15import logging
16import astropy.units as u
17from astropy.coordinates import Angle
19from astro_metadata_translator import cache_translation
20from astro_metadata_translator.translators.helpers import tracking_from_degree_headers
22from .lsstsim import LsstSimTranslator
24log = logging.getLogger(__name__)
27class LsstImSimTranslator(LsstSimTranslator):
28 """Metadata translation class for ImSim headers"""
30 name = "LSST-ImSim"
31 """Name of this translation class"""
33 _const_map = {
34 "instrument": "LSST-ImSim",
35 "boresight_rotation_coord": "sky",
36 "object": "UNKNOWN",
37 "pressure": None,
38 "temperature": None,
39 "relative_humidity": 40.0,
40 }
42 _trivial_map = {
43 "detector_group": "RAFTNAME",
44 "detector_name": "SENSNAME",
45 "observation_id": "OBSID",
46 "science_program": "RUNNUM",
47 "exposure_id": "OBSID",
48 "visit_id": "OBSID",
49 "physical_filter": "FILTER",
50 "dark_time": ("DARKTIME", dict(unit=u.s)),
51 "exposure_time": ("EXPTIME", dict(unit=u.s)),
52 "detector_serial": "LSST_NUM",
53 }
55 cameraPolicyFile = "policy/imsim.yaml"
57 @classmethod
58 def can_translate(cls, header, filename=None):
59 """Indicate whether this translation class can translate the
60 supplied header.
62 There is no ``INSTRUME`` header in ImSim data. Instead we use
63 the ``TESTTYPE`` header.
65 Parameters
66 ----------
67 header : `dict`-like
68 Header to convert to standardized form.
69 filename : `str`, optional
70 Name of file being translated.
72 Returns
73 -------
74 can : `bool`
75 `True` if the header is recognized by this class. `False`
76 otherwise.
77 """
78 return cls.can_translate_with_options(header, {"TESTTYPE": "IMSIM"},
79 filename=filename)
81 @cache_translation
82 def to_tracking_radec(self):
83 # Docstring will be inherited. Property defined in properties.py
84 radecsys = ("RADESYS",)
85 radecpairs = (("RATEL", "DECTEL"),)
86 return tracking_from_degree_headers(self, radecsys, radecpairs)
88 @cache_translation
89 def to_boresight_airmass(self):
90 # Docstring will be inherited. Property defined in properties.py
91 altaz = self.to_altaz_begin()
92 if altaz is not None:
93 return altaz.secz.to_value()
94 return None
96 @cache_translation
97 def to_boresight_rotation_angle(self):
98 angle = Angle(90.*u.deg) - Angle(self.quantity_from_card("ROTANGLE", u.deg))
99 angle = angle.wrap_at("360d")
100 return angle