Skip to content

Commit

Permalink
Format the transferred files
Browse files Browse the repository at this point in the history
  • Loading branch information
arunkannawadi committed Nov 14, 2024
1 parent 807961c commit eba1e74
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 37 deletions.
3 changes: 1 addition & 2 deletions python/lsst/drp/tasks/make_direct_warp.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,10 @@
)
from lsst.pipe.base.connectionTypes import Input, Output
from lsst.pipe.tasks.coaddBase import makeSkyInfo
from lsst.pipe.tasks.coaddInputRecorder import CoaddInputRecorderTask
from lsst.pipe.tasks.selectImages import PsfWcsSelectImagesTask
from lsst.skymap import BaseSkyMap

from lsst.pipe.tasks.coaddInputRecorder import CoaddInputRecorderTask

if TYPE_CHECKING:
from lsst.afw.image import MaskedImage
from lsst.afw.table import ExposureCatalog
Expand Down
38 changes: 15 additions & 23 deletions python/lsst/drp/tasks/make_psf_matched_warp.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,20 @@
"MakePsfMatchedWarpTask",
)

import warnings
from typing import TYPE_CHECKING

import lsst.geom as geom
import numpy as np
import warnings

from lsst.afw.geom import Polygon, makeWcsPairTransform, SinglePolygonException
import lsst.geom as geom
from lsst.afw.geom import Polygon, SinglePolygonException, makeWcsPairTransform
from lsst.coadd.utils import copyGoodPixels
from lsst.ip.diffim import ModelPsfMatchTask
from lsst.meas.algorithms import GaussianPsfFactory, WarpedPsf
from lsst.pex.config import ConfigurableField
from lsst.pipe.base import (
PipelineTask,
PipelineTaskConfig,
PipelineTaskConnections,
Struct,
)
from lsst.pipe.base import PipelineTask, PipelineTaskConfig, PipelineTaskConnections, Struct
from lsst.pipe.base.connectionTypes import Input, Output
from lsst.pipe.tasks.coaddBase import makeSkyInfo, growValidPolygons
from lsst.pipe.tasks.coaddBase import growValidPolygons, makeSkyInfo
from lsst.skymap import BaseSkyMap
from lsst.utils.timer import timeMethod

Expand All @@ -61,6 +56,7 @@ class MakePsfMatchedWarpConnections(
},
):
"""Connections for MakePsfMatchedWarpTask"""

sky_map = Input(
doc="Input definition of geometry/bbox and projection/wcs for warps.",
name=BaseSkyMap.SKYMAP_DATASET_TYPE_NAME,
Expand Down Expand Up @@ -173,18 +169,12 @@ def run(self, direct_warp: Exposure, bbox: geom.Box2I):

if (src_polygon := row.validPolygon) is None:
# Calculate the polygon for this detector.
src_polygon = Polygon(
[geom.Point2D(corner) for corner in row.getBBox().getCorners()]
)
self.log.debug("Polygon for detector=%d is calculated as %s",
row["ccd"],
src_polygon
)
src_polygon = Polygon([geom.Point2D(corner) for corner in row.getBBox().getCorners()])
self.log.debug("Polygon for detector=%d is calculated as %s", row["ccd"], src_polygon)
else:
self.log.debug("Polygon for detector=%d is read from the input calexp as %s",
row["ccd"],
src_polygon
)
self.log.debug(
"Polygon for detector=%d is read from the input calexp as %s", row["ccd"], src_polygon
)

try:
destination_polygon = src_polygon.transform(transform).intersectionSingle(
Expand Down Expand Up @@ -249,7 +239,9 @@ def run(self, direct_warp: Exposure, bbox: geom.Box2I):
del temp_psf_matched

self.log.info(
"Copied %d pixels from CCD %d to exposure_psf_matched", num_good_pixels, row["ccd"],
"Copied %d pixels from CCD %d to exposure_psf_matched",
num_good_pixels,
row["ccd"],
)
total_good_pixels += num_good_pixels

Expand All @@ -258,7 +250,7 @@ def run(self, direct_warp: Exposure, bbox: geom.Box2I):
if total_good_pixels > 0:
growValidPolygons(
exposure_psf_matched.info.getCoaddInputs(),
-self.config.psfMatch.kernel.active.kernelSize // 2
-self.config.psfMatch.kernel.active.kernelSize // 2,
)

return Struct(psf_matched_warp=exposure_psf_matched)
Expand Down
2 changes: 1 addition & 1 deletion tests/assemble_coadd_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
from lsst.geom import arcseconds, degrees
from lsst.meas.algorithms.testUtils import plantSources
from lsst.obs.base import MakeRawVisitInfoViaObsInfo
from lsst.pipe.tasks.coaddInputRecorder import CoaddInputRecorderConfig, CoaddInputRecorderTask
from lsst.pipe.tasks.coaddBase import growValidPolygons
from lsst.pipe.tasks.coaddInputRecorder import CoaddInputRecorderConfig, CoaddInputRecorderTask
from lsst.skymap import Index2D, PatchInfo

__all__ = ["makeMockSkyInfo", "MockCoaddTestData"]
Expand Down
15 changes: 4 additions & 11 deletions tests/test_make_psf_matched_warp.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,13 @@
import unittest

import numpy as np
from test_make_direct_warp import MakeWarpTestCase

import lsst.utils.tests

import lsst.afw.cameraGeom.testUtils
import lsst.afw.image

import lsst.utils.tests
from lsst.drp.tasks.make_direct_warp import MakeDirectWarpTask, WarpDetectorInputs
from lsst.drp.tasks.make_psf_matched_warp import MakePsfMatchedWarpTask
import lsst.afw.cameraGeom.testUtils

from test_make_direct_warp import MakeWarpTestCase


class MakePsfMatchedWarpTestCase(MakeWarpTestCase):
Expand All @@ -50,11 +47,7 @@ def test_makeWarp(self):
exposure_or_handle=self.dataRef, data_id=self.dataRef.dataId
)
}
result = makeWarp.run(
warp_detector_inputs,
sky_info=self.skyInfo,
visit_summary=None
)
result = makeWarp.run(warp_detector_inputs, sky_info=self.skyInfo, visit_summary=None)

warp = result.warp

Expand Down

0 comments on commit eba1e74

Please sign in to comment.