From 9c721e1504f1f258e397975fb1a721a82a3f2a59 Mon Sep 17 00:00:00 2001 From: Paul Price Date: Tue, 18 Jul 2017 17:16:19 -0400 Subject: [PATCH] add test of bad CoaddPsf input CoaddPsf throws a RangeError when one of the inputs has an unexpectedly large transform. This tests that behaviour. --- tests/test_coaddPsf.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/test_coaddPsf.py b/tests/test_coaddPsf.py index bbb85f890..6827cec28 100755 --- a/tests/test_coaddPsf.py +++ b/tests/test_coaddPsf.py @@ -480,6 +480,27 @@ def testBBox(self): with self.assertRaises(pexExceptions.LogicError): mypsf.resized(100, 100) + def testLargeTransform(self): + """Test that images with bad astrometry are identified""" + multiplier = 1000.0 # CD matrix multiplier for bad input + badId = 1 # ID of bad input + for ii in range(3): + record = self.mycatalog.addNew() + record.setPsf(measAlg.DoubleGaussianPsf(50, 50, 5.0, 1.00, 0.0)) + cdMatrix = [self.cd11, self.cd12, self.cd21, self.cd22] + if ii == badId: + # This image has bad astrometry: + cdMatrix = [xx*multiplier for xx in cdMatrix] + record['id'] = ii + record['weight'] = 1.0 + record.setWcs(afwImage.makeWcs(self.crval, self.crpix, *cdMatrix)) + record.setBBox(afwGeom.Box2I(afwGeom.Point2I(0, 0), afwGeom.Extent2I(2000, 2000))) + + coaddPsf = measAlg.CoaddPsf(self.mycatalog, self.wcsref) + with self.assertRaises(pexExceptions.RangeError) as cm: + coaddPsf.computeKernelImage() + self.assertIn("id=%d" % (badId,), str(cm.exception)) + class TestMemory(lsst.utils.tests.MemoryTestCase): pass