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 #190

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
5 changes: 1 addition & 4 deletions bin.src/reportImagesToCoadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import numpy

import lsst.pex.config as pexConfig
import lsst.afw.coord as afwCoord
import lsst.afw.geom as afwGeom
import lsst.pipe.base as pipeBase
from lsst.pipe.tasks.selectImages import WcsSelectImagesTask
Expand Down Expand Up @@ -95,9 +94,7 @@ def run(self, dataRef):
(raRange[1], decRange[1]),
(raRange[0], decRange[1]),
]
coordList = [
afwCoord.IcrsCoord(afwGeom.Angle(ra, afwGeom.degrees), afwGeom.Angle(dec, afwGeom.degrees))
for ra, dec in raDecList]
coordList = [afwGeom.SpherePoint(ra, dec, afwGeom.degrees) for ra, dec in raDecList]

exposureInfoList = self.select.runDataRef(
dataRef=dataRef,
Expand Down
5 changes: 1 addition & 4 deletions bin.src/reportPatches.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
from __future__ import print_function

import lsst.pex.config as pexConfig
import lsst.afw.coord as afwCoord
import lsst.afw.geom as afwGeom
import lsst.pipe.base as pipeBase

Expand Down Expand Up @@ -80,9 +79,7 @@ def run(self, dataRef):
(raRange[1], decRange[1]),
(raRange[0], decRange[1]),
]
coordList = [
afwCoord.IcrsCoord(afwGeom.Angle(ra, afwGeom.degrees), afwGeom.Angle(dec, afwGeom.degrees))
for ra, dec in raDecList]
coordList = [afwGeom.SpherePoint(ra, dec, afwGeom.degrees) for ra, dec in raDecList]
tractPatchList = skyMap.findTractPatchList(coordList)
for tractInfo, patchInfoList in tractPatchList:
for patchInfo in patchInfoList:
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/pipe/tasks/mocks/mockObservation.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def makePointings(self, n, tractInfo):
@param[in] n: number of pointings
@param[in] tractInfo: skymap tract (a lsst.skymap.TractInfo)
@return a Python iterable over (coord, angle) pairs:
- coord is an object position (an lsst.afw.coord.Coord)
- coord is an ICRS object position (an lsst.afw.geom.SpherePoint)
- angle is a position angle (???) (an lsst.afw.geom.Angle)

The default implementation returns an iterator (i.e. the function is a "generator"),
Expand All @@ -169,7 +169,7 @@ def makePointings(self, n, tractInfo):
def buildWcs(self, position, pa, detector):
"""Build a simple TAN Wcs with no distortion and exactly-aligned CCDs.

@param[in] position: object position on sky (an lsst.afw.coord.Coord)
@param[in] position: ICRS object position on sky (on lsst.afw.geom.SpherePoint)
@param[in] pa: position angle (an lsst.afw.geom.Angle)
@param[in] detector: detector information (an lsst.afw.cameraGeom.Detector)
"""
Expand Down
3 changes: 1 addition & 2 deletions python/lsst/pipe/tasks/objectMasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from builtins import object
import re
import lsst.daf.base as dafBase
import lsst.afw.coord as afwCoord
import lsst.afw.geom as afwGeom
import lsst.afw.table as afwTable
from lsst.log import Log
Expand Down Expand Up @@ -170,7 +169,7 @@ def readFits(fileName, hdu=0, flags=0):
rec["type"] = _type
rec["id"] = _id
rec["mag"] = mag
rec.setCoord(afwCoord.Fk5Coord(ra, dec))
rec.setCoord(afwGeom.SpherePoint(ra, dec))

