Skip to content

Commit

Permalink
Merge pull request #1007 from lsst/tickets/DM-47517
Browse files Browse the repository at this point in the history
DM-47517: Transfer the new warping tasks to drp_tasks
  • Loading branch information
arunkannawadi authored Dec 3, 2024
2 parents 9745ceb + 2e8e791 commit c017317
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 1,751 deletions.
35 changes: 35 additions & 0 deletions python/lsst/pipe/tasks/coaddBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import lsst.pipe.base as pipeBase
import lsst.geom as geom

from lsst.afw.geom import Polygon
from lsst.meas.algorithms import ScaleVarianceTask
from .selectImages import PsfWcsSelectImagesTask
from .coaddInputRecorder import CoaddInputRecorderTask
Expand Down Expand Up @@ -251,3 +252,37 @@ def subBBoxIter(bbox, subregionSize):
"colShift=%s, rowShift=%s" %
(bbox, subregionSize, colShift, rowShift))
yield subBBox


# Note that this is implemented as a free-floating function to enable reuse in
# lsst.pipe.tasks.makeWarp and in lsst.drp.tasks.make_psf_matched_warp
# without creating any relationships between the two classes.
# This may be converted to a method after makeWarp.py is removed altogether in
# DM-47916.
def growValidPolygons(coaddInputs, growBy: int) -> None:
"""Grow coaddInputs' ccds' ValidPolygons in place.
Either modify each ccd's validPolygon in place, or if CoaddInputs
does not have a validPolygon, create one from its bbox.
Parameters
----------
coaddInputs : `lsst.afw.image.coaddInputs`
CoaddInputs object containing the ccds to grow the valid polygons of.
growBy : `int`
The value to grow the valid polygons by.
Notes
-----
Negative values for ``growBy`` can shrink the polygons.
"""
for ccd in coaddInputs.ccds:
polyOrig = ccd.getValidPolygon()
validPolyBBox = polyOrig.getBBox() if polyOrig else ccd.getBBox()
validPolyBBox.grow(growBy)
if polyOrig:
validPolygon = polyOrig.intersectionSingle(validPolyBBox)
else:
validPolygon = Polygon(geom.Box2D(validPolyBBox))

ccd.validPolygon = validPolygon
3 changes: 1 addition & 2 deletions python/lsst/pipe/tasks/makeWarp.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
from lsst.meas.algorithms import CoaddPsf, CoaddPsfConfig, GaussianPsfFactory
from lsst.skymap import BaseSkyMap
from lsst.utils.timer import timeMethod
from .coaddBase import CoaddBaseTask, makeSkyInfo, reorderAndPadList
from .make_psf_matched_warp import growValidPolygons
from .coaddBase import CoaddBaseTask, growValidPolygons, makeSkyInfo, reorderAndPadList
from .warpAndPsfMatch import WarpAndPsfMatchTask
from collections.abc import Iterable

Expand Down
Loading

0 comments on commit c017317

Please sign in to comment.