Skip to content

Commit

Permalink
add psf to CCDData cutouts
Browse files Browse the repository at this point in the history
  • Loading branch information
ebellm committed Jun 13, 2024
1 parent 917e884 commit 758c6c7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion python/lsst/ap/association/packageAlerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,11 +389,12 @@ def createCcdDataCutout(self, image, skyCenter, extent, photoCalib, srcId):
CCDData object storing the calibrate information from the input
difference or template image.
"""
point = image.getWcs().skyToPixel(skyCenter)

# Catch errors in retrieving the cutout.
try:
cutout = image.getCutout(skyCenter, extent)
except InvalidParameterError:
point = image.getWcs().skyToPixel(skyCenter)
imBBox = image.getBBox()
if not geom.Box2D(image.getBBox()).contains(point):
self.log.warning(
Expand All @@ -410,6 +411,8 @@ def createCcdDataCutout(self, image, skyCenter, extent, photoCalib, srcId):
% srcId)
return None

cutoutPsf = image.psf.computeKernelImage(point).array

# Find the value of the bottom corner of our cutout's BBox and
# subtract 1 so that the CCDData cutout position value will be
# [1, 1].
Expand All @@ -433,6 +436,7 @@ def createCcdDataCutout(self, image, skyCenter, extent, photoCalib, srcId):
uncertainty=VarianceUncertainty(calibCutout.getVariance().array),
flags=calibCutout.getMask().array,
wcs=cutoutWcs,
psf=cutoutPsf,
meta={"cutMinX": cutOutMinX,
"cutMinY": cutOutMinY},
unit=u.nJy)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_packageAlerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ def testCreateCcdDataCutout(self):
self.cutoutWcs.wcs.cd)
self.assertFloatsAlmostEqual(ccdData.data,
calibExposure.getImage().array)
self.assertFloatsAlmostEqual(ccdData.psf,
self.exposure.psf.computeKernelImage(self.center).array)
self.assertFloatsAlmostEqual(np.sum(ccdData.psf), 1.0)

ccdData = packageAlerts.createCcdDataCutout(
self.exposure,
Expand Down

0 comments on commit 758c6c7

Please sign in to comment.