Skip to content

Commit

Permalink
Simplify test_coadd.py
Browse files Browse the repository at this point in the history
by calling assertWcsAlmostEqualOverBBox instead of
using a custom method to do the same thing.
This eliminiates an issue with replacing Coord
with SpherePoint: calling getPosition without an argument.
  • Loading branch information
r-owen committed Mar 16, 2018
1 parent fce6a49 commit f0963bb
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions tests/test_coadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,6 @@ def testAddOne(self):
msg = "coadd != input exposure"
self.assertMaskedImagesAlmostEqual(inMaskedImage, coaddMaskedImage, skipMask=skipMaskArr, msg=msg)

def assertWcsSame(self, wcs1, wcs2):
for xPixPos in (0, 1000, 2000):
for yPixPos in (0, 1000, 2000):
fromPixPos = afwGeom.Point2D(xPixPos, yPixPos)
sky1 = wcs1.pixelToSky(fromPixPos)
sky2 = wcs2.pixelToSky(fromPixPos)
if not np.allclose(sky1.getPosition(), sky2.getPosition()):
self.fail("wcs do not match at fromPixPos=%s: sky1=%s != sky2=%s" %
(fromPixPos, sky1, sky2))
toPixPos1 = wcs1.skyToPixel(sky1)
toPixPos2 = wcs2.skyToPixel(sky1)
if not np.allclose((xPixPos, yPixPos), toPixPos1):
self.fail("wcs do not match at sky1=%s: fromPixPos=%s != toPixPos1=%s" %
(sky1, fromPixPos, toPixPos1))
if not np.allclose(toPixPos1, toPixPos2):
self.fail("wcs do not match at fromPixPos=%s, sky1=%s: toPixPos1=%s != toPixPos2=%s" %
(fromPixPos, sky1, toPixPos1, toPixPos2))

@unittest.skipUnless(AfwdataDir, "afwdata not available")
def testGetters(self):
"""Test getters for coadd
Expand All @@ -124,7 +106,7 @@ def testGetters(self):
badPixelMask += afwImage.Mask.getPlaneBitMask(maskPlaneName)
self.assertEqual(bbox, coadd.getBBox())
self.assertEqual(badPixelMask, coadd.getBadPixelMask())
self.assertWcsSame(wcs, coadd.getWcs())
self.assertWcsAlmostEqualOverBBox(wcs, coadd.getWcs(), coadd.getBBox())

@unittest.skipUnless(AfwdataDir, "afwdata not available")
def testFilters(self):
Expand Down

0 comments on commit f0963bb

Please sign in to comment.