LSST Applications  21.0.0-147-g0e635eb1+1acddb5be5,22.0.0+052faf71bd,22.0.0+1ea9a8b2b2,22.0.0+6312710a6c,22.0.0+729191ecac,22.0.0+7589c3a021,22.0.0+9f079a9461,22.0.1-1-g7d6de66+b8044ec9de,22.0.1-1-g87000a6+536b1ee016,22.0.1-1-g8e32f31+6312710a6c,22.0.1-10-gd060f87+016f7cdc03,22.0.1-12-g9c3108e+df145f6f68,22.0.1-16-g314fa6d+c825727ab8,22.0.1-19-g93a5c75+d23f2fb6d8,22.0.1-19-gb93eaa13+aab3ef7709,22.0.1-2-g8ef0a89+b8044ec9de,22.0.1-2-g92698f7+9f079a9461,22.0.1-2-ga9b0f51+052faf71bd,22.0.1-2-gac51dbf+052faf71bd,22.0.1-2-gb66926d+6312710a6c,22.0.1-2-gcb770ba+09e3807989,22.0.1-20-g32debb5+b8044ec9de,22.0.1-23-gc2439a9a+fb0756638e,22.0.1-3-g496fd5d+09117f784f,22.0.1-3-g59f966b+1e6ba2c031,22.0.1-3-g849a1b8+f8b568069f,22.0.1-3-gaaec9c0+c5c846a8b1,22.0.1-32-g5ddfab5d3+60ce4897b0,22.0.1-4-g037fbe1+64e601228d,22.0.1-4-g8623105+b8044ec9de,22.0.1-5-g096abc9+d18c45d440,22.0.1-5-g15c806e+57f5c03693,22.0.1-7-gba73697+57f5c03693,master-g6e05de7fdc+c1283a92b8,master-g72cdda8301+729191ecac,w.2021.39
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 163 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 171 of file sourceDeblendTask.py.

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

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

◆ 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 286 of file sourceDeblendTask.py.

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

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

◆ isMasked()

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

Definition at line 518 of file sourceDeblendTask.py.

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

◆ postSingleDeblendHook()

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

Definition at line 493 of file sourceDeblendTask.py.

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

◆ preSingleDeblendHook()

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

Definition at line 490 of file sourceDeblendTask.py.

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

◆ 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 266 of file sourceDeblendTask.py.

266  def run(self, exposure, sources):
267  """Get the PSF from the provided exposure and then run deblend.
268 
269  Parameters
270  ----------
271  exposure : `lsst.afw.image.Exposure`
272  Exposure to be processed
273  sources : `lsst.afw.table.SourceCatalog`
274  SourceCatalog containing sources detected on this exposure.
275  """
276  psf = exposure.getPsf()
277  assert sources.getSchema() == self.schema
278  self.deblend(exposure, sources, psf)
279 
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 529 of file sourceDeblendTask.py.

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

Member Data Documentation

◆ ConfigClass

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

Definition at line 168 of file sourceDeblendTask.py.

◆ deblendFailedKey

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.deblendFailedKey

Definition at line 226 of file sourceDeblendTask.py.

◆ deblendPatchedTemplateKey

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.deblendPatchedTemplateKey

Definition at line 237 of file sourceDeblendTask.py.

◆ deblendRampedTemplateKey

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.deblendRampedTemplateKey

Definition at line 232 of file sourceDeblendTask.py.

◆ deblendSkippedKey

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.deblendSkippedKey

Definition at line 229 of file sourceDeblendTask.py.

◆ hasStrayFluxKey

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.hasStrayFluxKey

Definition at line 242 of file sourceDeblendTask.py.

◆ maskedKey

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.maskedKey

Definition at line 222 of file sourceDeblendTask.py.

◆ nChildKey

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.nChildKey

Definition at line 209 of file sourceDeblendTask.py.

◆ nPeaksKey

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.nPeaksKey

Definition at line 257 of file sourceDeblendTask.py.

◆ parentNPeaksKey

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.parentNPeaksKey

Definition at line 261 of file sourceDeblendTask.py.

◆ peakCenter

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.peakCenter

Definition at line 249 of file sourceDeblendTask.py.

◆ peakIdKey

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.peakIdKey

Definition at line 252 of file sourceDeblendTask.py.

◆ peakSchemaMapper

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.peakSchemaMapper

Definition at line 194 of file sourceDeblendTask.py.

◆ psfCenterKey

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.psfCenterKey

Definition at line 213 of file sourceDeblendTask.py.

◆ psfFluxKey

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.psfFluxKey

Definition at line 215 of file sourceDeblendTask.py.

◆ psfKey

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.psfKey

Definition at line 211 of file sourceDeblendTask.py.

◆ schema

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.schema

Definition at line 187 of file sourceDeblendTask.py.

◆ toCopyFromParent

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.toCopyFromParent

Definition at line 188 of file sourceDeblendTask.py.

◆ tooBigKey

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.tooBigKey

Definition at line 220 of file sourceDeblendTask.py.

◆ tooManyPeaksKey

lsst.meas.deblender.sourceDeblendTask.SourceDeblendTask.tooManyPeaksKey

Definition at line 217 of file sourceDeblendTask.py.


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