Skip to content

Commit

Permalink
Merge branch 'tickets/DM-11023'
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulPrice committed Sep 25, 2017
2 parents b99accf + 9c721e1 commit 22030a4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/CoaddPsf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,15 @@ PTR(afw::detection::Psf::Image) CoaddPsf::doComputeKernelImage(
PTR(afw::geom::XYTransform) xytransform(
new afw::image::XYTransformFromWcsPair(_coaddWcs, exposureRecord.getWcs())
);
WarpedPsf warpedPsf = WarpedPsf(exposureRecord.getPsf(), xytransform, _warpingControl);
PTR(afw::image::Image<double>) componentImg = warpedPsf.computeKernelImage(ccdXY, color);
PTR(afw::image::Image<double>) componentImg;
try {
WarpedPsf warpedPsf = WarpedPsf(exposureRecord.getPsf(), xytransform, _warpingControl);
componentImg = warpedPsf.computeKernelImage(ccdXY, color);
} catch (pex::exceptions::RangeError & exc) {
LSST_EXCEPT_ADD(exc, (boost::format("Computing WarpedPsf kernel image for id=%d") %
exposureRecord.getId()).str());
throw exc;
}
imgVector.push_back(componentImg);
weightSum += exposureRecord.get(_weightKey);
weightVector.push_back(exposureRecord.get(_weightKey));
Expand Down
21 changes: 21 additions & 0 deletions tests/test_coaddPsf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 22030a4

Please sign in to comment.