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-11162: Replace all use of Coord and subclasses with SpherePoint #78

Merged
merged 2 commits into from
Mar 23, 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
2 changes: 1 addition & 1 deletion python/lsst/obs/decam/ingestCalibs.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def getInfo(self, filename):

def _translateFromCalibId(self, field, md):
"""Fetch the ID from the CALIB_ID header.

Calibration products made with constructCalibs have some metadata
saved in its FITS header CALIB_ID.
"""
Expand Down
7 changes: 4 additions & 3 deletions python/lsst/obs/decam/makeDecamRawVisitInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@

import astropy.units

from lsst.afw.coord import Coord, IcrsCoord, Observatory, Weather
from lsst.afw.coord import Observatory, Weather
from lsst.afw.geom import SpherePoint
from lsst.obs.base import MakeRawVisitInfo

__all__ = ["MakeDecamRawVisitInfo"]
Expand All @@ -49,11 +50,11 @@ def setArgDict(self, md, argDict):
"""
MakeRawVisitInfo.setArgDict(self, md, argDict)
argDict["darkTime"] = self.popFloat(md, "DARKTIME")
argDict["boresightAzAlt"] = Coord(
argDict["boresightAzAlt"] = SpherePoint(
self.popAngle(md, "AZ"),
self.altitudeFromZenithDistance(self.popAngle(md, "ZD")),
)
argDict["boresightRaDec"] = IcrsCoord(
argDict["boresightRaDec"] = SpherePoint(
self.popAngle(md, "TELRA", units=astropy.units.h),
self.popAngle(md, "TELDEC"),
)
Expand Down
18 changes: 8 additions & 10 deletions python/lsst/obs/decam/selectDecamImages.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import re

import lsst.pex.config as pexConfig
from lsst.afw.coord import IcrsCoord
import lsst.afw.geom as afwGeom
from lsst.daf.persistence import DbAuth
import lsst.pipe.base as pipeBase
Expand Down Expand Up @@ -62,7 +61,8 @@ class ExposureInfo(BaseExposureInfo):

Data includes:
- dataId: data ID of exposure (a dict)
- coordList: a list of corner coordinates of the exposure (list of IcrsCoord)
- coordList: a list of ICRS coordinates of the corners of the exposure
(each an lsst.afw.geom.SpherePoint)
- fwhm: mean FWHM of exposure
- airmass: mean airmass of exposure
- filename: original filename of exposure
Expand All @@ -81,10 +81,7 @@ def __init__(self, result):
coordList = []
for i in range(4):
coordList.append(
IcrsCoord(
afwGeom.Angle(result[self._nextInd], afwGeom.degrees),
afwGeom.Angle(result[self._nextInd], afwGeom.degrees),
)
afwGeom.SpherePoint(result[self._nextInd], result[self._nextInd], afwGeom.degrees)
)
BaseExposureInfo.__init__(self, dataId, coordList)

Expand Down Expand Up @@ -212,6 +209,7 @@ def _runArgDictFromDataId(self, dataId):
filter=dataId["filter"],
)


if __name__ == "__main__":
# example of use
selectTask = SelectDecamImagesTask()
Expand All @@ -220,10 +218,10 @@ def _runArgDictFromDataId(self, dataId):
minDec = afwGeom.Angle(-1, afwGeom.degrees)
maxDec = afwGeom.Angle(1, afwGeom.degrees)
coordList = [
IcrsCoord(minRa, minDec),
IcrsCoord(maxRa, minDec),
IcrsCoord(maxRa, maxDec),
IcrsCoord(minRa, maxDec),
afwGeom.SpherePoint(minRa, minDec),
afwGeom.SpherePoint(maxRa, minDec),
afwGeom.SpherePoint(maxRa, maxDec),
afwGeom.SpherePoint(minRa, maxDec),
]
results = selectTask.run(coordList=coordList, filter='r')
filenames = set()
Expand Down
4 changes: 2 additions & 2 deletions tests/test_getInstcal.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def testInstcal(self):
visitInfo = exp.getInfo().getVisitInfo()
self.assertEqual(visitInfo.getDate(), visit229388_info['dateAvg'])
self.assertAnglesAlmostEqual(visitInfo.getEra(), visit229388_info['era'])
self.assertCoordsAlmostEqual(visitInfo.getBoresightRaDec(), visit229388_info['boresightRaDec'])
self.assertCoordsAlmostEqual(visitInfo.getBoresightAzAlt(), visit229388_info['boresightAzAlt'])
self.assertSpherePointsAlmostEqual(visitInfo.getBoresightRaDec(), visit229388_info['boresightRaDec'])
self.assertSpherePointsAlmostEqual(visitInfo.getBoresightAzAlt(), visit229388_info['boresightAzAlt'])
self.assertAlmostEqual(visitInfo.getBoresightAirmass(), visit229388_info['boresightAirmass'])
self.assertTrue(math.isnan(visitInfo.getBoresightRotAngle().asDegrees()))
self.assertEqual(visitInfo.getRotType(), visit229388_info['rotType'])
Expand Down
12 changes: 5 additions & 7 deletions tests/test_getRaw.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,14 @@

import lsst.pex.exceptions as pexExcept
import lsst.daf.persistence as dafPersist
from lsst.obs.base import MakeRawVisitInfo
from lsst.afw.image import RotType
from lsst.afw.coord import IcrsCoord, Coord
from lsst.afw.geom import degrees
from lsst.afw.geom import degrees, SpherePoint


# Desired VisitInfo values for visit 229388, shared between test_getRaw.py and
# test_getInstcal.py

boresightRaDec = IcrsCoord('02:51:16.790', '-00:00:05.699')
boresightRaDec = SpherePoint(42.81995833, -0.00158305, degrees)
# NOTE: if we deal with DM-8053 and implement UT1, ERA will not come from HA, so this will change.
HA = -42.505291666666665*degrees
era = HA + boresightRaDec[0] - 70.81489000000001*degrees
Expand All @@ -52,7 +50,7 @@
"darkTime": 201.15662,
"era": era,
"boresightRaDec": boresightRaDec,
"boresightAzAlt": Coord(61.24*degrees, (90-50.46)*degrees),
"boresightAzAlt": SpherePoint(61.24, 90 - 50.46, degrees),
"boresightAirmass": 1.57,
"boresightRotAngle": float("nan")*degrees,
"rotType": RotType.UNKNOWN,
Expand Down Expand Up @@ -112,8 +110,8 @@ def testRaw(self):
visitInfo = exp.getInfo().getVisitInfo()
self.assertEqual(visitInfo.getDate(), visit229388_info['dateAvg'])
self.assertAnglesAlmostEqual(visitInfo.getEra(), visit229388_info['era'])
self.assertCoordsAlmostEqual(visitInfo.getBoresightRaDec(), visit229388_info['boresightRaDec'])
self.assertCoordsAlmostEqual(visitInfo.getBoresightAzAlt(), visit229388_info['boresightAzAlt'])
self.assertSpherePointsAlmostEqual(visitInfo.getBoresightRaDec(), visit229388_info['boresightRaDec'])
self.assertSpherePointsAlmostEqual(visitInfo.getBoresightAzAlt(), visit229388_info['boresightAzAlt'])
self.assertAlmostEqual(visitInfo.getBoresightAirmass(), visit229388_info['boresightAirmass'])
self.assertTrue(math.isnan(visitInfo.getBoresightRotAngle().asDegrees()))
self.assertEqual(visitInfo.getRotType(), visit229388_info['rotType'])
Expand Down