LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask Class Reference
Inheritance diagram for lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask:

Public Member Functions

def __init__ (self, schema, peakSchema=None, **kwargs)
 
def addSchemaKeys (self, schema)
 
def run (self, exposure, sources)
 
def deblend (self, exposure, srcs, psf)
 
def preSingleDeblendHook (self, exposure, srcs, i, fp, psf, psf_fwhm, sigma1)
 
def postSingleDeblendHook (self, exposure, srcs, i, npre, kids, fp, psf, psf_fwhm, sigma1, res)
 
def isLargeFootprint (self, footprint)
 
def isMasked (self, footprint, mask)
 
def skipParent (self, source, mask)
 

Public Attributes

 schema
 
 toCopyFromParent
 
 peakSchemaMapper
 
 nChildKey
 
 psfKey
 
 psfCenterKey
 
 psfFluxKey
 
 tooManyPeaksKey
 
 tooBigKey
 
 maskedKey
 
 deblendFailedKey
 
 deblendSkippedKey
 
 deblendRampedTemplateKey
 
 deblendPatchedTemplateKey
 
 hasStrayFluxKey
 
 peakCenter
 
 peakIdKey
 
 nPeaksKey
 
 parentNPeaksKey
 

Static Public Attributes

 ConfigClass = SourceDeblendConfig
 

Detailed Description

Split blended sources into individual sources.

This task has no return value; it only modifies the SourceCatalog in-place.

Definition at line 161 of file sourceDeblendTask.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.__init__ (   self,
  schema,
  peakSchema = None,
**  kwargs 
)
Create the task, adding necessary fields to the given schema.

Parameters
----------
schema : `lsst.afw.table.Schema`
    Schema object for measurement fields; will be modified in-place.
peakSchema : `lsst.afw.table.peakSchema`
    Schema of Footprint Peaks that will be passed to the deblender.
    Any fields beyond the PeakTable minimal schema will be transferred
    to the main source Schema. If None, no fields will be transferred
    from the Peaks
**kwargs
    Additional keyword arguments passed to ~lsst.pipe.base.task

Definition at line 169 of file sourceDeblendTask.py.

169  def __init__(self, schema, peakSchema=None, **kwargs):
170  """Create the task, adding necessary fields to the given schema.
171 
172  Parameters
173  ----------
174  schema : `lsst.afw.table.Schema`
175  Schema object for measurement fields; will be modified in-place.
176  peakSchema : `lsst.afw.table.peakSchema`
177  Schema of Footprint Peaks that will be passed to the deblender.
178  Any fields beyond the PeakTable minimal schema will be transferred
179  to the main source Schema. If None, no fields will be transferred
180  from the Peaks
181  **kwargs
182  Additional keyword arguments passed to ~lsst.pipe.base.task
183  """
184  pipeBase.Task.__init__(self, **kwargs)
185  self.schema = schema
186  self.toCopyFromParent = [item.key for item in self.schema
187  if item.field.getName().startswith("merge_footprint")]
188  peakMinimalSchema = afwDet.PeakTable.makeMinimalSchema()
189  if peakSchema is None:
190  # In this case, the peakSchemaMapper will transfer nothing, but we'll still have one
191  # to simplify downstream code
192  self.peakSchemaMapper = afwTable.SchemaMapper(peakMinimalSchema, schema)
193  else:
194  self.peakSchemaMapper = afwTable.SchemaMapper(peakSchema, schema)
195  for item in peakSchema:
196  if item.key not in peakMinimalSchema:
197  self.peakSchemaMapper.addMapping(item.key, item.field)
198  # Because SchemaMapper makes a copy of the output schema you give its ctor, it isn't
199  # updating this Schema in place. That's probably a design flaw, but in the meantime,
200  # we'll keep that schema in sync with the peakSchemaMapper.getOutputSchema() manually,
201  # by adding the same fields to both.
202  schema.addField(item.field)
203  assert schema == self.peakSchemaMapper.getOutputSchema(), "Logic bug mapping schemas"
204  self.addSchemaKeys(schema)
205 
A mapping between the keys of two Schemas, used to copy data between them.
Definition: SchemaMapper.h:21

Member Function Documentation

◆ addSchemaKeys()

def lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.addSchemaKeys (   self,
  schema 
)

Definition at line 206 of file sourceDeblendTask.py.

