Skip to content

Commit 324cd09

Browse files
committed
Update to new deblender model API
1 parent 1955dfa commit 324cd09

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

python/lsst/meas/algorithms/setPrimaryFlags.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def __init__(self, *, schema, isSingleFrame=False, **kwargs):
8080
doc=primaryDoc,
8181
)
8282

83-
if "deblend_nChild" in schema.getNames():
83+
if "deblend_nChild" in schema.getNames() or "deblend_scarletFlux" in schema.getNames():
8484
self.includeDeblend = True
8585
self.isDeblendedSourceKey = self.schema.addField(
8686
"detect_isDeblendedSource", type="Flag",
@@ -285,26 +285,21 @@ def getDeblendPrimaryFlags(sources):
285285
True for each source that is a "DeblendedSourceModel"
286286
as defined above.
287287
"""
288-
nChildKey = "deblend_nChild"
289-
nChild = sources[nChildKey]
290288
parent = sources["parent"]
291289

292290
if "deblend_scarletFlux" in sources.schema:
293-
# The number of peaks in the sources footprint.
294-
# This (may be) different than nChild,
295-
# the number of deblended sources in the catalog,
296-
# because some peaks might have been culled during deblending.
297-
nPeaks = sources["deblend_nPeaks"]
291+
# The number of peaks in the parent footprint
298292
parentNChild = sources["deblend_parentNChild"]
299-
# It is possible for a catalog to contain a hierarchy of sources,
300-
# so we mark the leaves (end nodes of the hierarchy tree with no
301-
# children).
302-
isLeaf = nPeaks == 1
293+
# The number of peaks in the deconvolved-parent footprint
294+
blendNChild = sources["deblend_blendNChild"]
303295
fromBlend = parentNChild > 1
304-
isIsolated = isLeaf & ((parent == 0) | parentNChild == 1)
305-
isDeblendedSource = (fromBlend & isLeaf) | (isIsolated & (parent == 0))
306-
isDeblendedModelSource = (parent != 0) & isLeaf
296+
isIsolated = (blendNChild == 0) | (parentNChild == 1)
297+
isDeblendedSource = (blendNChild == 0) | (parentNChild > 1)
298+
isDeblendedModelSource = parent != 0
307299
else:
300+
nChildKey = "deblend_nChild"
301+
nChild = sources[nChildKey]
302+
parent = sources["parent"]
308303
# Set the flags for meas_deblender
309304
fromBlend = parent != 0
310305
isIsolated = (nChild == 0) & (parent == 0)

0 commit comments

Comments
 (0)