Skip to content

Commit 7bc6a53

Browse files
committed
Slight hack for unpersistable empty BackgroundList
1 parent bd29c5e commit 7bc6a53

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
@@ -53,8 +53,9 @@
5353
from lsst.meas.extensions.scarlet.io import updateCatalogFootprints
5454
from lsst.meas.astrom import DirectMatchTask, denormalizeMatches
5555
from lsst.pipe.tasks.propagateSourceFlags import PropagateSourceFlagsTask
56-
import lsst.afw.table as afwTable
56+
import lsst.afw.image as afwImage
5757
import lsst.afw.math as afwMath
58+
import lsst.afw.table as afwTable
5859
from lsst.daf.base import PropertyList
5960
from lsst.skymap import BaseSkyMap
6061

@@ -315,6 +316,17 @@ def run(self, exposure, idFactory, expId, patchInfo=None):
315316
if hasattr(detections, "background") and detections.background:
316317
for bg in detections.background:
317318
backgrounds.append(bg)
319+
if len(backgrounds) == 0:
320+
# Persist a constant background with value of 0.0 to get around
321+
# inability to persist empty BackgroundList.
322+
bgLevel = 0.0
323+
bgStats = afwImage.MaskedImageF(1, 1)
324+
bgStats.set(bgLevel, 0, bgLevel)
325+
bg = afwMath.BackgroundMI(exposure.getBBox(), bgStats)
326+
bgData = (bg, afwMath.Interpolate.LINEAR, afwMath.REDUCE_INTERP_ORDER,
327+
afwMath.ApproximateControl.UNKNOWN, 0, 0, False)
328+
backgrounds.append(bgData)
329+
318330
return Struct(outputSources=sources, outputBackgrounds=backgrounds, outputExposure=exposure)
319331

320332
def _cropToExactBinning(self, exposure, patchInfo):

0 commit comments

Comments
 (0)