Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-16253: Switch to astro_metadata_translator #97

Merged
merged 2 commits into from
Nov 1, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
65 changes: 4 additions & 61 deletions python/lsst/obs/decam/makeDecamRawVisitInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,70 +20,13 @@
# see <http://www.lsstcorp.org/LegalNotices/>.
#

import astropy.units

from lsst.afw.coord import Observatory, Weather
from lsst.afw.geom import SpherePoint
from lsst.obs.base import MakeRawVisitInfo
from lsst.obs.base import MakeRawVisitInfoViaObsInfo
from astro_metadata_translator import DecamTranslator

__all__ = ["MakeDecamRawVisitInfo"]


class MakeDecamRawVisitInfo(MakeRawVisitInfo):
class MakeDecamRawVisitInfo(MakeRawVisitInfoViaObsInfo):
"""Make a VisitInfo from the FITS header of a raw DECam image

Fields that are not set:
- exposureId
- ut1
- era (set by back-computing from HourAngle and RA, but not fully correct: see DM-8503)
- boresightRotAngle
- rotType
"""
def setArgDict(self, md, argDict):
"""Set an argument dict for VisitInfo and pop associated metadata

@param[in,out] md metadata, as an lsst.daf.base.PropertyList or PropertySet
@param[in,out] argdict a dict of arguments
"""
MakeRawVisitInfo.setArgDict(self, md, argDict)
argDict["darkTime"] = self.popFloat(md, "DARKTIME")
argDict["boresightAzAlt"] = SpherePoint(
self.popAngle(md, "AZ"),
self.altitudeFromZenithDistance(self.popAngle(md, "ZD")),
)
argDict["boresightRaDec"] = SpherePoint(
self.popAngle(md, "TELRA", units=astropy.units.h),
self.popAngle(md, "TELDEC"),
)
argDict["boresightAirmass"] = self.popFloat(md, "AIRMASS")
argDict["observatory"] = Observatory(
self.popAngle(md, "OBS-LONG"),
self.popAngle(md, "OBS-LAT"),
self.popFloat(md, "OBS-ELEV"),
)
# Default weather is based on typical conditions at an altitude of 2215 meters.
temperature = self.defaultMetadata(self.popFloat(md, "OUTTEMP"), 10., minimum=-10., maximum=40.)
pressure = self.defaultMetadata(self.pascalFromMmHg(self.popFloat(md, "PRESSURE")), 77161.1,
minimum=70000., maximum=85000.)
humidity = self.defaultMetadata(self.popFloat(md, "HUMIDITY"), 40., minimum=0., maximum=100.)
argDict["weather"] = Weather(temperature, pressure, humidity)
longitude = argDict["observatory"].getLongitude()
argDict['era'] = self.decamGetEra(md, argDict["boresightRaDec"][0], longitude)

def getDateAvg(self, md, exposureTime):
"""Return date at the middle of the exposure

@param[in,out] md FITS metadata; changed in place
@param[in] exposureTime exposure time in sec
"""
dateObs = self.popIsoDate(md, "DATE-OBS")
return self.offsetDate(dateObs, 0.5*exposureTime)

def decamGetEra(self, md, RA, longitude):
"""
DECAM provides HA, so we can get LST and thus an ERA-equivalent from that.

NOTE: if we deal with DM-8053 and implement UT1, we can delete this method and use UT1 directly.
"""
HA = self.popAngle(md, "HA", units=astropy.units.h)
return HA + RA - longitude
metadataTranslator = DecamTranslator
1 change: 1 addition & 0 deletions ups/obs_decam.table
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ setupRequired(pex_exceptions)
setupRequired(pex_config)
setupRequired(pex_policy)
setupRequired(ip_isr)
setupRequired(astro_metadata_translator)

setupOptional(testdata_decam)

Expand Down