From b4daed4deea6674d4a807ee86f3dd2902c4a0018 Mon Sep 17 00:00:00 2001 From: fred3m Date: Fri, 14 Nov 2025 10:04:37 -0800 Subject: [PATCH 1/2] Update to new deblender model API --- .../lsst/meas/algorithms/setPrimaryFlags.py | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/python/lsst/meas/algorithms/setPrimaryFlags.py b/python/lsst/meas/algorithms/setPrimaryFlags.py index f08a326a2..0e4029cd8 100644 --- a/python/lsst/meas/algorithms/setPrimaryFlags.py +++ b/python/lsst/meas/algorithms/setPrimaryFlags.py @@ -80,7 +80,7 @@ def __init__(self, *, schema, isSingleFrame=False, **kwargs): doc=primaryDoc, ) - if "deblend_nChild" in schema.getNames(): + if "deblend_nChild" in schema.getNames() or "deblend_scarletFlux" in schema.getNames(): self.includeDeblend = True self.isDeblendedSourceKey = self.schema.addField( "detect_isDeblendedSource", type="Flag", @@ -285,26 +285,21 @@ def getDeblendPrimaryFlags(sources): True for each source that is a "DeblendedSourceModel" as defined above. """ - nChildKey = "deblend_nChild" - nChild = sources[nChildKey] parent = sources["parent"] if "deblend_scarletFlux" in sources.schema: - # The number of peaks in the sources footprint. - # This (may be) different than nChild, - # the number of deblended sources in the catalog, - # because some peaks might have been culled during deblending. - nPeaks = sources["deblend_nPeaks"] + # The number of peaks in the parent footprint parentNChild = sources["deblend_parentNChild"] - # It is possible for a catalog to contain a hierarchy of sources, - # so we mark the leaves (end nodes of the hierarchy tree with no - # children). - isLeaf = nPeaks == 1 + # The number of peaks in the deconvolved-parent footprint + blendNChild = sources["deblend_blendNChild"] fromBlend = parentNChild > 1 - isIsolated = isLeaf & ((parent == 0) | parentNChild == 1) - isDeblendedSource = (fromBlend & isLeaf) | (isIsolated & (parent == 0)) - isDeblendedModelSource = (parent != 0) & isLeaf + isIsolated = (blendNChild == 0) | (parentNChild == 1) + isDeblendedSource = (blendNChild == 0) | (parentNChild > 1) + isDeblendedModelSource = parent != 0 else: + nChildKey = "deblend_nChild" + nChild = sources[nChildKey] + parent = sources["parent"] # Set the flags for meas_deblender fromBlend = parent != 0 isIsolated = (nChild == 0) & (parent == 0) From fae7426f8fd45532c5bff3db3cc33a8ef0cfb065 Mon Sep 17 00:00:00 2001 From: fred3m Date: Fri, 21 Nov 2025 16:00:13 -0800 Subject: [PATCH 2/2] Simplify condition --- python/lsst/meas/algorithms/setPrimaryFlags.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/lsst/meas/algorithms/setPrimaryFlags.py b/python/lsst/meas/algorithms/setPrimaryFlags.py index 0e4029cd8..2adf985ce 100644 --- a/python/lsst/meas/algorithms/setPrimaryFlags.py +++ b/python/lsst/meas/algorithms/setPrimaryFlags.py @@ -80,7 +80,7 @@ def __init__(self, *, schema, isSingleFrame=False, **kwargs): doc=primaryDoc, ) - if "deblend_nChild" in schema.getNames() or "deblend_scarletFlux" in schema.getNames(): + if "deblend_nChild" in schema.getNames(): self.includeDeblend = True self.isDeblendedSourceKey = self.schema.addField( "detect_isDeblendedSource", type="Flag",