Coverage for python/lsst/obs/lsst/translators/lsstsim.py : 26%

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.
"""Shared routines for LSST Simulated Data. """ """Path to policy file relative to obs_lsst root."""
"""Mapping of detector name to detector number."""
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. """ return compute_detector_exposure_id_generic(exposure_id, detector_num, max_num=1000, mode="concat")
def compute_detector_num_from_name(cls, detector_group, detector_name): """Helper method to return the detector number from the name.
Parameters ---------- detector_group : `str` Name of the detector grouping. This is generally the raft name. detector_name : `str` Detector name.
Returns ------- num : `int` Detector number. """ fullname = f"{detector_group}_{detector_name}"
num = None if cls.cameraPolicyFile is not None: if cls.detectorMapping is None: cls.detectorMapping = read_detector_ids(cls.cameraPolicyFile) if fullname in cls.detectorMapping: num = cls.detectorMapping[fullname] else: log.warning(f"Unable to determine detector number from detector name {fullname}")
return num
def to_telescope(self): # Docstring will be inherited. Property defined in properties.py telescope = None if "OUTFILE" in self._header and self._header["OUTFILE"].startswith("lsst"): telescope = "LSST" self._used_these_cards("OUTFILE") elif "LSST_NUM" in self._header: telescope = "LSST" self._used_these_cards("LSST_NUM") return telescope
def to_location(self): # Docstring will be inherited. Property defined in properties.py location = None tel = self.to_telescope() if tel == "LSST": location = LSST_LOCATION return location
def to_datetime_begin(self): # Docstring will be inherited. Property defined in properties.py self._used_these_cards("MJD-OBS") return Time(self._header["MJD-OBS"], scale="tai", format="mjd")
def to_datetime_end(self): # Docstring will be inherited. Property defined in properties.py return self.to_datetime_begin() + self.to_exposure_time()
def to_detector_num(self): # Docstring will be inherited. Property defined in properties.py raft = self.to_detector_group() detector = self.to_detector_name() return self.compute_detector_num_from_name(raft, detector)
def to_detector_exposure_id(self): exposure_id = self.to_exposure_id() num = self.to_detector_num() return self.compute_detector_exposure_id(exposure_id, num)
def to_observation_type(self): # Docstring will be inherited. Property defined in properties.py obstype = self._header["IMGTYPE"] self._used_these_cards("IMGTYPE") obstype = obstype.lower() if obstype == "skyexp": obstype = "science" return obstype
def to_altaz_begin(self): # Docstring will be inherited. Property defined in properties.py if self.to_observation_type() == "science": # Derive from RADec in absence of any other information radec = self.to_tracking_radec() if radec is not None: # This triggers warnings because of the future dates with warnings.catch_warnings(): warnings.simplefilter("ignore", category=astropy.utils.exceptions.AstropyWarning) altaz = radec.transform_to(AltAz) return altaz return None |