Coverage for python/astro_metadata_translator/translators/hsc.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.
"""Metadata translator for HSC standard headers. """
"""Name of this translation class"""
"""Supports the HSC instrument."""
"boresight_rotation_coord": "sky"} """Hard wire HSC even though modern headers call it Hyper Suprime-Cam"""
"detector_name": "T_CCDSN", # T_CCDID seems to always be undefined } """One-to-one mappings"""
# Zero point for HSC dates: 2012-01-01 51544 -> 2000-01-01
# CCD index mapping for commissioning run 2 107: 105, 113: 107, 115: 109, 108: 110, 114: 108, }
"""Indicate whether this translation class can translate the supplied header.
There is no ``INSTRUME`` header in early HSC files, so this method looks for HSC mentions in other headers. In more recent files the instrument is called "Hyper Suprime-Cam".
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. """ if "INSTRUME" in header: return header["INSTRUME"] == "Hyper Suprime-Cam"
for k in ("EXP-ID", "FRAMEID"): if k in header: if header[k].startswith("HSC"): return True return False
def to_exposure_id(self): """Calculate unique exposure integer for this observation
Returns ------- visit : `int` Integer uniquely identifying this exposure. """ exp_id = self._header["EXP-ID"].strip() m = re.search(r"^HSCE(\d{8})$", exp_id) # 2016-06-14 and new scheme if m: self._used_these_cards("EXP-ID") return int(m.group(1))
# Fallback to old scheme m = re.search(r"^HSC([A-Z])(\d{6})00$", exp_id) if not m: raise RuntimeError(f"Unable to interpret EXP-ID: {exp_id}") letter, visit = m.groups() visit = int(visit) if visit == 0: # Don't believe it frame_id = self._header["FRAMEID"].strip() m = re.search(r"^HSC([A-Z])(\d{6})\d{2}$", frame_id) if not m: raise RuntimeError(f"Unable to interpret FRAMEID: {frame_id}") letter, visit = m.groups() visit = int(visit) if visit % 2: # Odd? visit -= 1 self._used_these_cards("EXP-ID", "FRAMEID") return visit + 1000000*(ord(letter) - ord("A"))
def to_boresight_rotation_angle(self): # Docstring will be inherited. Property defined in properties.py # Rotation angle formula determined empirically from visual inspection # of HSC images. See DM-9111. angle = Angle(270.*u.deg) - Angle(self.quantity_from_card("INST-PA", u.deg)) angle = angle.wrap_at("360d") return angle
def to_detector_num(self): """Calculate the detector number.
Focus CCDs were numbered incorrectly in the readout software during commissioning run 2. This method maps to the correct ones.
Returns ------- num : `int` Detector number. """
ccd = super().to_detector_num() try: tjd = self._get_adjusted_mjd() except Exception: return ccd
if tjd > 390 and tjd < 405: ccd = self._CCD_MAP_COMMISSIONING_2.get(ccd, ccd)
return ccd
def to_detector_exposure_id(self): # Docstring will be inherited. Property defined in properties.py return self.to_exposure_id() * 200 + self.to_detector_num() |