Coverage for python/lsst/obs/lsst/translators/phosim.py : 62%

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 LSST PhoSim FITS headers"""
13__all__ = ("LsstPhoSimTranslator", )
15import logging
17import astropy.units as u
18import astropy.units.cds as cds
19from astropy.coordinates import Angle
21from astro_metadata_translator import cache_translation
22from astro_metadata_translator.translators.helpers import tracking_from_degree_headers, \
23 altaz_from_degree_headers
25from .lsstsim import LsstSimTranslator
27log = logging.getLogger(__name__)
30class LsstPhoSimTranslator(LsstSimTranslator):
31 """Metadata translator for LSST PhoSim data.
32 """
34 name = "LSSTCam-PhoSim"
35 """Name of this translation class"""
37 _const_map = {
38 "instrument": "LSSTCam-PhoSim",
39 "boresight_rotation_coord": "sky",
40 "observation_type": "science",
41 "object": "UNKNOWN",
42 "relative_humidity": 40.0,
43 }
45 _trivial_map = {
46 "detector_group": "RAFTNAME",
47 "observation_id": "OBSID",
48 "science_program": "RUNNUM",
49 "exposure_id": "OBSID",
50 "visit_id": "OBSID",
51 "physical_filter": "FILTER",
52 "dark_time": ("DARKTIME", dict(unit=u.s)),
53 "exposure_time": ("EXPTIME", dict(unit=u.s)),
54 "temperature": ("TEMPERA", dict(unit=u.deg_C)),
55 "pressure": ("PRESS", dict(unit=cds.mmHg)),
56 "boresight_airmass": "AIRMASS",
57 "detector_name": "SENSNAME",
58 "detector_serial": "LSST_NUM",
59 }
61 cameraPolicyFile = "policy/phosim.yaml"
63 @classmethod
64 def can_translate(cls, header, filename=None):
65 """Indicate whether this translation class can translate the
66 supplied header.
68 There is no ``INSTRUME`` header in PhoSim data. Instead we use
69 the ``CREATOR`` header.
71 Parameters
72 ----------
73 header : `dict`-like
74 Header to convert to standardized form.
75 filename : `str`, optional
76 Name of file being translated.
78 Returns
79 -------
80 can : `bool`
81 `True` if the header is recognized by this class. `False`
82 otherwise.
83 """
84 return cls.can_translate_with_options(header, {"CREATOR": "PHOSIM", "TESTTYPE": "PHOSIM"},
85 filename=filename)
87 @cache_translation
88 def to_tracking_radec(self):
89 # Docstring will be inherited. Property defined in properties.py
90 radecsys = ("RADESYS",)
91 radecpairs = (("RATEL", "DECTEL"), ("RA_DEG", "DEC_DEG"), ("BORE-RA", "BORE-DEC"))
92 return tracking_from_degree_headers(self, radecsys, radecpairs)
94 @cache_translation
95 def to_altaz_begin(self):
96 # Docstring will be inherited. Property defined in properties.py
97 # Fallback to the "derive from ra/dec" if keys are missing
98 if self.are_keys_ok(["ZENITH", "AZIMUTH"]):
99 return altaz_from_degree_headers(self, (("ZENITH", "AZIMUTH"),),
100 self.to_datetime_begin(), is_zd=set(["ZENITH"]))
101 else:
102 return super().to_altaz_begin()
104 @cache_translation
105 def to_boresight_rotation_angle(self):
106 angle = Angle(90.*u.deg) - Angle(self.quantity_from_card(["ROTANGZ", "ROTANGLE"], u.deg))
107 angle = angle.wrap_at("360d")
108 return angle