206  def addSchemaKeys(self, schema):
207  self.nChildKey = schema.addField('deblend_nChild', type=np.int32,
208  doc='Number of children this object has (defaults to 0)')
209  self.psfKey = schema.addField('deblend_deblendedAsPsf', type='Flag',
210  doc='Deblender thought this source looked like a PSF')
211  self.psfCenterKey = afwTable.Point2DKey.addFields(schema, 'deblend_psfCenter',
212  'If deblended-as-psf, the PSF centroid', "pixel")
213  self.psfFluxKey = schema.addField('deblend_psf_instFlux', type='D',
214  doc='If deblended-as-psf, the instrumental PSF flux', units='count')
215  self.tooManyPeaksKey = schema.addField('deblend_tooManyPeaks', type='Flag',
216  doc='Source had too many peaks; '
217  'only the brightest were included')
218  self.tooBigKey = schema.addField('deblend_parentTooBig', type='Flag',
219  doc='Parent footprint covered too many pixels')
220  self.maskedKey = schema.addField('deblend_masked', type='Flag',
221  doc='Parent footprint was predominantly masked')
222 
223  if self.config.catchFailures:
224  self.deblendFailedKey = schema.addField('deblend_failed', type='Flag',
225  doc="Deblending failed on source")
226 
227  self.deblendSkippedKey = schema.addField('deblend_skipped', type='Flag',
228  doc="Deblender skipped this source")
229 
230  self.deblendRampedTemplateKey = schema.addField(
231  'deblend_rampedTemplate', type='Flag',
232  doc=('This source was near an image edge and the deblender used '
233  '"ramp" edge-handling.'))
234 
235  self.deblendPatchedTemplateKey = schema.addField(
236  'deblend_patchedTemplate', type='Flag',
237  doc=('This source was near an image edge and the deblender used '
238  '"patched" edge-handling.'))
239 
240  self.hasStrayFluxKey = schema.addField(
241  'deblend_hasStrayFlux', type='Flag',
242  doc=('This source was assigned some stray flux'))
243 
244  self.log.trace('Added keys to schema: %s', ", ".join(str(x) for x in (
245  self.nChildKey, self.psfKey, self.psfCenterKey, self.psfFluxKey,
246  self.tooManyPeaksKey, self.tooBigKey)))
247  self.peakCenter = afwTable.Point2IKey.addFields(schema, name="deblend_peak_center",
248  doc="Center used to apply constraints in scarlet",
249  unit="pixel")
250  self.peakIdKey = schema.addField("deblend_peakId", type=np.int32,
251  doc="ID of the peak in the parent footprint. "
252  "This is not unique, but the combination of 'parent'"
253  "and 'peakId' should be for all child sources. "
254  "Top level blends with no parents have 'peakId=0'")
255  self.nPeaksKey = schema.addField("deblend_nPeaks", type=np.int32,
256  doc="Number of initial peaks in the blend. "
257  "This includes peaks that may have been culled "
258  "during deblending or failed to deblend")
259  self.parentNPeaksKey = schema.addField("deblend_parentNPeaks", type=np.int32,
260  doc="Same as deblend_n_peaks, but the number of peaks "
261  "in the parent footprint")
262 

◆ deblend()

def lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.deblend (   self,
  exposure,
  srcs,
  psf 
)
Deblend.

Parameters
----------
exposure : `lsst.afw.image.Exposure`
    Exposure to be processed
srcs : `lsst.afw.table.SourceCatalog`
    SourceCatalog containing sources detected on this exposure
psf : `lsst.afw.detection.Psf`
    Point source function

Returns
-------
None

Definition at line 284 of file sourceDeblendTask.py.

