Skip to content

Commit 9d5c6a2

Browse files
authored
Merge pull request #1160 from lsst/tickets/DM-52555
DM-52555: Fix failure when some bands have bad coadds
2 parents 3eec3fa + d375939 commit 9d5c6a2

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

python/lsst/pipe/tasks/deblendCoaddSourcesPipeline.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,15 @@ def __init__(self, initInputs, **kwargs):
171171
def runQuantum(self, butlerQC, inputRefs, outputRefs):
172172
# Obtain the list of bands, sort them (alphabetically), then reorder
173173
# all input lists to match this band order.
174-
coaddRefs = inputRefs.coadds_cell if self.config.useCellCoadds else inputRefs.coadds
175-
bandOrder = [dRef.dataId["band"] for dRef in coaddRefs]
174+
# Note: sometimes deconvolution fails. If this happens then
175+
# the dataIds missing from deconvolvedRefs will be removed
176+
# during the process.
177+
deconvolvedRefs = inputRefs.deconvolvedCoadds
178+
bandOrder = [dRef.dataId["band"] for dRef in deconvolvedRefs]
176179
bandOrder.sort()
177180
inputRefs = reorderRefs(inputRefs, bandOrder, dataIdKey="band")
178181
inputs = butlerQC.get(inputRefs)
179-
bands = [dRef.dataId["band"] for dRef in coaddRefs]
182+
bands = [dRef.dataId["band"] for dRef in deconvolvedRefs]
180183
mergedDetections = inputs.pop("mergedDetections")
181184
if self.config.useCellCoadds:
182185
exposures = [mcc.stitch().asExposure() for mcc in inputs.pop("coadds_cell")]
@@ -188,10 +191,14 @@ def runQuantum(self, butlerQC, inputRefs, outputRefs):
188191
coadds = inputs.pop("coadds")
189192

190193
# Ensure that the coadd bands and deconvolved coadd bands match
191-
deconvBands = [dRef.dataId["band"] for dRef in inputRefs.deconvolvedCoadds]
192-
if bands != deconvBands:
193-
self.log.error("Coadd bands %s != deconvolved coadd bands %s", bands, deconvBands)
194-
raise RuntimeError("Number of coadd bands and deconvolved coadd bands do not match")
194+
coaddRefs = inputRefs.coadds_cell if self.config.useCellCoadds else inputRefs.coadds
195+
coaddBands = [dRef.dataId["band"] for dRef in coaddRefs]
196+
if bands != coaddBands:
197+
self.log.error("Coadd bands %s != deconvolved coadd bands %s", bands, coaddBands)
198+
raise RuntimeError(
199+
"Number of coadd bands and deconvolved coadd bands do not match. "
200+
"This should never happen and indicates a bug in reorderRefs."
201+
)
195202

196203
deconvolvedCoadds = inputs.pop("deconvolvedCoadds")
197204

0 commit comments

Comments
 (0)