Skip to content

Commit

Permalink
Merge pull request #63 from lsst/tickets/DM-45366
Browse files Browse the repository at this point in the history
DM-45366: Pad psfMatchedWarpRefList in prepareInputs
  • Loading branch information
arunkannawadi authored Jul 29, 2024
2 parents cd1c8d4 + 2c06c77 commit 57d0c7d
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions python/lsst/drp/tasks/assemble_coadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,11 +534,19 @@ def prepareInputs(self, refList, psfMatchedWarpRefList=None):
imageScalerList = []
outputPsfMatchedWarpRefList = []

if not psfMatchedWarpRefList:
psfMatchedWarpRefList = [None] * len(refList)
# Convert psfMatchedWarpRefList to a dict, so we can look them up by
# their dataId.
# Note: Some warps may not have a corresponding psfMatchedWarp, which
# could have happened due to a failure in the PSF matching, or not
# having enough good pixels to support the PSF-matching kernel.

if psfMatchedWarpRefList is None:
psfMatchedWarpRefDict = {ref.dataId: None for ref in refList}
else:
psfMatchedWarpRefDict = {ref.dataId: ref for ref in psfMatchedWarpRefList}

warpName = self.getTempExpDatasetName(self.warpType)
for warpRef, psfMatchedWarpRef in zip(refList, psfMatchedWarpRefList, strict=True):
for warpRef in refList:
warp = warpRef.get()
# Ignore any input warp that is empty of data
if numpy.isnan(warp.image.array).all():
Expand Down Expand Up @@ -569,6 +577,9 @@ def prepareInputs(self, refList, psfMatchedWarpRefList=None):
warpRefList.append(warpRef)
weightList.append(weight)
imageScalerList.append(imageScaler)

dataId = warpRef.dataId
psfMatchedWarpRef = psfMatchedWarpRefDict.get(dataId, None)
outputPsfMatchedWarpRefList.append(psfMatchedWarpRef)

return pipeBase.Struct(
Expand Down Expand Up @@ -1110,6 +1121,9 @@ def _setValidPolygons(self, warpList, psfMatchedWarpRefList):
(direct) warps.
"""
for warp, psfMatchedWarpRef in zip(warpList, psfMatchedWarpRefList):
if psfMatchedWarpRef is None:
continue

psfMatchedCcdTable = psfMatchedWarpRef.get(component="coaddInputs").ccds
ccdTable = warp.getInfo().getCoaddInputs().ccds

Expand Down

0 comments on commit 57d0c7d

Please sign in to comment.