Coverage for python/astro_metadata_translator/translators/decam.py : 27%

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 part of astro_metadata_translator. # # Developed for the LSST Data Management System. # This product includes software developed by the LSST Project # (http://www.lsst.org). # See the LICENSE file at the top-level directory of this distribution # 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.
tracking_from_degree_headers
"""Metadata translator for DECam standard headers. """
"""Name of this translation class"""
"""Supports the DECam instrument."""
"boresight_rotation_coord": "unknown", "detector_group": None}
"dark_time": ("DARKTIME", dict(unit=u.s)), "boresight_airmass": ("AIRMASS", dict(checker=is_non_science)), "observation_id": "OBSID", "object": "OBJECT", "science_program": "PROPID", "detector_num": "CCDNUM", "detector_serial": "DETECTOR", "detector_name": "DETPOS", "telescope": ("TELESCOP", dict(default="CTIO 4.0-m telescope")), "instrument": ("INSTRUME", dict(default="DECam")), # Ensure that reasonable values are always available "relative_humidity": ("HUMIDITY", dict(default=40., minimum=0, maximum=100.)), "temperature": ("OUTTEMP", dict(unit=u.deg_C, default=10., minimum=-10., maximum=40.)), # Header says torr but seems to be mbar. Use hPa unit # which is the SI equivalent of mbar. "pressure": ("PRESSURE", dict(unit=u.hPa, default=771.611, minimum=700., maximum=850.)), }
"""Indicate whether this translation class can translate the supplied header.
Checks the INSTRUME and FILTER headers.
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. """ # Use INSTRUME. Because of defaulting behavior only do this # if we really have an INSTRUME header if "INSTRUME" in header: via_instrume = super().can_translate(header, filename=filename) if via_instrume: return via_instrume if "FILTER" in header and "DECam" in header["FILTER"]: return True return False
def to_exposure_id(self): """Calculate exposure ID solely for science observations.
Returns ------- id : `int` ID of exposure. """ if self.to_observation_type() != "science": return None value = self._header["EXPNUM"] self._used_these_cards("EXPNUM") return value
def to_visit_id(self): # Docstring will be inherited. Property defined in properties.py return self.to_exposure_id()
def to_datetime_end(self): # Docstring will be inherited. Property defined in properties.py return self._from_fits_date("DTUTC")
"""Fetch the ID from the CALIB_ID header.
Calibration products made with constructCalibs have some metadata saved in its FITS header CALIB_ID. """ data = self._header["CALIB_ID"] match = re.search(r".*%s=(\S+)" % field, data) self._used_these_cards("CALIB_ID") return match.groups()[0]
def to_physical_filter(self): """Calculate physical filter.
Return `None` if the keyword FILTER does not exist in the header, which can happen for some valid Community Pipeline products.
Returns ------- filter : `str` The full filter name. """ if "FILTER" in self._header: value = self._header["FILTER"].strip() self._used_these_cards("FILTER") return value elif "CALIB_ID" in self._header: return self._translate_from_calib_id("filter") else: return None
def to_location(self): """Calculate the observatory location.
Returns ------- location : `astropy.coordinates.EarthLocation` An object representing the location of the telescope. """
if "OBS-LONG" in self._header: # OBS-LONG has west-positive sign so must be flipped lon = self._header["OBS-LONG"] * -1.0 value = EarthLocation.from_geodetic(lon, self._header["OBS-LAT"], self._header["OBS-ELEV"]) self._used_these_cards("OBS-LONG", "OBS-LAT", "OBS-ELEV") else: # Look up the value since some files do not have location value = EarthLocation.of_site("ctio")
return value
def to_observation_type(self): """Calculate the observation type.
Returns ------- typ : `str` Observation type. Normalized to standard set. """ if "OBSTYPE" not in self._header: return "none" obstype = self._header["OBSTYPE"].strip().lower() self._used_these_cards("OBSTYPE") if obstype == "object": return "science" return obstype
def to_tracking_radec(self): # Docstring will be inherited. Property defined in properties.py radecsys = ("RADESYS",) radecpairs = (("TELRA", "TELDEC"),) return tracking_from_degree_headers(self, radecsys, radecpairs, unit=(u.hourangle, u.deg))
def to_altaz_begin(self): # Docstring will be inherited. Property defined in properties.py return altaz_from_degree_headers(self, (("ZD", "AZ"),), self.to_datetime_begin(), is_zd=set(["ZD"]))
def to_detector_exposure_id(self): # Docstring will be inherited. Property defined in properties.py exposure_id = self.to_exposure_id() if exposure_id is None: return None return int("{:07d}{:02d}".format(exposure_id, self.to_detector_num())) |