Skip to content

Commit

Permalink
Enable ra/dec calculation for LSSTCam
Browse files Browse the repository at this point in the history
Currently tests by using the phosim emulation.

Punts the comcam work until real examples exist.

$ translate_header.py -p lsst.obs.lsst.translators tests/headers/lsstCam-MC_H_20000217_000032_R22_S00.yaml
Analyzing tests/headers/lsstCam-MC_H_20000217_000032_R22_S00.yaml...
WARNING:lsst.obs.lsst.translators.lsst:tests/headers/lsstCam-MC_H_20000217_000032_R22_S00.yaml(MC_H_20000217_000032): Unable to determine airmass of a science observation, returning 1.
instrument: LSSTCam
telescope: Simonyi Survey Telescope
datetime_begin: 2000-02-17T02:14:33.319
altaz_begin: None
boresight_airmass: 1.0
boresight_rotation_angle: 0.0 deg
boresight_rotation_coord: sky
dark_time: 15.0 s
datetime_end: 2000-02-17T02:14:48.319
detector_exposure_id: 4000021700032090
detector_group: R22
detector_name: S00
detector_num: 90
detector_serial: E2V-CCD250-369
detector_unique_name: R22_S00
exposure_group: 4000021700032
exposure_id: 4000021700032
exposure_time: 15.0 s
location: (1818938.94323602, -5208470.950938, -3195172.08426757) m
object: UNKNOWN
observation_counter: 32
observation_id: MC_H_20000217_000032
observation_reason: phosim
observation_type: science
observing_day: 20000217
physical_filter: g
pressure: None
relative_humidity: None
science_program: 9006001
temperature: None
tracking_radec: <SkyCoord (ICRS): (ra, dec) in deg
    (0., 0.)>
visit_id: 4000021700032
  • Loading branch information
timj committed Feb 2, 2021
1 parent 9e97a07 commit 0309ccb
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 55 deletions.
4 changes: 4 additions & 0 deletions python/lsst/obs/lsst/translators/comCam.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class LsstComCamTranslator(LsstCamTranslator):

_const_map = {
"instrument": "LSSTComCam",
"boresight_rotation_coord": "unknown",
"boresight_rotation_angle": None,
"boresight_airmass": None,
"tracking_radec": None,
}

# Use the comCam raft definition
Expand Down
43 changes: 0 additions & 43 deletions python/lsst/obs/lsst/translators/latiss.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,46 +511,3 @@ def to_physical_filter(self):
physical_filter = f"{physical_filter}{FILTER_DELIMITER}{grating}"

return physical_filter

@cache_translation
def to_boresight_rotation_coord(self):
"""Boresight rotation angle.
Only relevant for science observations.
"""
unknown = "unknown"
if not self.is_on_sky():
return unknown

self._used_these_cards("ROTCOORD")
coord = self._header.get("ROTCOORD", unknown)
if coord is None:
coord = unknown
return coord

@cache_translation
def to_boresight_airmass(self):
"""Calculate airmass at boresight at start of observation.
Notes
-----
Early data are missing AMSTART header so we fall back to calculating
it from ELSTART.
"""
if not self.is_on_sky():
return None

# This observation should have AMSTART
amkey = "AMSTART"
if self.is_key_ok(amkey):
self._used_these_cards(amkey)
return self._header[amkey]

# Instead we need to look at azel
altaz = self.to_altaz_begin()
if altaz is not None:
return altaz.secz.to_value()

log.warning("%s: Unable to determine airmass of a science observation, returning 1.",
self._log_prefix)
return 1.0
43 changes: 43 additions & 0 deletions python/lsst/obs/lsst/translators/lsst.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,3 +760,46 @@ def to_observation_counter(self):
log.warning("%s: Unable to determine the observation counter so returning 0",
self._log_prefix)
return 0

@cache_translation
def to_boresight_rotation_coord(self):
"""Boresight rotation angle.
Only relevant for science observations.
"""
unknown = "unknown"
if not self.is_on_sky():
return unknown

self._used_these_cards("ROTCOORD")
coord = self._header.get("ROTCOORD", unknown)
if coord is None:
coord = unknown
return coord

@cache_translation
def to_boresight_airmass(self):
"""Calculate airmass at boresight at start of observation.
Notes
-----
Early data are missing AMSTART header so we fall back to calculating
it from ELSTART.
"""
if not self.is_on_sky():
return None

# This observation should have AMSTART
amkey = "AMSTART"
if self.is_key_ok(amkey):
self._used_these_cards(amkey)
return self._header[amkey]

# Instead we need to look at azel
altaz = self.to_altaz_begin()
if altaz is not None:
return altaz.secz.to_value()

log.warning("%s: Unable to determine airmass of a science observation, returning 1.",
self._log_prefix)
return 1.0
8 changes: 3 additions & 5 deletions python/lsst/obs/lsst/translators/lsstCam.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ class LsstCamTranslator(LsstBaseTranslator):
"telescope": SIMONYI_TELESCOPE,
# Migrate these to full translations once test data appears that
# includes them
"boresight_rotation_coord": "unknown",
"boresight_rotation_angle": None,
"boresight_airmass": None,
"tracking_radec": None,
"altaz_begin": None,
"object": "UNKNOWN",
"relative_humidity": None,
Expand All @@ -73,7 +69,9 @@ class LsstCamTranslator(LsstBaseTranslator):
"observation_id": "OBSID",
"exposure_time": ("EXPTIME", dict(unit=u.s)),
"detector_serial": "LSST_NUM",
"science_program": ("RUNNUM", dict(default="unknown"))
"science_program": ("RUNNUM", dict(default="unknown")),
"boresight_rotation_angle": (["ROTPA", "ROTANGLE"], dict(checker=is_non_science_or_lab,
default=float("nan"), unit=u.deg)),
}

# Use Imsim raft definitions until a true lsstCam definition exists
Expand Down
2 changes: 1 addition & 1 deletion tests/headers/lsstCam-MC_H_20000217_000032_R22_S00.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ SEQNUM: 32
SIMPLE: true
TELCODE: MC
TELESCOP: LSST
TESTTYPE: PHOSIM
TESTTYPE: PHOSIM
8 changes: 2 additions & 6 deletions tests/test_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import os.path
import unittest
import astropy
import astropy.units as u
import astropy.units.cds as cds
import lsst.obs.lsst.translators # noqa: F401 -- register the translators
Expand Down Expand Up @@ -148,7 +147,7 @@ def test_phoSimLsstCam_translator(self):
test_data = (("lsstCam-MC_H_20000217_000032_R22_S00.yaml",
dict(telescope="Simonyi Survey Telescope",
instrument="LSSTCam",
boresight_rotation_coord="unknown",
boresight_rotation_coord="sky",
dark_time=15.0*u.s,
detector_exposure_id=4000021700032090,
detector_group="R22",
Expand Down Expand Up @@ -263,10 +262,7 @@ def test_phosim_translator(self):
)
for filename, expected in test_data:
with self.subTest(f"Testing {filename}"):
# PhoSim data are in the future and Astropy complains
# about astrometry errors.
with self.assertWarns(astropy.utils.exceptions.AstropyWarning):
self.assertObservationInfoFromYaml(filename, dir=self.datadir, **expected)
self.assertObservationInfoFromYaml(filename, dir=self.datadir, **expected)

def test_latiss_translator(self):
test_data = (("latiss-2018-09-20-05700065-det000.yaml",
Expand Down

0 comments on commit 0309ccb

Please sign in to comment.