Coverage for python/lsst/meas/deblender/sourceDeblendTask.py: 18%
231 statements
« prev ^ index » next coverage.py v7.2.5, created at 2023-05-02 22:33 +0000
« prev ^ index » next coverage.py v7.2.5, created at 2023-05-02 22:33 +0000
1# This file is part of meas_deblender.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (https://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <https://www.gnu.org/licenses/>.
22__all__ = ['SourceDeblendConfig', 'SourceDeblendTask']
24import math
25import numpy as np
27import lsst.pex.config as pexConfig
28import lsst.pipe.base as pipeBase
29import lsst.afw.math as afwMath
30import lsst.geom as geom
31import lsst.afw.geom.ellipses as afwEll
32import lsst.afw.image as afwImage
33import lsst.afw.detection as afwDet
34import lsst.afw.table as afwTable
35from lsst.utils.timer import timeMethod
38class SourceDeblendConfig(pexConfig.Config):
40 edgeHandling = pexConfig.ChoiceField(
41 doc='What to do when a peak to be deblended is close to the edge of the image',
42 dtype=str, default='ramp',
43 allowed={
44 'clip': 'Clip the template at the edge AND the mirror of the edge.',
45 'ramp': 'Ramp down flux at the image edge by the PSF',
46 'noclip': 'Ignore the edge when building the symmetric template.',
47 }
48 )
50 strayFluxToPointSources = pexConfig.ChoiceField(
51 doc='When the deblender should attribute stray flux to point sources',
52 dtype=str, default='necessary',
53 allowed={
54 'necessary': 'When there is not an extended object in the footprint',
55 'always': 'Always',
56 'never': ('Never; stray flux will not be attributed to any deblended child '
57 'if the deblender thinks all peaks look like point sources'),
58 }
59 )
61 assignStrayFlux = pexConfig.Field(dtype=bool, default=True,
62 doc='Assign stray flux (not claimed by any child in the deblender) '
63 'to deblend children.')
65 strayFluxRule = pexConfig.ChoiceField(
66 doc='How to split flux among peaks',
67 dtype=str, default='trim',
68 allowed={
69 'r-to-peak': '~ 1/(1+R^2) to the peak',
70 'r-to-footprint': ('~ 1/(1+R^2) to the closest pixel in the footprint. '
71 'CAUTION: this can be computationally expensive on large footprints!'),
72 'nearest-footprint': ('Assign 100% to the nearest footprint (using L-1 norm aka '
73 'Manhattan distance)'),
74 'trim': ('Shrink the parent footprint to pixels that are not assigned to children')
75 }
76 )
78 clipStrayFluxFraction = pexConfig.Field(dtype=float, default=0.001,
79 doc=('When splitting stray flux, clip fractions below '
80 'this value to zero.'))
81 psfChisq1 = pexConfig.Field(dtype=float, default=1.5, optional=False,
82 doc=('Chi-squared per DOF cut for deciding a source is '
83 'a PSF during deblending (un-shifted PSF model)'))
84 psfChisq2 = pexConfig.Field(dtype=float, default=1.5, optional=False,
85 doc=('Chi-squared per DOF cut for deciding a source is '
86 'PSF during deblending (shifted PSF model)'))
87 psfChisq2b = pexConfig.Field(dtype=float, default=1.5, optional=False,
88 doc=('Chi-squared per DOF cut for deciding a source is '
89 'a PSF during deblending (shifted PSF model #2)'))
90 maxNumberOfPeaks = pexConfig.Field(dtype=int, default=0,
91 doc=("Only deblend the brightest maxNumberOfPeaks peaks in the parent"
92 " (<= 0: unlimited)"))
93 maxFootprintArea = pexConfig.Field(dtype=int, default=1000000,
94 doc=("Maximum area for footprints before they are ignored as large; "
95 "non-positive means no threshold applied"))
96 maxFootprintSize = pexConfig.Field(dtype=int, default=0,
97 doc=("Maximum linear dimension for footprints before they are ignored "
98 "as large; non-positive means no threshold applied"))
99 minFootprintAxisRatio = pexConfig.Field(dtype=float, default=0.0,
100 doc=("Minimum axis ratio for footprints before they are ignored "
101 "as large; non-positive means no threshold applied"))
102 notDeblendedMask = pexConfig.Field(dtype=str, default="NOT_DEBLENDED", optional=True,
103 doc="Mask name for footprints not deblended, or None")
105 tinyFootprintSize = pexConfig.RangeField(dtype=int, default=2, min=2, inclusiveMin=True,
106 doc=('Footprints smaller in width or height than this value '
107 'will be ignored; minimum of 2 due to PSF gradient '
108 'calculation.'))
110 propagateAllPeaks = pexConfig.Field(dtype=bool, default=False,
111 doc=('Guarantee that all peaks produce a child source.'))
112 catchFailures = pexConfig.Field(
113 dtype=bool,
114 default=True,
115 doc=("If True, catch exceptions thrown by the deblender, log them, "
116 "and set a flag on the parent, instead of letting them propagate up."))
117 maskPlanes = pexConfig.ListField(dtype=str, default=["SAT", "INTRP", "NO_DATA"],
118 doc="Mask planes to ignore when performing statistics")
119 maskLimits = pexConfig.DictField(
120 keytype=str,
121 itemtype=float,
122 default={},
123 doc=("Mask planes with the corresponding limit on the fraction of masked pixels. "
124 "Sources violating this limit will not be deblended."),
125 )
126 weightTemplates = pexConfig.Field(
127 dtype=bool, default=False,
128 doc=("If true, a least-squares fit of the templates will be done to the "
129 "full image. The templates will be re-weighted based on this fit."))
130 removeDegenerateTemplates = pexConfig.Field(dtype=bool, default=False,
131 doc=("Try to remove similar templates?"))
132 maxTempDotProd = pexConfig.Field(
133 dtype=float, default=0.5,
134 doc=("If the dot product between two templates is larger than this value, we consider them to be "
135 "describing the same object (i.e. they are degenerate). If one of the objects has been "
136 "labeled as a PSF it will be removed, otherwise the template with the lowest value will "
137 "be removed."))
138 medianSmoothTemplate = pexConfig.Field(dtype=bool, default=True,
139 doc="Apply a smoothing filter to all of the template images")
141 # Testing options
142 # Some obs packages and ci packages run the full pipeline on a small
143 # subset of data to test that the pipeline is functioning properly.
144 # This is not meant as scientific validation, so it can be useful
145 # to only run on a small subset of the data that is large enough to
146 # test the desired pipeline features but not so long that the deblender
147 # is the tall pole in terms of execution times.
148 useCiLimits = pexConfig.Field(
149 dtype=bool, default=False,
150 doc="Limit the number of sources deblended for CI to prevent long build times")
151 ciDeblendChildRange = pexConfig.ListField(
152 dtype=int, default=[2, 10],
153 doc="Only deblend parent Footprints with a number of peaks in the (inclusive) range indicated."
154 "If `useCiLimits==False` then this parameter is ignored.")
155 ciNumParentsToDeblend = pexConfig.Field(
156 dtype=int, default=10,
157 doc="Only use the first `ciNumParentsToDeblend` parent footprints with a total peak count "
158 "within `ciDebledChildRange`. "
159 "If `useCiLimits==False` then this parameter is ignored.")
162class SourceDeblendTask(pipeBase.Task):
163 """Split blended sources into individual sources.
165 This task has no return value; it only modifies the SourceCatalog in-place.
166 """
167 ConfigClass = SourceDeblendConfig
168 _DefaultName = "sourceDeblend"
170 def __init__(self, schema, peakSchema=None, **kwargs):
171 """Create the task, adding necessary fields to the given schema.
173 Parameters
174 ----------
175 schema : `lsst.afw.table.Schema`
176 Schema object for measurement fields; will be modified in-place.
177 peakSchema : `lsst.afw.table.peakSchema`
178 Schema of Footprint Peaks that will be passed to the deblender.
179 Any fields beyond the PeakTable minimal schema will be transferred
180 to the main source Schema. If None, no fields will be transferred
181 from the Peaks
182 **kwargs
183 Additional keyword arguments passed to ~lsst.pipe.base.task
184 """
185 pipeBase.Task.__init__(self, **kwargs)
186 self.schema = schema
187 self.toCopyFromParent = [item.key for item in self.schema
188 if item.field.getName().startswith("merge_footprint")]
189 peakMinimalSchema = afwDet.PeakTable.makeMinimalSchema()
190 if peakSchema is None:
191 # In this case, the peakSchemaMapper will transfer nothing, but we'll still have one
192 # to simplify downstream code
193 self.peakSchemaMapper = afwTable.SchemaMapper(peakMinimalSchema, schema)
194 else:
195 self.peakSchemaMapper = afwTable.SchemaMapper(peakSchema, schema)
196 for item in peakSchema:
197 if item.key not in peakMinimalSchema:
198 self.peakSchemaMapper.addMapping(item.key, item.field)
199 # Because SchemaMapper makes a copy of the output schema you give its ctor, it isn't
200 # updating this Schema in place. That's probably a design flaw, but in the meantime,
201 # we'll keep that schema in sync with the peakSchemaMapper.getOutputSchema() manually,
202 # by adding the same fields to both.
203 schema.addField(item.field)
204 assert schema == self.peakSchemaMapper.getOutputSchema(), "Logic bug mapping schemas"
205 self.addSchemaKeys(schema)
207 def addSchemaKeys(self, schema):
208 self.nChildKey = schema.addField('deblend_nChild', type=np.int32,
209 doc='Number of children this object has (defaults to 0)')
210 self.psfKey = schema.addField('deblend_deblendedAsPsf', type='Flag',
211 doc='Deblender thought this source looked like a PSF')
212 self.psfCenterKey = afwTable.Point2DKey.addFields(schema, 'deblend_psfCenter',
213 'If deblended-as-psf, the PSF centroid', "pixel")
214 self.psfFluxKey = schema.addField('deblend_psf_instFlux', type='D',
215 doc='If deblended-as-psf, the instrumental PSF flux', units='count')
216 self.tooManyPeaksKey = schema.addField('deblend_tooManyPeaks', type='Flag',
217 doc='Source had too many peaks; '
218 'only the brightest were included')
219 self.tooBigKey = schema.addField('deblend_parentTooBig', type='Flag',
220 doc='Parent footprint covered too many pixels')
221 self.maskedKey = schema.addField('deblend_masked', type='Flag',
222 doc='Parent footprint was predominantly masked')
224 if self.config.catchFailures:
225 self.deblendFailedKey = schema.addField('deblend_failed', type='Flag',
226 doc="Deblending failed on source")
228 self.deblendSkippedKey = schema.addField('deblend_skipped', type='Flag',
229 doc="Deblender skipped this source")
231 self.deblendRampedTemplateKey = schema.addField(
232 'deblend_rampedTemplate', type='Flag',
233 doc=('This source was near an image edge and the deblender used '
234 '"ramp" edge-handling.'))
236 self.deblendPatchedTemplateKey = schema.addField(
237 'deblend_patchedTemplate', type='Flag',
238 doc=('This source was near an image edge and the deblender used '
239 '"patched" edge-handling.'))
241 self.hasStrayFluxKey = schema.addField(
242 'deblend_hasStrayFlux', type='Flag',
243 doc=('This source was assigned some stray flux'))
245 self.log.trace('Added keys to schema: %s', ", ".join(str(x) for x in (
246 self.nChildKey, self.psfKey, self.psfCenterKey, self.psfFluxKey,
247 self.tooManyPeaksKey, self.tooBigKey)))
248 self.peakCenter = afwTable.Point2IKey.addFields(schema, name="deblend_peak_center",
249 doc="Center used to apply constraints in scarlet",
250 unit="pixel")
251 self.peakIdKey = schema.addField("deblend_peakId", type=np.int32,
252 doc="ID of the peak in the parent footprint. "
253 "This is not unique, but the combination of 'parent'"
254 "and 'peakId' should be for all child sources. "
255 "Top level blends with no parents have 'peakId=0'")
256 self.nPeaksKey = schema.addField("deblend_nPeaks", type=np.int32,
257 doc="Number of initial peaks in the blend. "
258 "This includes peaks that may have been culled "
259 "during deblending or failed to deblend")
260 self.parentNPeaksKey = schema.addField("deblend_parentNPeaks", type=np.int32,
261 doc="Same as deblend_n_peaks, but the number of peaks "
262 "in the parent footprint")
264 @timeMethod
265 def run(self, exposure, sources):
266 """Get the PSF from the provided exposure and then run deblend.
268 Parameters
269 ----------
270 exposure : `lsst.afw.image.Exposure`
271 Exposure to be processed
272 sources : `lsst.afw.table.SourceCatalog`
273 SourceCatalog containing sources detected on this exposure.
274 """
275 psf = exposure.getPsf()
276 assert sources.getSchema() == self.schema
277 self.deblend(exposure, sources, psf)
279 def _getPsfFwhm(self, psf, position):
280 return psf.computeShape(position).getDeterminantRadius() * 2.35
282 @timeMethod
283 def deblend(self, exposure, srcs, psf):
284 """Deblend.
286 Parameters
287 ----------
288 exposure : `lsst.afw.image.Exposure`
289 Exposure to be processed
290 srcs : `lsst.afw.table.SourceCatalog`
291 SourceCatalog containing sources detected on this exposure
292 psf : `lsst.afw.detection.Psf`
293 Point source function
295 Returns
296 -------
297 None
298 """
299 # Cull footprints if required by ci
300 if self.config.useCiLimits:
301 self.log.info(f"Using CI catalog limits, "
302 f"the original number of sources to deblend was {len(srcs)}.")
303 # Select parents with a number of children in the range
304 # config.ciDeblendChildRange
305 minChildren, maxChildren = self.config.ciDeblendChildRange
306 nPeaks = np.array([len(src.getFootprint().peaks) for src in srcs])
307 childrenInRange = np.where((nPeaks >= minChildren) & (nPeaks <= maxChildren))[0]
308 if len(childrenInRange) < self.config.ciNumParentsToDeblend:
309 raise ValueError("Fewer than ciNumParentsToDeblend children were contained in the range "
310 "indicated by ciDeblendChildRange. Adjust this range to include more "
311 "parents.")
312 # Keep all of the isolated parents and the first
313 # `ciNumParentsToDeblend` children
314 parents = nPeaks == 1
315 children = np.zeros((len(srcs),), dtype=bool)
316 children[childrenInRange[:self.config.ciNumParentsToDeblend]] = True
317 srcs = srcs[parents | children]
318 # We need to update the IdFactory, otherwise the the source ids
319 # will not be sequential
320 idFactory = srcs.getIdFactory()
321 maxId = np.max(srcs["id"])
322 idFactory.notify(maxId)
324 self.log.info("Deblending %d sources", len(srcs))
326 from lsst.meas.deblender.baseline import deblend
328 # find the median stdev in the image...
329 mi = exposure.getMaskedImage()
330 statsCtrl = afwMath.StatisticsControl()
331 statsCtrl.setAndMask(mi.getMask().getPlaneBitMask(self.config.maskPlanes))
332 stats = afwMath.makeStatistics(mi.getVariance(), mi.getMask(), afwMath.MEDIAN, statsCtrl)
333 sigma1 = math.sqrt(stats.getValue(afwMath.MEDIAN))
334 self.log.trace('sigma1: %g', sigma1)
336 n0 = len(srcs)
337 nparents = 0
338 for i, src in enumerate(srcs):
339 # t0 = time.clock()
341 fp = src.getFootprint()
342 pks = fp.getPeaks()
344 # Since we use the first peak for the parent object, we should propagate its flags
345 # to the parent source.
346 src.assign(pks[0], self.peakSchemaMapper)
348 if len(pks) < 2:
349 continue
351 if self.isLargeFootprint(fp):
352 src.set(self.tooBigKey, True)
353 self.skipParent(src, mi.getMask())
354 self.log.warning('Parent %i: skipping large footprint (area: %i)',
355 int(src.getId()), int(fp.getArea()))
356 continue
357 if self.isMasked(fp, exposure.getMaskedImage().getMask()):
358 src.set(self.maskedKey, True)
359 self.skipParent(src, mi.getMask())
360 self.log.warning('Parent %i: skipping masked footprint (area: %i)',
361 int(src.getId()), int(fp.getArea()))
362 continue
364 nparents += 1
365 center = fp.getCentroid()
366 psf_fwhm = self._getPsfFwhm(psf, center)
368 self.log.trace('Parent %i: deblending %i peaks', int(src.getId()), len(pks))
370 self.preSingleDeblendHook(exposure, srcs, i, fp, psf, psf_fwhm, sigma1)
371 npre = len(srcs)
373 # This should really be set in deblend, but deblend doesn't have access to the src
374 src.set(self.tooManyPeaksKey, len(fp.getPeaks()) > self.config.maxNumberOfPeaks)
376 try:
377 res = deblend(
378 fp, mi, psf, psf_fwhm, sigma1=sigma1,
379 psfChisqCut1=self.config.psfChisq1,
380 psfChisqCut2=self.config.psfChisq2,
381 psfChisqCut2b=self.config.psfChisq2b,
382 maxNumberOfPeaks=self.config.maxNumberOfPeaks,
383 strayFluxToPointSources=self.config.strayFluxToPointSources,
384 assignStrayFlux=self.config.assignStrayFlux,
385 strayFluxAssignment=self.config.strayFluxRule,
386 rampFluxAtEdge=(self.config.edgeHandling == 'ramp'),
387 patchEdges=(self.config.edgeHandling == 'noclip'),
388 tinyFootprintSize=self.config.tinyFootprintSize,
389 clipStrayFluxFraction=self.config.clipStrayFluxFraction,
390 weightTemplates=self.config.weightTemplates,
391 removeDegenerateTemplates=self.config.removeDegenerateTemplates,
392 maxTempDotProd=self.config.maxTempDotProd,
393 medianSmoothTemplate=self.config.medianSmoothTemplate
394 )
395 if self.config.catchFailures:
396 src.set(self.deblendFailedKey, False)
397 except Exception as e:
398 if self.config.catchFailures:
399 self.log.warning("Unable to deblend source %d: %s", src.getId(), e)
400 src.set(self.deblendFailedKey, True)
401 import traceback
402 traceback.print_exc()
403 continue
404 else:
405 raise
407 kids = []
408 nchild = 0
409 for j, peak in enumerate(res.deblendedParents[0].peaks):
410 heavy = peak.getFluxPortion()
411 if heavy is None or peak.skip:
412 src.set(self.deblendSkippedKey, True)
413 if not self.config.propagateAllPeaks:
414 # Don't care
415 continue
416 # We need to preserve the peak: make sure we have enough info to create a minimal
417 # child src
418 self.log.trace("Peak at (%i,%i) failed. Using minimal default info for child.",
419 pks[j].getIx(), pks[j].getIy())
420 if heavy is None:
421 # copy the full footprint and strip out extra peaks
422 foot = afwDet.Footprint(src.getFootprint())
423 peakList = foot.getPeaks()
424 peakList.clear()
425 peakList.append(peak.peak)
426 zeroMimg = afwImage.MaskedImageF(foot.getBBox())
427 heavy = afwDet.makeHeavyFootprint(foot, zeroMimg)
428 if peak.deblendedAsPsf:
429 if peak.psfFitFlux is None:
430 peak.psfFitFlux = 0.0
431 if peak.psfFitCenter is None:
432 peak.psfFitCenter = (peak.peak.getIx(), peak.peak.getIy())
434 assert(len(heavy.getPeaks()) == 1)
436 src.set(self.deblendSkippedKey, False)
437 child = srcs.addNew()
438 nchild += 1
439 for key in self.toCopyFromParent:
440 child.set(key, src.get(key))
441 child.assign(heavy.getPeaks()[0], self.peakSchemaMapper)
442 child.setParent(src.getId())
443 child.setFootprint(heavy)
444 child.set(self.psfKey, peak.deblendedAsPsf)
445 child.set(self.hasStrayFluxKey, peak.strayFlux is not None)
446 if peak.deblendedAsPsf:
447 (cx, cy) = peak.psfFitCenter
448 child.set(self.psfCenterKey, geom.Point2D(cx, cy))
449 child.set(self.psfFluxKey, peak.psfFitFlux)
450 child.set(self.deblendRampedTemplateKey, peak.hasRampedTemplate)
451 child.set(self.deblendPatchedTemplateKey, peak.patched)
453 # Set the position of the peak from the parent footprint
454 # This will make it easier to match the same source across
455 # deblenders and across observations, where the peak
456 # position is unlikely to change unless enough time passes
457 # for a source to move on the sky.
458 child.set(self.peakCenter, geom.Point2I(pks[j].getIx(), pks[j].getIy()))
459 child.set(self.peakIdKey, pks[j].getId())
461 # The children have a single peak
462 child.set(self.nPeaksKey, 1)
463 # Set the number of peaks in the parent
464 child.set(self.parentNPeaksKey, len(pks))
466 kids.append(child)
468 # Child footprints may extend beyond the full extent of their parent's which
469 # results in a failure of the replace-by-noise code to reinstate these pixels
470 # to their original values. The following updates the parent footprint
471 # in-place to ensure it contains the full union of itself and all of its
472 # children's footprints.
473 spans = src.getFootprint().spans
474 for child in kids:
475 spans = spans.union(child.getFootprint().spans)
476 src.getFootprint().setSpans(spans)
478 src.set(self.nChildKey, nchild)
480 self.postSingleDeblendHook(exposure, srcs, i, npre, kids, fp, psf, psf_fwhm, sigma1, res)
481 # print('Deblending parent id', src.getId(), 'took', time.clock() - t0)
483 n1 = len(srcs)
484 self.log.info('Deblended: of %i sources, %i were deblended, creating %i children, total %i sources',
485 n0, nparents, n1-n0, n1)
487 def preSingleDeblendHook(self, exposure, srcs, i, fp, psf, psf_fwhm, sigma1):
488 pass
490 def postSingleDeblendHook(self, exposure, srcs, i, npre, kids, fp, psf, psf_fwhm, sigma1, res):
491 pass
493 def isLargeFootprint(self, footprint):
494 """Returns whether a Footprint is large
496 'Large' is defined by thresholds on the area, size and axis ratio.
497 These may be disabled independently by configuring them to be non-positive.
499 This is principally intended to get rid of satellite streaks, which the
500 deblender or other downstream processing can have trouble dealing with
501 (e.g., multiple large HeavyFootprints can chew up memory).
502 """
503 if self.config.maxFootprintArea > 0 and footprint.getArea() > self.config.maxFootprintArea:
504 return True
505 if self.config.maxFootprintSize > 0:
506 bbox = footprint.getBBox()
507 if max(bbox.getWidth(), bbox.getHeight()) > self.config.maxFootprintSize:
508 return True
509 if self.config.minFootprintAxisRatio > 0:
510 axes = afwEll.Axes(footprint.getShape())
511 if axes.getB() < self.config.minFootprintAxisRatio*axes.getA():
512 return True
513 return False
515 def isMasked(self, footprint, mask):
516 """Returns whether the footprint violates the mask limits
517 """
518 size = float(footprint.getArea())
519 for maskName, limit in self.config.maskLimits.items():
520 maskVal = mask.getPlaneBitMask(maskName)
521 unmaskedSpan = footprint.spans.intersectNot(mask, maskVal) # spanset of unmasked pixels
522 if (size - unmaskedSpan.getArea())/size > limit:
523 return True
524 return False
526 def skipParent(self, source, mask):
527 """Indicate that the parent source is not being deblended
529 We set the appropriate flags and mask.
531 Parameters
532 ----------
533 source : `lsst.afw.table.SourceRecord`
534 The source to flag as skipped
535 mask : `lsst.afw.image.Mask`
536 The mask to update
537 """
538 fp = source.getFootprint()
539 source.set(self.deblendSkippedKey, True)
540 if self.config.notDeblendedMask:
541 mask.addMaskPlane(self.config.notDeblendedMask)
542 fp.spans.setMask(mask, mask.getPlaneBitMask(self.config.notDeblendedMask))
544 # Set the center of the parent
545 bbox = fp.getBBox()
546 centerX = int(bbox.getMinX()+bbox.getWidth()/2)
547 centerY = int(bbox.getMinY()+bbox.getHeight()/2)
548 source.set(self.peakCenter, geom.Point2I(centerX, centerY))
549 # There are no deblended children, so nChild = 0
550 source.set(self.nChildKey, 0)
551 # But we also want to know how many peaks that we would have
552 # deblended if the parent wasn't skipped.
553 source.set(self.nPeaksKey, len(fp.peaks))
554 # Top level parents are not a detected peak, so they have no peakId
555 source.set(self.peakIdKey, 0)
556 # Top level parents also have no parentNPeaks
557 source.set(self.parentNPeaksKey, 0)