Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions python/lsst/ip/diffim/getTemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ def run(self, exposure, sensorRef, templateIdList=None):
self.log.info("Using skyMap tract %s" % (tractInfo.getId(),))
skyCorners = [expWcs.pixelToSky(pixPos) for pixPos in expBoxD.getCorners()]
patchList = tractInfo.findPatchList(skyCorners)
expFilterName = sensorRef.getButler().queryMetadata("calexp",
format="filter",
dataId=sensorRef.dataId)[0]

if not patchList:
raise RuntimeError("No suitable tract found")
Expand All @@ -99,15 +102,17 @@ def run(self, exposure, sensorRef, templateIdList=None):
coaddExposure.getMaskedImage().set(np.nan, afwImage.Mask\
.getPlaneBitMask("NO_DATA"), np.nan)
nPatchesFound = 0
coaddFilter = None

coaddFilterName = expFilterName
coaddPsf = None
for patchInfo in patchList:
patchSubBBox = patchInfo.getOuterBBox()
patchSubBBox.clip(coaddBBox)
patchArgDict = dict(
datasetType=self.getCoaddDatasetName() + "_sub",
datasetType=self.getCoaddDatasetName() + "_calexp_sub",
bbox=patchSubBBox,
tract=tractInfo.getId(),
filter=coaddFilterName,
patch="%s,%s" % (patchInfo.getIndex()[0], patchInfo.getIndex()[1]),
)
if patchSubBBox.isEmpty():
Expand All @@ -122,8 +127,6 @@ def run(self, exposure, sensorRef, templateIdList=None):
self.log.info("Reading patch %s" % patchArgDict)
coaddPatch = sensorRef.get(**patchArgDict)
coaddExposure.getMaskedImage().assign(coaddPatch.getMaskedImage(), coaddPatch.getBBox())
if coaddFilter is None:
coaddFilter = coaddPatch.getFilter()

# Retrieve the PSF for this coadd tract, if not already retrieved
if coaddPsf is None and coaddPatch.hasPsf():
Expand All @@ -136,7 +139,7 @@ def run(self, exposure, sensorRef, templateIdList=None):
raise RuntimeError("No coadd Psf found!")

coaddExposure.setPsf(coaddPsf)
coaddExposure.setFilter(coaddFilter)
coaddExposure.setFilter(exposure.getFilter())
return pipeBase.Struct(exposure=coaddExposure,
sources=None)

Expand Down