Skip to content

Commit

Permalink
Experimental attempt to use ERFA to get AZEL from Hour Angle
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Sep 26, 2020
1 parent 157298e commit 88897bb
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion python/lsst/obs/lsst/translators/imsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import logging
import astropy.units as u
from astropy.coordinates import Angle
from astropy.coordinates import Angle, AltAz

from astro_metadata_translator import cache_translation
from astro_metadata_translator.translators.helpers import tracking_from_degree_headers
Expand Down Expand Up @@ -116,3 +116,26 @@ def to_physical_filter(self):
self.to_observation_id(), self._header["FILTER"])
return self._header["FILTER"]
return "_".join((self._header["FILTER"], "sim", throughputs_version))

@cache_translation
def to_altaz_begin(self):
# Calculate from the hour angle if available
if self.to_observation_type() != "science":
return None

if not self.are_keys_ok(["HASTART", "DECTEL"]):
# Fallback to slow method
return super().to_altaz_begin()

location = self.to_location()
ha = Angle(self._header["HASTART"], unit=u.deg)

# For speed over accuracy, assume this is apparent Dec not ICRS
dec = Angle(self._header["DECTEL"], unit=u.deg)

# Use erfa directly
import astropy._erfa as erfa
az, el = erfa.hd2ae(ha.radian, dec.radian, location.lat.radian)

return AltAz(az*u.radian, el*u.radian,
obstime=self.to_datetime_begin(), location=location)

0 comments on commit 88897bb

Please sign in to comment.