Skip to content

Commit

Permalink
Merge pull request #258 from lsst/tickets/DM-38568
Browse files Browse the repository at this point in the history
DM-38568: Set the physical_filter for templates.
  • Loading branch information
isullivan committed May 7, 2023
2 parents 2ab44a2 + c66cdc8 commit e197c71
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions python/lsst/ip/diffim/getTemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ def runQuantum(self, butlerQC, inputRefs, outputRefs):
results = self.getOverlappingExposures(inputs)
inputs["coaddExposures"] = results.coaddExposures
inputs["dataIds"] = results.dataIds
inputs["physical_filter"] = butlerQC.quantum.dataId["physical_filter"]
outputs = self.run(**inputs)
butlerQC.put(outputs, outputRefs)

Expand Down Expand Up @@ -481,7 +482,7 @@ def getOverlappingExposures(self, inputs):
return pipeBase.Struct(coaddExposures=coaddExposureList,
dataIds=dataIds)

def run(self, coaddExposures, bbox, wcs, dataIds, **kwargs):
def run(self, coaddExposures, bbox, wcs, dataIds, physical_filter=None, **kwargs):
"""Warp coadds from multiple tracts to form a template for image diff.
Where the tracts overlap, the resulting template image is averaged.
Expand All @@ -499,6 +500,8 @@ def run(self, coaddExposures, bbox, wcs, dataIds, **kwargs):
Template WCS onto which to resample the ``coaddExposures``.
dataIds : `list` [`lsst.daf.butler.DataCoordinate`]
Record of the tract and patch of each coaddExposure.
physical_filter : `str`, optional
The physical filter of the science image.
**kwargs
Any additional keyword parameters.
Expand All @@ -510,6 +513,13 @@ def run(self, coaddExposures, bbox, wcs, dataIds, **kwargs):
``template``
A template coadd exposure assembled out of patches
(`lsst.afw.image.ExposureF`).
Raises
------
NoWorkFound
If no coadds are found with sufficient un-masked pixels.
RuntimeError
If the PSF of the template can't be calculated.
"""
# Table for CoaddPSF
tractsSchema = afwTable.ExposureTable.makeMinimalSchema()
Expand Down Expand Up @@ -583,7 +593,12 @@ def run(self, coaddExposures, bbox, wcs, dataIds, **kwargs):
raise RuntimeError("CoaddPsf could not be constructed")

templateExposure.setPsf(coaddPsf)
templateExposure.setFilter(coaddExposure.getFilter())
# Coadds do not have a physical filter, so fetch it from the butler to prevent downstream warnings.
if physical_filter is None:
filterLabel = coaddExposure.getFilter()
else:
filterLabel = afwImage.FilterLabel(dataId['band'], physical_filter)
templateExposure.setFilter(filterLabel)
templateExposure.setPhotoCalib(coaddExposure.getPhotoCalib())
return pipeBase.Struct(template=templateExposure)

Expand Down

0 comments on commit e197c71

Please sign in to comment.