Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-38751: Allow MeasureApCorrTask to fail and filter when making warps. #774

Merged
merged 2 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 20 additions & 4 deletions python/lsst/pipe/tasks/characterizeImage.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@
import lsst.pipe.base.connectionTypes as cT
from lsst.afw.math import BackgroundList
from lsst.afw.table import SourceTable
from lsst.meas.algorithms import SubtractBackgroundTask, SourceDetectionTask, MeasureApCorrTask
from lsst.meas.algorithms import (
SubtractBackgroundTask,
SourceDetectionTask,
MeasureApCorrTask,
MeasureApCorrError,
)
from lsst.meas.algorithms.installGaussianPsf import InstallGaussianPsfTask
from lsst.meas.astrom import RefMatchTask, displayAstrometry
from lsst.meas.algorithms import LoadReferenceObjectsConfig
Expand Down Expand Up @@ -426,9 +431,20 @@ def run(self, exposure, exposureIdInfo=None, background=None):
self.measurement.run(measCat=dmeRes.sourceCat, exposure=dmeRes.exposure,
exposureId=exposureIdInfo.expId)
if self.config.doApCorr:
apCorrMap = self.measureApCorr.run(exposure=dmeRes.exposure, catalog=dmeRes.sourceCat).apCorrMap
dmeRes.exposure.getInfo().setApCorrMap(apCorrMap)
self.applyApCorr.run(catalog=dmeRes.sourceCat, apCorrMap=exposure.getInfo().getApCorrMap())
try:
apCorrMap = self.measureApCorr.run(
exposure=dmeRes.exposure,
catalog=dmeRes.sourceCat,
).apCorrMap
except MeasureApCorrError:
# We have failed to get a valid aperture correction map.
# Proceed with processing, and image will be filtered
# downstream.
dmeRes.exposure.info.setApCorrMap(None)
else:
dmeRes.exposure.info.setApCorrMap(apCorrMap)
self.applyApCorr.run(catalog=dmeRes.sourceCat, apCorrMap=exposure.getInfo().getApCorrMap())

self.catalogCalculation.run(dmeRes.sourceCat)

self.display("measure", exposure=dmeRes.exposure, sourceCat=dmeRes.sourceCat)
Expand Down
8 changes: 7 additions & 1 deletion python/lsst/pipe/tasks/makeWarp.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ def _prepareCalibratedExposures(self, calExpList=[], wcsList=None, backgroundLis
if not self.config.bgSubtracted:
calexp.maskedImage += background.getImage()

detectorId = calexp.getInfo().getDetector().getId()
detectorId = calexp.info.getDetector().getId()

# Find the external photoCalib.
if externalPhotoCalibCatalog is not None:
Expand Down Expand Up @@ -713,6 +713,12 @@ def _prepareCalibratedExposures(self, calExpList=[], wcsList=None, backgroundLis
"and will not be used in the warp.", detectorId)
continue
calexp.info.setApCorrMap(apCorrMap)
else:
# Ensure that calexp has valid aperture correction map.
if calexp.info.getApCorrMap() is None:
self.log.warning("Detector id %s has None for ApCorrMap in the calexp "
"and will not be used in the warp.", detectorId)
continue

# Calibrate the image.
calexp.maskedImage = photoCalib.calibrateImage(calexp.maskedImage,
Expand Down