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 for VisitInfo calculation #50

Merged
merged 1 commit into from
Nov 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
58 changes: 5 additions & 53 deletions python/lsst/obs/cfht/makeMegacamRawVisitInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,64 +20,16 @@
# 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 MegaPrimeTranslator

__all__ = ["MakeMegacamRawVisitInfo"]


class MakeMegacamRawVisitInfo(MakeRawVisitInfo):
class MakeMegacamRawVisitInfo(MakeRawVisitInfoViaObsInfo):

"""Make a VisitInfo from the FITS header of a raw Megacam image
"""

def setArgDict(self, md, argDict):
"""Set an argument dict for VisitInfo and pop associated metadata

Parameters
----------
md : `lsst.daf.base.PropertyList` or `lsst.daf.base.PropertySet`
Metadata to extract from. Extracted values are removed.
argdict : `dict`
A dict of arguments to add to values to.
"""
MakeRawVisitInfo.setArgDict(self, md, argDict)
argDict["darkTime"] = self.popFloat(md, "DARKTIME")
argDict["boresightAzAlt"] = SpherePoint(
self.popAngle(md, "TELAZ"),
self.popAngle(md, "TELALT"),
)
argDict["boresightRaDec"] = SpherePoint(
self.popAngle(md, "RA_DEG",),
self.popAngle(md, "DEC_DEG"),
)
argDict["boresightAirmass"] = self.popFloat(md, "AIRMASS")
argDict["observatory"] = Observatory(
self.popAngle(md, "LONGITUD"),
self.popAngle(md, "LATITUDE"),
4204, # from Wikipedia
)
argDict["weather"] = Weather(
self.popFloat(md, "TEMPERAT"),
self.popFloat(md, "PRESSURE")*100.0, # 100 Pascal per millibar
self.popFloat(md, "RELHUMID"),
)
# Using LST to compute ERA until we get UT1 (see: DM-8053)
LST = self.popAngle(md, "LST-OBS", units=astropy.units.h)
argDict['era'] = self.eraFromLstAndLongitude(LST, argDict["observatory"].getLongitude())

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

Parameters
----------
md : `lsst.daf.base.PropertyList` or `lsst.daf.base.PropertySet`
FITS metadata; changed in place
exposureTime : `float`
exposure time in sec
"""
dateObs = self.popMjdDate(md, "MJD-OBS")
return self.offsetDate(dateObs, 0.5*exposureTime)
# Force MegaPrime translator
metadataTranslator = MegaPrimeTranslator
14 changes: 6 additions & 8 deletions tests/test_butler.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import lsst.pex.exceptions as pexExcept
from lsst.daf.base import DateTime
from lsst.afw.image import RotType
from lsst.afw.geom import degrees, SpherePoint
from lsst.geom import degrees, radians, SpherePoint

try:
type(display)
Expand All @@ -58,21 +58,19 @@ def setUp(self):
self.filter = "i2"
self.exposureTime = 615.037
self.darkTime = 615.0
dateObs = DateTime(54771.6066250, DateTime.MJD, DateTime.UTC)
self.dateAvg = DateTime(dateObs.nsecs(DateTime.TAI) + int(0.5e9*self.exposureTime), DateTime.TAI)
self.boresightRaDec = SpherePoint(135.409417, -2.400000, degrees)
self.dateAvg = DateTime(54771.610881712964, DateTime.MJD, DateTime.TAI)
self.boresightRaDec = SpherePoint(135.40941055, -2.39999432, degrees)
self.boresightAzAlt = SpherePoint(122.34, 52.02, degrees)
self.boresightAirmass = 1.269
self.rotType = RotType.UNKNOWN
self.obs_longitude = -155.468876*degrees
self.obs_latitude = 19.825252*degrees
self.obs_elevation = 4204
self.obs_elevation = 4215
self.weath_airTemperature = 0.90
self.weath_airPressure = 617.65*100 # 100 Pascal/millibar
self.weath_humidity = 39.77
# NOTE: if we deal with DM-8053 and get UT1 implemented, ERA will change slightly.
lst = 104.16591666666666*degrees
self.era = lst - self.obs_longitude
self.era = 4.55388*radians

def tearDown(self):
del self.butler
Expand Down Expand Up @@ -123,7 +121,7 @@ def testRaw(self):

visitInfo = raw.getInfo().getVisitInfo()
self.assertAlmostEqual(visitInfo.getDate().get(), self.dateAvg.get())
self.assertEqual(visitInfo.getEra(), self.era)
self.assertAnglesAlmostEqual(visitInfo.getEra(), self.era, maxDiff=0.1*degrees)
self.assertAlmostEqual(visitInfo.getExposureTime(), self.exposureTime)
self.assertAlmostEqual(visitInfo.getDarkTime(), self.darkTime)
self.assertSpherePointsAlmostEqual(visitInfo.getBoresightRaDec(), self.boresightRaDec)
Expand Down
1 change: 1 addition & 0 deletions ups/obs_cfht.table
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ setupRequired(obs_base)
setupRequired(meas_algorithms)
setupRequired(pipe_tasks)
setupRequired(astropy)
setupRequired(astro_metadata_translator)

setupOptional(testdata_cfht)

Expand Down