Coverage for python/lsst/obs/lsst/translators/auxTel.py : 29%

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
# This file is currently part of obs_lsst but is written to allow it # to be migrated to the astro_metadata_translator package at a later date. # # This product includes software developed by the LSST Project # (http://www.lsst.org). # See the LICENSE file in this directory for details of code ownership. # # Use of this source code is governed by a 3-clause BSD-style # license that can be found in the LICENSE file.
# AuxTel is not the same place as LSST # These coordinates read from Apple Maps
# Date instrument is taking data at telescope # Prior to this date many parameters are automatically nulled out # since the headers have not historically been reliable
# Define the sensor and group name for AuxTel globally so that it can be used # in multiple places. There is no raft but for consistency with other LSST # cameras we define one.
"""Pseudo method to determine whether this is a lab or non-science header.
Raises ------ KeyError If this is a science observation and on the mountain. """ if is_non_science(self): return if not self._is_on_mountain(): return raise KeyError("Required key is missing and this is a mountain science observation")
"""Metadata translator for LSST AuxTel data.
For lab measurements many values are masked out. """
"""Name of this translation class"""
"""Supports the LATISS instrument."""
# AuxTel is not yet attached to a telescope so many translations # are null. "instrument": "LATISS", "telescope": "LSSTAuxTel", "detector_group": _DETECTOR_GROUP_NAME, "detector_num": 0, "detector_name": _DETECTOR_NAME, # Single sensor "boresight_rotation_coord": "unknown", "science_program": "unknown", "relative_humidity": None, "pressure": None, "temperature": None, "altaz_begin": None, "tracking_radec": None, }
"observation_id": ("OBSID", dict(default=None, checker=is_non_science)), "detector_serial": ["LSST_NUM", "DETSER"], "boresight_airmass": ("AMSTART", dict(checker=is_non_science_or_lab)), "object": ("OBJECT", dict(checker=is_non_science_or_lab, default="UNKNOWN")), "boresight_rotation_angle": ("ROTANGLE", dict(checker=is_non_science_or_lab, default=float("nan"), unit=u.deg)), }
"""Fixed name of detector group."""
"""Fixed name of single sensor."""
"""Indicate whether this translation class can translate the supplied header.
Parameters ---------- header : `dict`-like Header to convert to standardized form. filename : `str`, optional Name of file being translated.
Returns ------- can : `bool` `True` if the header is recognized by this class. `False` otherwise. """ # INSTRUME keyword might be of two types if "INSTRUME" in header: instrume = header["INSTRUME"] for v in ("LSST_ATISS", "LATISS"): if instrume == v: return True # Calibration files strip important headers at the moment so guess if "DETNAME" in header and header["DETNAME"] == "RXX_S00": return True return False
date = self.to_datetime_begin() if date > TSTART: return True return False
def compute_detector_exposure_id(exposure_id, detector_num): """Compute the detector exposure ID from detector number and exposure ID.
This is a helper method to allow code working outside the translator infrastructure to use the same algorithm.
Parameters ---------- exposure_id : `int` Unique exposure ID. detector_num : `int` Detector number.
Returns ------- detector_exposure_id : `int` The calculated ID. """ if detector_num != 0: log.warning("Unexpected non-zero detector number for AuxTel") return exposure_id
def to_location(self): # Docstring will be inherited. Property defined in properties.py if self._is_on_mountain(): return AUXTEL_LOCATION return None
def to_dark_time(self): # Docstring will be inherited. Property defined in properties.py if self.is_key_ok("DARKTIME"): return self.quantity_from_card("DARKTIME", u.s)
log.warning("Explicit dark time not found, setting dark time to the exposure time.") return self.to_exposure_time()
def to_exposure_time(self): # Docstring will be inherited. Property defined in properties.py # Some data is missing a value for EXPTIME. # Have to be careful we do not have circular logic when trying to # guess if self.is_key_ok("EXPTIME"): return self.quantity_from_card("EXPTIME", u.s)
# A missing or undefined EXPTIME is problematic. Set to -1 # to indicate that none was found. log.warning("Insufficient information to derive exposure time. Setting to -1.0s") return -1.0 * u.s
def to_observation_type(self): """Determine the observation type.
In the absence of an ``IMGTYPE`` header, assumes lab data is always a dark if exposure time is non-zero, else bias.
Returns ------- obstype : `str` Observation type. """
# AuxTel observation type is documented to appear in OBSTYPE # but for historical reasons prefers IMGTYPE. Some data puts # it in GROUPID (which is meant to be for something else). # Test the keys in order until we find one that contains a # defined value. obstype_keys = ["OBSTYPE", "IMGTYPE"]
# For now, hope that GROUPID does not contain an obs type value # when on the mountain. if not self._is_on_mountain(): obstype_keys.append("GROUPID")
for k in obstype_keys: if self.is_key_ok(k): obstype = self._header[k] self._used_these_cards(k) return obstype.lower()
# In the absence of any observation type information, return # unknown unless we think it might be a bias. exptime = self.to_exposure_time() if exptime == 0.0: obstype = "bias" else: obstype = "unknown" log.warning("Unable to determine observation type. Guessing '%s'", obstype) return obstype |