Skip to content

Commit

Permalink
Pass observation filter to the coadd query.
Browse files Browse the repository at this point in the history
  • Loading branch information
ctslater committed Nov 27, 2017
1 parent f4bc96c commit 9c04692
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 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,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()
Expand All @@ -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():
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

0 comments on commit 9c04692

Please sign in to comment.