284  def deblend(self, exposure, srcs, psf):
285  """Deblend.
286 
287  Parameters
288  ----------
289  exposure : `lsst.afw.image.Exposure`
290  Exposure to be processed
291  srcs : `lsst.afw.table.SourceCatalog`
292  SourceCatalog containing sources detected on this exposure
293  psf : `lsst.afw.detection.Psf`
294  Point source function
295 
296  Returns
297  -------
298  None
299  """
300  # Cull footprints if required by ci
301  if self.config.useCiLimits:
302  self.log.info(f"Using CI catalog limits, "
303  f"the original number of sources to deblend was {len(srcs)}.")
304  # Select parents with a number of children in the range
305  # config.ciDeblendChildRange
306  minChildren, maxChildren = self.config.ciDeblendChildRange
307  nPeaks = np.array([len(src.getFootprint().peaks) for src in srcs])
308  childrenInRange = np.where((nPeaks >= minChildren) & (nPeaks <= maxChildren))[0]
309  if len(childrenInRange) < self.config.ciNumParentsToDeblend:
310  raise ValueError("Fewer than ciNumParentsToDeblend children were contained in the range "
311  "indicated by ciDeblendChildRange. Adjust this range to include more "
312  "parents.")
313  # Keep all of the isolated parents and the first
314  # `ciNumParentsToDeblend` children
315  parents = nPeaks == 1
316  children = np.zeros((len(srcs),), dtype=bool)
317  children[childrenInRange[:self.config.ciNumParentsToDeblend]] = True
318  srcs = srcs[parents | children]
319  # We need to update the IdFactory, otherwise the the source ids
320  # will not be sequential
321  idFactory = srcs.getIdFactory()
322  maxId = np.max(srcs["id"])
323  idFactory.notify(maxId)
324 
325  self.log.info("Deblending %d sources", len(srcs))
326 
327  from lsst.meas.deblender.baseline import deblend
328 
329  # find the median stdev in the image...
330  mi = exposure.getMaskedImage()
331  statsCtrl = afwMath.StatisticsControl()
332  statsCtrl.setAndMask(mi.getMask().getPlaneBitMask(self.config.maskPlanes))
333  stats = afwMath.makeStatistics(mi.getVariance(), mi.getMask(), afwMath.MEDIAN, statsCtrl)
334  sigma1 = math.sqrt(stats.getValue(afwMath.MEDIAN))
335  self.log.trace('sigma1: %g', sigma1)
336 
337  n0 = len(srcs)
338  nparents = 0
339  for i, src in enumerate(srcs):
340  # t0 = time.clock()
341 
342  fp = src.getFootprint()
343  pks = fp.getPeaks()
344 
345  # Since we use the first peak for the parent object, we should propagate its flags
346  # to the parent source.
347  src.assign(pks[0], self.peakSchemaMapper)
348 
349  if len(pks) < 2:
350  continue
351 
352  if self.isLargeFootprint(fp):
353  src.set(self.tooBigKey, True)
354  self.skipParent(src, mi.getMask())
355  self.log.warning('Parent %i: skipping large footprint (area: %i)',
356  int(src.getId()), int(fp.getArea()))
357  continue
358  if self.isMasked(fp, exposure.getMaskedImage().getMask()):
359  src.set(self.maskedKey, True)
360  self.skipParent(src, mi.getMask())
361  self.log.warning('Parent %i: skipping masked footprint (area: %i)',
362  int(src.getId()), int(fp.getArea()))
363  continue
364 
365  nparents += 1
366  bb = fp.getBBox()
367  psf_fwhm = self._getPsfFwhm(psf, bb)
368 
369  self.log.trace('Parent %i: deblending %i peaks', int(src.getId()), len(pks))
370 
371  self.preSingleDeblendHook(exposure, srcs, i, fp, psf, psf_fwhm, sigma1)
372  npre = len(srcs)
373 
374  # This should really be set in deblend, but deblend doesn't have access to the src
375  src.set(self.tooManyPeaksKey, len(fp.getPeaks()) > self.config.maxNumberOfPeaks)
376 
377  try:
378  res = deblend(
379  fp, mi, psf, psf_fwhm, sigma1=sigma1,
380  psfChisqCut1=self.config.psfChisq1,
381  psfChisqCut2=self.config.psfChisq2,
382  psfChisqCut2b=self.config.psfChisq2b,
383  maxNumberOfPeaks=self.config.maxNumberOfPeaks,
384  strayFluxToPointSources=self.config.strayFluxToPointSources,
385  assignStrayFlux=self.config.assignStrayFlux,
386  strayFluxAssignment=self.config.strayFluxRule,
387  rampFluxAtEdge=(self.config.edgeHandling == 'ramp'),
388  patchEdges=(self.config.edgeHandling == 'noclip'),
389  tinyFootprintSize=self.config.tinyFootprintSize,
390  clipStrayFluxFraction=self.config.clipStrayFluxFraction,
391  weightTemplates=self.config.weightTemplates,
392  removeDegenerateTemplates=self.config.removeDegenerateTemplates,
393  maxTempDotProd=self.config.maxTempDotProd,
394  medianSmoothTemplate=self.config.medianSmoothTemplate
395  )
396  if self.config.catchFailures:
397  src.set(self.deblendFailedKey, False)
398  except Exception as e:
399  if self.config.catchFailures:
400  self.log.warning("Unable to deblend source %d: %s", src.getId(), e)
401  src.set(self.deblendFailedKey, True)
402  import traceback
403  traceback.print_exc()
404  continue
405  else:
406  raise
407 
408  kids = []
409  nchild = 0
410  for j, peak in enumerate(res.deblendedParents[0].peaks):
411  heavy = peak.getFluxPortion()
412  if heavy is None or peak.skip:
413  src.set(self.deblendSkippedKey, True)
414  if not self.config.propagateAllPeaks:
415  # Don't care
416  continue
417  # We need to preserve the peak: make sure we have enough info to create a minimal
418  # child src
419  self.log.trace("Peak at (%i,%i) failed. Using minimal default info for child.",
420  pks[j].getIx(), pks[j].getIy())
421  if heavy is None:
422  # copy the full footprint and strip out extra peaks
423  foot = afwDet.Footprint(src.getFootprint())
424  peakList = foot.getPeaks()
425  peakList.clear()
426  peakList.append(peak.peak)
427  zeroMimg = afwImage.MaskedImageF(foot.getBBox())
428  heavy = afwDet.makeHeavyFootprint(foot, zeroMimg)
429  if peak.deblendedAsPsf:
430  if peak.psfFitFlux is None:
431  peak.psfFitFlux = 0.0
432  if peak.psfFitCenter is None:
433  peak.psfFitCenter = (peak.peak.getIx(), peak.peak.getIy())
434 
435  assert(len(heavy.getPeaks()) == 1)
436 
437  src.set(self.deblendSkippedKey, False)
438  child = srcs.addNew()
439  nchild += 1
440  for key in self.toCopyFromParent:
441  child.set(key, src.get(key))
442  child.assign(heavy.getPeaks()[0], self.peakSchemaMapper)
443  child.setParent(src.getId())
444  child.setFootprint(heavy)
445  child.set(self.psfKey, peak.deblendedAsPsf)
446  child.set(self.hasStrayFluxKey, peak.strayFlux is not None)
447  if peak.deblendedAsPsf:
448  (cx, cy) = peak.psfFitCenter
449  child.set(self.psfCenterKey, geom.Point2D(cx, cy))
450  child.set(self.psfFluxKey, peak.psfFitFlux)
451  child.set(self.deblendRampedTemplateKey, peak.hasRampedTemplate)
452  child.set(self.deblendPatchedTemplateKey, peak.patched)
453 
454  # Set the position of the peak from the parent footprint
455  # This will make it easier to match the same source across
456  # deblenders and across observations, where the peak
457  # position is unlikely to change unless enough time passes
458  # for a source to move on the sky.
459  child.set(self.peakCenter, geom.Point2I(pks[j].getIx(), pks[j].getIy()))
460  child.set(self.peakIdKey, pks[j].getId())
461 
462  # The children have a single peak
463  child.set(self.nPeaksKey, 1)
464  # Set the number of peaks in the parent
465  child.set(self.parentNPeaksKey, len(pks))
466 
467  kids.append(child)
468 
469  # Child footprints may extend beyond the full extent of their parent's which
470  # results in a failure of the replace-by-noise code to reinstate these pixels
471  # to their original values. The following updates the parent footprint
472  # in-place to ensure it contains the full union of itself and all of its
473  # children's footprints.
474  spans = src.getFootprint().spans
475  for child in kids:
476  spans = spans.union(child.getFootprint().spans)
477  src.getFootprint().setSpans(spans)
478 
479  src.set(self.nChildKey, nchild)
480 
481  self.postSingleDeblendHook(exposure, srcs, i, npre, kids, fp, psf, psf_fwhm, sigma1, res)
482  # print('Deblending parent id', src.getId(), 'took', time.clock() - t0)
483 
484  n1 = len(srcs)
485  self.log.info('Deblended: of %i sources, %i were deblended, creating %i children, total %i sources',
486  n0, nparents, n1-n0, n1)
487 
Class to describe the properties of a detected object from an image.
Definition: Footprint.h:63
Pass parameters to a Statistics object.
Definition: Statistics.h:92
HeavyFootprint< ImagePixelT, MaskPixelT, VariancePixelT > makeHeavyFootprint(Footprint const &foot, lsst::afw::image::MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > const &img, HeavyFootprintCtrl const *ctrl=nullptr)
Create a HeavyFootprint with footprint defined by the given Footprint and pixel values from the given...
Statistics makeStatistics(lsst::afw::image::Image< Pixel > const &img, lsst::afw::image::Mask< image::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Handle a watered-down front-end to the constructor (no variance)
Definition: Statistics.h:359
def deblend(footprint, maskedImage, psf, psffwhm, psfChisqCut1=1.5, psfChisqCut2=1.5, psfChisqCut2b=1.5, fitPsfs=True, medianSmoothTemplate=True, medianFilterHalfsize=2, monotonicTemplate=True, weightTemplates=False, log=None, verbose=False, sigma1=None, maxNumberOfPeaks=0, assignStrayFlux=True, strayFluxToPointSources='necessary', strayFluxAssignment='r-to-peak', rampFluxAtEdge=False, patchEdges=False, tinyFootprintSize=2, getTemplateSum=False, clipStrayFluxFraction=0.001, clipFootprintToNonzero=True, removeDegenerateTemplates=False, maxTempDotProd=0.5)
Definition: baseline.py:439

◆ isLargeFootprint()

def lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.isLargeFootprint (   self,
  footprint 
)
Returns whether a Footprint is large

'Large' is defined by thresholds on the area, size and axis ratio.
These may be disabled independently by configuring them to be non-positive.

This is principally intended to get rid of satellite streaks, which the
deblender or other downstream processing can have trouble dealing with
(e.g., multiple large HeavyFootprints can chew up memory).

Definition at line 494 of file sourceDeblendTask.py.

494  def isLargeFootprint(self, footprint):
495  """Returns whether a Footprint is large
496 
497  'Large' is defined by thresholds on the area, size and axis ratio.
498  These may be disabled independently by configuring them to be non-positive.
499 
500  This is principally intended to get rid of satellite streaks, which the
501  deblender or other downstream processing can have trouble dealing with
502  (e.g., multiple large HeavyFootprints can chew up memory).
503  """
504  if self.config.maxFootprintArea > 0 and footprint.getArea() > self.config.maxFootprintArea:
505  return True
506  if self.config.maxFootprintSize > 0:
507  bbox = footprint.getBBox()
508  if max(bbox.getWidth(), bbox.getHeight()) > self.config.maxFootprintSize:
509  return True
510  if self.config.minFootprintAxisRatio > 0:
511  axes = afwEll.Axes(footprint.getShape())
512  if axes.getB() < self.config.minFootprintAxisRatio*axes.getA():
513  return True
514  return False
515 
int max

◆ isMasked()

def lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.isMasked (   self,
  footprint,
  mask 
)
Returns whether the footprint violates the mask limits

Definition at line 516 of file sourceDeblendTask.py.

516  def isMasked(self, footprint, mask):
517  """Returns whether the footprint violates the mask limits
518  """
519  size = float(footprint.getArea())
520  for maskName, limit in self.config.maskLimits.items():
521  maskVal = mask.getPlaneBitMask(maskName)
522  unmaskedSpan = footprint.spans.intersectNot(mask, maskVal) # spanset of unmasked pixels
523  if (size - unmaskedSpan.getArea())/size > limit:
524  return True
525  return False
526 

◆ postSingleDeblendHook()

def lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.postSingleDeblendHook (   self,
  exposure,
  srcs,
  i,
  npre,
  kids,
  fp,
  psf,
  psf_fwhm,
  sigma1,
  res 
)

Definition at line 491 of file sourceDeblendTask.py.

491  def postSingleDeblendHook(self, exposure, srcs, i, npre, kids, fp, psf, psf_fwhm, sigma1, res):
492  pass
493 

◆ preSingleDeblendHook()

def lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.preSingleDeblendHook (   self,
  exposure,
  srcs,
  i,
  fp,
  psf,
  psf_fwhm,
  sigma1 
)

Definition at line 488 of file sourceDeblendTask.py.

488  def preSingleDeblendHook(self, exposure, srcs, i, fp, psf, psf_fwhm, sigma1):
489  pass
490 

◆ run()

def lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.run (   self,
  exposure,
  sources 
)
Get the PSF from the provided exposure and then run deblend.

Parameters
----------
exposure : `lsst.afw.image.Exposure`
    Exposure to be processed
sources : `lsst.afw.table.SourceCatalog`
    SourceCatalog containing sources detected on this exposure.

Definition at line 264 of file sourceDeblendTask.py.

264  def run(self, exposure, sources):
265  """Get the PSF from the provided exposure and then run deblend.
266 
267  Parameters
268  ----------
269  exposure : `lsst.afw.image.Exposure`
270  Exposure to be processed
271  sources : `lsst.afw.table.SourceCatalog`
272  SourceCatalog containing sources detected on this exposure.
273  """
274  psf = exposure.getPsf()
275  assert sources.getSchema() == self.schema
276  self.deblend(exposure, sources, psf)
277 
def run(self, coaddExposures, bbox, wcs)
Definition: getTemplate.py:603

◆ skipParent()

def lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.skipParent (   self,
  source,
  mask 
)
Indicate that the parent source is not being deblended

We set the appropriate flags and mask.

Parameters
----------
source : `lsst.afw.table.SourceRecord`
    The source to flag as skipped
mask : `lsst.afw.image.Mask`
    The mask to update

Definition at line 527 of file sourceDeblendTask.py.

527  def skipParent(self, source, mask):
528  """Indicate that the parent source is not being deblended
529 
530  We set the appropriate flags and mask.
531 
532  Parameters
533  ----------
534  source : `lsst.afw.table.SourceRecord`
535  The source to flag as skipped
536  mask : `lsst.afw.image.Mask`
537  The mask to update
538  """
539  fp = source.getFootprint()
540  source.set(self.deblendSkippedKey, True)
541  if self.config.notDeblendedMask:
542  mask.addMaskPlane(self.config.notDeblendedMask)
543  fp.spans.setMask(mask, mask.getPlaneBitMask(self.config.notDeblendedMask))
544 
545  # Set the center of the parent
546  bbox = fp.getBBox()
547  centerX = int(bbox.getMinX()+bbox.getWidth()/2)
548  centerY = int(bbox.getMinY()+bbox.getHeight()/2)
549  source.set(self.peakCenter, geom.Point2I(centerX, centerY))
550  # There are no deblended children, so nChild = 0
551  source.set(self.nChildKey, 0)
552  # But we also want to know how many peaks that we would have
553  # deblended if the parent wasn't skipped.
554  source.set(self.nPeaksKey, len(fp.peaks))
555  # Top level parents are not a detected peak, so they have no peakId
556  source.set(self.peakIdKey, 0)
557  # Top level parents also have no parentNPeaks
558  source.set(self.parentNPeaksKey, 0)

Member Data Documentation

◆ ConfigClass

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.ConfigClass = SourceDeblendConfig
static

Definition at line 166 of file sourceDeblendTask.py.

◆ deblendFailedKey

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.deblendFailedKey

Definition at line 224 of file sourceDeblendTask.py.

◆ deblendPatchedTemplateKey

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.deblendPatchedTemplateKey

Definition at line 235 of file sourceDeblendTask.py.

◆ deblendRampedTemplateKey

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.deblendRampedTemplateKey

Definition at line 230 of file sourceDeblendTask.py.

◆ deblendSkippedKey

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.deblendSkippedKey

Definition at line 227 of file sourceDeblendTask.py.

◆ hasStrayFluxKey

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.hasStrayFluxKey

Definition at line 240 of file sourceDeblendTask.py.

◆ maskedKey

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.maskedKey

Definition at line 220 of file sourceDeblendTask.py.

◆ nChildKey

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.nChildKey

Definition at line 207 of file sourceDeblendTask.py.

◆ nPeaksKey

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.nPeaksKey

Definition at line 255 of file sourceDeblendTask.py.

◆ parentNPeaksKey

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.parentNPeaksKey

Definition at line 259 of file sourceDeblendTask.py.

◆ peakCenter

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.peakCenter

Definition at line 247 of file sourceDeblendTask.py.

◆ peakIdKey

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.peakIdKey

Definition at line 250 of file sourceDeblendTask.py.

◆ peakSchemaMapper

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.peakSchemaMapper

Definition at line 192 of file sourceDeblendTask.py.

◆ psfCenterKey

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.psfCenterKey

Definition at line 211 of file sourceDeblendTask.py.

◆ psfFluxKey

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.psfFluxKey

Definition at line 213 of file sourceDeblendTask.py.

◆ psfKey

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.psfKey

Definition at line 209 of file sourceDeblendTask.py.

◆ schema

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.schema

Definition at line 185 of file sourceDeblendTask.py.

◆ toCopyFromParent

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.toCopyFromParent

Definition at line 186 of file sourceDeblendTask.py.

◆ tooBigKey

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.tooBigKey

Definition at line 218 of file sourceDeblendTask.py.

◆ tooManyPeaksKey

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.tooManyPeaksKey

Definition at line 215 of file sourceDeblendTask.py.


The documentation for this class was generated from the following file: