diff --git a/python/lsst/ip/diffim/getTemplate.py b/python/lsst/ip/diffim/getTemplate.py index ce387d08..dbde74dc 100644 --- a/python/lsst/ip/diffim/getTemplate.py +++ b/python/lsst/ip/diffim/getTemplate.py @@ -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") @@ -99,7 +102,8 @@ 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() @@ -108,6 +112,7 @@ def run(self, exposure, sensorRef, templateIdList=None): datasetType=self.getCoaddDatasetName() + "_sub", bbox=patchSubBBox, tract=tractInfo.getId(), + filter=coaddFilterName, patch="%s,%s" % (patchInfo.getIndex()[0], patchInfo.getIndex()[1]), ) if patchSubBBox.isEmpty(): @@ -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(): @@ -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)