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

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
20from astro_metadata_translator import cache_translation
21from astro_metadata_translator.translators.helpers import tracking_from_degree_headers, \
22 altaz_from_degree_headers
24from .lsstsim import LsstSimTranslator
26log = logging.getLogger(__name__)
29class LsstPhoSimTranslator(LsstSimTranslator):
30 """Metadata translator for LSST PhoSim data.
31 """
33 name = "LSST-PhoSim"
34 """Name of this translation class"""
36 _const_map = {
37 "instrument": "LSST-PhoSim",
38 "boresight_rotation_coord": "sky",
39 "observation_type": "science",
40 "object": "UNKNOWN",
41 "relative_humidity": 40.0,
42 }
44 _trivial_map = {
45 "detector_group": "RAFTNAME",
46 "observation_id": "OBSID",
47 "science_program": "RUNNUM",
48 "exposure_id": "OBSID",
49 "visit_id": "OBSID",
50 "physical_filter": "FILTER",
51 "dark_time": ("DARKTIME", dict(unit=u.s)),
52 "exposure_time": ("EXPTIME", dict(unit=u.s)),
53 "temperature": ("TEMPERA", dict(unit=u.deg_C)),
54 "pressure": ("PRESS", dict(unit=cds.mmHg)),
55 "boresight_rotation_angle": (["ROTANGZ", "ROTANGLE"], dict(unit=u.deg)),
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()