Skip to content

Commit

Permalink
Build CoaddPsf of CoaddPsfs in tract WCS
Browse files Browse the repository at this point in the history
Previously it was loading the PSFs pre-warped to the detector WCS.
CoaddPsf warps when evaluating anyway so pre-warping is overkill
and harder to debug.
  • Loading branch information
yalsayyad committed Nov 10, 2021
1 parent 5bd0cb7 commit a85a5a9
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions python/lsst/ip/diffim/getTemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from lsst.skymap import BaseSkyMap
from lsst.daf.butler import DeferredDatasetHandle
from lsst.ip.diffim.dcrModel import DcrModel
from lsst.meas.algorithms import CoaddPsf, WarpedPsf, CoaddPsfConfig
from lsst.meas.algorithms import CoaddPsf, CoaddPsfConfig

__all__ = ["GetCoaddAsTemplateTask", "GetCoaddAsTemplateConfig",
"GetCalexpAsTemplateTask", "GetCalexpAsTemplateConfig",
Expand Down Expand Up @@ -649,28 +649,25 @@ def run(self, coaddExposures, bbox, wcs):
coaddPatch = coaddExposure.get()

# warp to detector WCS
xyTransform = afwGeom.makeWcsPairTransform(coaddPatch.getWcs(), finalWcs)
psfWarped = WarpedPsf(coaddPatch.getPsf(), xyTransform)
warped = self.warper.warpExposure(finalWcs, coaddPatch, maxBBox=finalBBox)

# Check if warped image is viable
if not np.any(np.isfinite(warped.image.array)):
self.log.info("No overlap for warped %s. Skipping" % coaddExposure.ref.dataId)
continue

warped.setPsf(psfWarped)

exp = afwImage.ExposureF(finalBBox, finalWcs)
exp.maskedImage.set(np.nan, afwImage.Mask.getPlaneBitMask("NO_DATA"), np.nan)
exp.maskedImage.assign(warped.maskedImage, warped.getBBox())

maskedImageList.append(exp.maskedImage)
weightList.append(1)
record = tractsCatalog.addNew()
record.setPsf(psfWarped)
record.setWcs(finalWcs)
record.setPsf(coaddPatch.getPsf())
record.setWcs(coaddPatch.getWcs())
record.setPhotoCalib(coaddPatch.getPhotoCalib())
record.setBBox(warped.getBBox())
record.setBBox(coaddPatch.getBBox())
record.setValidPolygon(afwGeom.Polygon(geom.Box2D(coaddPatch.getBBox()).getCorners()))
record.set(tractKey, coaddExposure.ref.dataId['tract'])
record.set(patchKey, coaddExposure.ref.dataId['patch'])
record.set(weightKey, 1.)
Expand Down

0 comments on commit a85a5a9

Please sign in to comment.