rec["angle"] = angle
rec["height"] = height
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/pipe/tasks/registerImage.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def fitWcs(self, matches, inputWcs, inputBBox):
self.log.debug("Registration WCS RMS iteration %d: %f pixels",
i, sipFit.getScatterInPixels())
wcs = sipFit.getNewWcs()
dr = [m.first.get(refCoordKey).angularSeparation(
dr = [m.first.get(refCoordKey).separation(
wcs.pixelToSky(m.second.get(inCentroidKey))).asArcseconds() for
m in copyMatches]
dr = numpy.array(dr)
Expand Down
8 changes: 4 additions & 4 deletions python/lsst/pipe/tasks/selectImages.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(self, dataId, coordList):

The object has the following fields:
- dataId: data ID of exposure (a dict)
- coordList: a list of corner coordinates of the exposure (list of afwCoord.IcrsCoord)
- coordList: ICRS coordinates of the corners of the exposure (list of lsst.afw.geom.SpherePoint)
plus any others items that are desired
"""
super(BaseExposureInfo, self).__init__(dataId=dataId, coordList=coordList)
Expand All @@ -84,7 +84,7 @@ def run(self, coordList):
- exposureInfoList: a list of exposure information objects (subclasses of BaseExposureInfo),
which have at least the following fields:
- dataId: data ID dictionary
- coordList: coordinates of the corner of the exposure (list of afwCoord.IcrsCoord)
- coordList: ICRS coordinates of the corners of the exposure (list of lsst.afw.geom.SpherePoint)
"""
raise NotImplementedError()

Expand Down Expand Up @@ -184,7 +184,7 @@ def runDataRef(self, dataRef, coordList, makeDataRefList=True, selectDataList=[]
If "convexHull" is found to be too slow, we can revise this.

@param dataRef: Data reference for coadd/tempExp (with tract, patch)
@param coordList: List of Coord specifying boundary of patch
@param coordList: List of ICRS coordinates (lsst.afw.geom.SpherePoint) specifying boundary of patch
@param makeDataRefList: Construct a list of data references?
@param selectDataList: List of SelectStruct, to consider for selection
"""
Expand Down Expand Up @@ -282,7 +282,7 @@ def runDataRef(self, dataRef, coordList, makeDataRefList=True, selectDataList=[]
the median size

@param dataRef: Data reference for coadd/tempExp (with tract, patch)
@param coordList: List of Coord specifying boundary of patch
@param coordList: List of ICRS coordinates (lsst.afw.geom.SpherePoint) specifying boundary of patch
@param makeDataRefList: Construct a list of data references?
@param selectDataList: List of SelectStruct, to consider for selection
"""
Expand Down
31 changes: 15 additions & 16 deletions tests/test_coaddInputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@
import lsst.pex.exceptions
from lsst.daf.base import DateTime
import lsst.afw.cameraGeom.testUtils
from lsst.afw.coord import Coord, IcrsCoord
from lsst.afw.coord import Observatory, Weather
import lsst.afw.geom
from lsst.afw.geom import degrees, makeCdMatrix, makeSkyWcs, Polygon
import lsst.afw.image
from lsst.afw.detection import GaussianPsf
from lsst.afw.math import ChebyshevBoundedField
Expand Down Expand Up @@ -97,11 +96,11 @@ def makeExposure(self, universalId):
exp.setDetector(detector)

expInfo = exp.getInfo()
scale = 5.1e-5 * degrees
cdMatrix = makeCdMatrix(scale=scale)
wcs = makeSkyWcs(
scale = 5.1e-5*lsst.afw.geom.degrees
cdMatrix = lsst.afw.geom.makeCdMatrix(scale=scale)
wcs = lsst.afw.geom.makeSkyWcs(
crpix=lsst.afw.geom.Point2D(5, 5),
crval=IcrsCoord(10*lsst.afw.geom.degrees, 45*lsst.afw.geom.degrees),
crval=lsst.afw.geom.SpherePoint(10, 45, lsst.afw.geom.degrees),
cdMatrix=cdMatrix,
)
expInfo.setWcs(wcs)
Expand All @@ -110,7 +109,7 @@ def makeExposure(self, universalId):
calib.setFluxMag0(1.1e12, 2.2e10)
expInfo.setCalib(calib)
expInfo.setApCorrMap(self.makeApCorrMap())
expInfo.setValidPolygon(Polygon(lsst.afw.geom.Box2D(bbox).getCorners()))
expInfo.setValidPolygon(lsst.afw.geom.Polygon(lsst.afw.geom.Box2D(bbox).getCorners()))
if self.version > 1:
expInfo.setVisitInfo(self.makeVisitInfo())

Expand All @@ -121,11 +120,11 @@ def makeExposure(self, universalId):

@staticmethod
def makeWcs():
scale = 5.1e-5 * degrees
cdMatrix = makeCdMatrix(scale=scale)
return makeSkyWcs(
scale = 5.1e-5*lsst.afw.geom.degrees
cdMatrix = lsst.afw.geom.makeCdMatrix(scale=scale)
return lsst.afw.geom.makeSkyWcs(
crpix = lsst.afw.geom.Point2D(5, 5),
crval = IcrsCoord(10*lsst.afw.geom.degrees, 45*lsst.afw.geom.degrees),
crval = lsst.afw.geom.SpherePoint(10, 45, lsst.afw.geom.degrees),
cdMatrix = cdMatrix,
)

Expand All @@ -138,13 +137,13 @@ def makeVisitInfo():
DateTime(65321.1, DateTime.MJD, DateTime.TAI),
12345.1,
45.1*lsst.afw.geom.degrees,
IcrsCoord(23.1*degrees, 73.2*degrees),
Coord(134.5*degrees, 33.3*degrees),
lsst.afw.geom.SpherePoint(23.1, 73.2, lsst.afw.geom.degrees),
lsst.afw.geom.SpherePoint(134.5, 33.3, lsst.afw.geom.degrees),
1.73,
73.2*degrees,
73.2*lsst.afw.geom.degrees,
lsst.afw.image.RotType.SKY,
lsst.afw.coord.Observatory(11.1*degrees, 22.2*degrees, 0.333),
lsst.afw.coord.Weather(1.1, 2.2, 34.5),
Observatory(11.1*lsst.afw.geom.degrees, 22.2*lsst.afw.geom.degrees, 0.333),
Weather(1.1, 2.2, 34.5),
)

@staticmethod
Expand Down
3 changes: 1 addition & 2 deletions tests/test_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import lsst.utils.tests
import lsst.afw.image as afwImage
import lsst.afw.table as afwTable
import lsst.afw.coord as afwCoord
import lsst.afw.geom as afwGeom
import lsst.afw.display.ds9 as ds9
from lsst.pipe.base import Struct
Expand Down Expand Up @@ -86,7 +85,7 @@ def create(self):
inputArray[(yInput).astype(int), (xInput).astype(int)] = 1

# Create WCSes
centerCoord = afwCoord.IcrsCoord(0*afwGeom.degrees, 0*afwGeom.degrees)
centerCoord = afwGeom.SpherePoint(0, 0, afwGeom.degrees)
centerPixel = afwGeom.Point2D(self.width/2, self.height/2)
cdMatrix = afwGeom.makeCdMatrix(scale=self.pixelScale)
wcs = afwGeom.makeSkyWcs(crpix=centerPixel, crval=centerCoord, cdMatrix=cdMatrix)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
import unittest

import lsst.utils
import lsst.afw.coord as afwCoord
import lsst.afw.table as afwTable
import lsst.afw.geom as afwGeom
import lsst.daf.persistence as dafPersist
import lsst.meas.base as measBase
import lsst.utils.tests
Expand Down Expand Up @@ -162,7 +162,7 @@ def _transformAndCheck(self, measConf, schema, transformTask):
# containing a source at an arbitrary position.
inCat = afwTable.SourceCatalog(schema)
r = inCat.addNew()
r.setCoord(afwCoord.Coord("00:00:00", "11:11:11"))
r.setCoord(afwGeom.SpherePoint(0.0, 11.19, afwGeom.degrees))
r[PLUGIN_NAME] = 1.0

wcs, calib = Placeholder(), Placeholder()
Expand Down
16 changes: 7 additions & 9 deletions tests/test_wcsSelectImages.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import unittest

import lsst.utils.tests
import lsst.afw.coord as afwCoord
import lsst.afw.geom as afwGeom
from lsst.pipe.tasks.selectImages import WcsSelectImagesTask, SelectStruct
from lsst.pipe.tasks.coaddBase import CoaddBaseTask
Expand Down Expand Up @@ -93,8 +92,8 @@ def get(self, dataType):


# Common defaults for createPatch and createImage
CENTER = afwCoord.IcrsCoord(0*afwGeom.degrees, 90*afwGeom.degrees)
ROTATEAXIS = afwCoord.IcrsCoord(0*afwGeom.degrees, 0*afwGeom.degrees)
CENTER = afwGeom.SpherePoint(0, 90, afwGeom.degrees)
ROTATEAXIS = afwGeom.SpherePoint(0, 0, afwGeom.degrees)
DIMS = afwGeom.Extent2I(3600, 3600)
SCALE = 0.5*afwGeom.arcseconds

Expand All @@ -103,7 +102,7 @@ def createPatch(
tractId=1, patchId=(2, 3), # Tract and patch identifier, for dataId
dims=DIMS, # Patch dimensions (Extent2I)
xy0=afwGeom.Point2I(1234, 5678), # Patch xy0 (Point2I)
center=CENTER, # Celestial coordinates of center (IcrsCoord)
center=CENTER, # ICRS sky position of center (lsst.afw.geom.SpherePoint)
scale=SCALE # Pixel scale (Angle)
):
crpix = afwGeom.Point2D(xy0) + afwGeom.Extent2D(dims)*0.5
Expand All @@ -118,15 +117,14 @@ def createPatch(

def createImage(
dataId={"name": "foobar"}, # Data identifier
center=CENTER, # Celestial coordinates of center (IcrsCoord)
rotateAxis=ROTATEAXIS, # Rotation axis (IcrsCoord)
center=CENTER, # ICRS sky position of center (lsst.afw.geom.SpherePoint)
rotateAxis=ROTATEAXIS, # Rotation axis (lsst.afw.geom.SpherePoint)
rotateAngle=0*afwGeom.degrees, # Rotation angle/distance to move (Angle)
dims=DIMS, # Image dimensions (Extent2I)
scale=SCALE # Pixel scale (Angle)
):
crpix = afwGeom.Point2D(afwGeom.Extent2D(dims)*0.5)
center = center.clone() # Ensure user doesn't need it, because we're mangling it
center.rotate(rotateAxis, rotateAngle)
center = center.rotated(rotateAxis, rotateAngle)
cdMatrix = afwGeom.makeCdMatrix(scale=scale)
wcs = afwGeom.makeSkyWcs(crpix=crpix, crval=center, cdMatrix=cdMatrix)
return SelectStruct(DummyDataRef(dataId), wcs, afwGeom.Box2I(afwGeom.Point2I(0, 0),
Expand Down Expand Up @@ -154,7 +152,7 @@ def testImageContained(self):

def testDisjoint(self):
self.check(createPatch(),
createImage(center=afwCoord.IcrsCoord(0*afwGeom.degrees, -90*afwGeom.degrees)),
createImage(center=afwGeom.SpherePoint(0, -90, afwGeom.degrees)),
False)

def testIntersect(self):
Expand Down