Skip to content

Commit f885f48

Browse files
committed
Slight hack for unpersistable empty BackgroundList
1 parent 215c095 commit f885f48

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

python/lsst/pipe/tasks/multiBand.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@
4747
from lsst.meas.extensions.scarlet.io import updateCatalogFootprints
4848
from lsst.meas.astrom import DirectMatchTask, denormalizeMatches
4949
from lsst.pipe.tasks.propagateSourceFlags import PropagateSourceFlagsTask
50-
import lsst.afw.table as afwTable
50+
import lsst.afw.image as afwImage
5151
import lsst.afw.math as afwMath
52+
import lsst.afw.table as afwTable
5253
from lsst.daf.base import PropertyList
5354
from lsst.skymap import BaseSkyMap
5455

@@ -309,6 +310,17 @@ def run(self, exposure, idFactory, expId, patchInfo=None):
309310
if hasattr(detections, "background") and detections.background:
310311
for bg in detections.background:
311312
backgrounds.append(bg)
313+
if len(backgrounds) == 0:
314+
# Persist a constant background with value of 0.0 to get around
315+
# inability to persist empty BackgroundList.
316+
bgLevel = 0.0
317+
bgStats = afwImage.MaskedImageF(1, 1)
318+
bgStats.set(bgLevel, 0, bgLevel)
319+
bg = afwMath.BackgroundMI(exposure.getBBox(), bgStats)
320+
bgData = (bg, afwMath.Interpolate.LINEAR, afwMath.REDUCE_INTERP_ORDER,
321+
afwMath.ApproximateControl.UNKNOWN, 0, 0, False)
322+
backgrounds.append(bgData)
323+
312324
return Struct(outputSources=sources, outputBackgrounds=backgrounds, outputExposure=exposure)
313325

314326
def _cropToExactBinning(self, exposure, patchInfo):

0 commit comments

Comments
 (0)