lsst.meas.deblender  21.0.0-3-g65f322c+86b96c0940
Classes | Functions
lsst.meas.deblender.plugins Namespace Reference

Classes

class  DeblenderPlugin
 

Functions

def clipFootprintToNonzeroImpl (foot, image)
 
def fitPsfs (debResult, log, psfChisqCut1=1.5, psfChisqCut2=1.5, psfChisqCut2b=1.5, tinyFootprintSize=2)
 
def buildSymmetricTemplates (debResult, log, patchEdges=False, setOrigTemplate=True)
 
def rampFluxAtEdge (debResult, log, patchEdges=False)
 
def medianSmoothTemplates (debResult, log, medianFilterHalfsize=2)
 
def makeTemplatesMonotonic (debResult, log)
 
def clipFootprintsToNonzero (debResult, log)
 
def weightTemplates (debResult, log)
 
def reconstructTemplates (debResult, log, maxTempDotProd=0.5)
 
def apportionFlux (debResult, log, assignStrayFlux=True, strayFluxAssignment='r-to-peak', strayFluxToPointSources='necessary', clipStrayFluxFraction=0.001, getTemplateSum=False)
 

Function Documentation

◆ apportionFlux()

def lsst.meas.deblender.plugins.apportionFlux (   debResult,
  log,
  assignStrayFlux = True,
  strayFluxAssignment = 'r-to-peak',
  strayFluxToPointSources = 'necessary',
  clipStrayFluxFraction = 0.001,
  getTemplateSum = False 
)
Apportion flux to all of the peak templates in each filter

Divide the ``maskedImage`` flux amongst all of the templates based on the fraction of
flux assigned to each ``template``.
Leftover "stray flux" is assigned to peaks based on the other parameters.

Parameters
----------
debResult: `lsst.meas.deblender.baseline.DeblenderResult`
    Container for the final deblender results.
log: `log.Log`
    LSST logger for logging purposes.
assignStrayFlux: `bool`, optional
    If True then flux in the parent footprint that is not covered by any of the
    template footprints is assigned to templates based on their 1/(1+r^2) distance.
    How the flux is apportioned is determined by ``strayFluxAssignment``.
strayFluxAssignment: `string`, optional
    Determines how stray flux is apportioned.
    * ``trim``: Trim stray flux and do not include in any footprints
    * ``r-to-peak`` (default): Stray flux is assigned based on (1/(1+r^2) from the peaks
    * ``r-to-footprint``: Stray flux is distributed to the footprints based on 1/(1+r^2) of the
      minimum distance from the stray flux to footprint
    * ``nearest-footprint``: Stray flux is assigned to the footprint with lowest L-1 (Manhattan)
      distance to the stray flux
strayFluxToPointSources: `string`, optional
    Determines how stray flux is apportioned to point sources
    * ``never``: never apportion stray flux to point sources
    * ``necessary`` (default): point sources are included only if there are no extended sources nearby
    * ``always``: point sources are always included in the 1/(1+r^2) splitting
clipStrayFluxFraction: `float`, optional
    Minimum stray-flux portion.
    Any stray-flux portion less than ``clipStrayFluxFraction`` is clipped to zero.
getTemplateSum: `bool`, optional
    As part of the flux calculation, the sum of the templates is calculated.
    If ``getTemplateSum==True`` then the sum of the templates is stored in the result
    (a `DeblendedFootprint`).

Returns
-------
modified: `bool`
    Apportion flux always modifies the templates, so ``modified`` is always ``True``.
    However, this should likely be the final step and it is unlikely that
    any deblender plugins will be re-run.

Definition at line 1216 of file plugins.py.

◆ buildSymmetricTemplates()

def lsst.meas.deblender.plugins.buildSymmetricTemplates (   debResult,
  log,
  patchEdges = False,
  setOrigTemplate = True 
)
Build a symmetric template for each peak in each filter

Given ``maskedImageF``, ``footprint``, and a ``DebldendedPeak``, creates a symmetric template
(``templateImage`` and ``templateFootprint``) around the peak for all peaks not flagged as
``skip`` or ``deblendedAsPsf``.

Parameters
----------
debResult: `lsst.meas.deblender.baseline.DeblenderResult`
    Container for the final deblender results.
log: `log.Log`
    LSST logger for logging purposes.
patchEdges: `bool`, optional
    If True and if the parent Footprint touches pixels with the ``EDGE`` bit set,
    then grow the parent Footprint to include all symmetric templates.

Returns
-------
modified: `bool`
    If any peaks are not skipped or marked as point sources, ``modified`` is ``True.
    Otherwise ``modified`` is ``False``.

Definition at line 689 of file plugins.py.

◆ clipFootprintsToNonzero()

def lsst.meas.deblender.plugins.clipFootprintsToNonzero (   debResult,
  log 
)
Clip non-zero spans in the template footprints for every peak in each filter.

Peak ``Footprint``s are clipped to the region in the image containing non-zero values
by dropping spans that are completely zero and moving endpoints to non-zero pixels
(but does not split spans that have internal zeros).

Parameters
----------
debResult: `lsst.meas.deblender.baseline.DeblenderResult`
    Container for the final deblender results.
log: `log.Log`
    LSST logger for logging purposes.

Returns
-------
modified: `bool`
    Whether or not any templates were modified.
    This will be ``True`` as long as there is at least one source that is not flagged as a PSF.

Definition at line 1013 of file plugins.py.

◆ clipFootprintToNonzeroImpl()

def lsst.meas.deblender.plugins.clipFootprintToNonzeroImpl (   foot,
  image 
)
 Clips the given *Footprint* to the region in the *Image*
 containing non-zero values.  The clipping drops spans that are
 totally zero, and moves endpoints to non-zero; it does not
 split spans that have internal zeros.

Definition at line 34 of file plugins.py.

◆ fitPsfs()

def lsst.meas.deblender.plugins.fitPsfs (   debResult,
  log,
  psfChisqCut1 = 1.5,
  psfChisqCut2 = 1.5,
  psfChisqCut2b = 1.5,
  tinyFootprintSize = 2 
)
Fit a PSF + smooth background model (linear) to a small region around each peak

This function will iterate over all filters in deblender result but does not compare
results across filters.
DeblendedPeaks that pass the cuts have their templates modified to the PSF + background model
and their ``deblendedAsPsf`` property set to ``True``.

This will likely be replaced in the future with a function that compares the psf chi-squared cuts
so that peaks flagged as point sources will be considered point sources in all bands.

Parameters
----------
debResult: `lsst.meas.deblender.baseline.DeblenderResult`
    Container for the final deblender results.
log: `log.Log`
    LSST logger for logging purposes.
psfChisqCut*: `float`, optional
    ``psfChisqCut1`` is the maximum chi-squared-per-degree-of-freedom allowed for a peak to
    be considered a PSF match without recentering.
    A fit is also made that includes terms to recenter the PSF.
    ``psfChisqCut2`` is the same as ``psfChisqCut1`` except it determines the restriction on the
    fit that includes recentering terms.
    If the peak is a match for a re-centered PSF, the PSF is repositioned at the new center and
    the peak footprint is fit again, this time to the new PSF.
    If the resulting chi-squared-per-degree-of-freedom is less than ``psfChisqCut2b`` then it
    passes the re-centering algorithm.
    If the peak passes both the re-centered and fixed position cuts, the better of the two is accepted,
    but parameters for all three psf fits are stored in the ``DebldendedPeak``.
    The default for ``psfChisqCut1``, ``psfChisqCut2``, and ``psfChisqCut2b`` is ``1.5``.
tinyFootprintSize: `float`, optional
    The PSF model is shrunk to the size that contains the original footprint.
    If the bbox of the clipped PSF model for a peak is smaller than ``max(tinyFootprintSize,2)``
    then ``tinyFootprint`` for the peak is set to ``True`` and the peak is not fit.
    The default is 2.

Returns
-------
modified: `bool`
    If any templates have been assigned to PSF point sources then ``modified`` is ``True``,
    otherwise it is ``False``.

Definition at line 154 of file plugins.py.

◆ makeTemplatesMonotonic()

def lsst.meas.deblender.plugins.makeTemplatesMonotonic (   debResult,
  log 
)
Make the templates monotonic.

The pixels in the templates are modified such that pixels further from the peak will
have values smaller than those closer to the peak.

Parameters
----------
debResult: `lsst.meas.deblender.baseline.DeblenderResult`
    Container for the final deblender results.
log: `log.Log`
    LSST logger for logging purposes.

Returns
-------
modified: `bool`
    Whether or not any templates were modified.
    This will be ``True`` as long as there is at least one source that is not flagged as a PSF.

Definition at line 978 of file plugins.py.

◆ medianSmoothTemplates()

def lsst.meas.deblender.plugins.medianSmoothTemplates (   debResult,
  log,
  medianFilterHalfsize = 2 
)
Applying median smoothing filter to the template images for every peak in every filter.

Parameters
----------
debResult: `lsst.meas.deblender.baseline.DeblenderResult`
    Container for the final deblender results.
log: `log.Log`
    LSST logger for logging purposes.
medianFilterHalfSize: `int`, optional
    Half the box size of the median filter, i.e. a ``medianFilterHalfSize`` of 50 means that
    each output pixel will be the median of  the pixels in a 101 x 101-pixel box in the input image.
    This parameter is only used when ``medianSmoothTemplate==True``, otherwise it is ignored.

Returns
-------
modified: `bool`
    Whether or not any templates were modified.
    This will be ``True`` as long as there is at least one source that is not flagged as a PSF.

Definition at line 933 of file plugins.py.

◆ rampFluxAtEdge()

def lsst.meas.deblender.plugins.rampFluxAtEdge (   debResult,
  log,
  patchEdges = False 
)
Adjust flux on the edges of the template footprints.

Using the PSF, a peak ``Footprint`` with pixels on the edge of ``footprint``
is grown by the ``psffwhm``*1.5 and filled in with ramped pixels.
The result is a new symmetric footprint template for the peaks near the edge.

Parameters
----------
debResult: `lsst.meas.deblender.baseline.DeblenderResult`
    Container for the final deblender results.
log: `log.Log`
    LSST logger for logging purposes.
patchEdges: `bool`, optional
    If True and if the parent Footprint touches pixels with the ``EDGE`` bit set,
    then grow the parent Footprint to include all symmetric templates.

Returns
-------
modified: `bool`
    If any peaks have their templates modified to include flux at the edges,
    ``modified`` is ``True``.

Definition at line 750 of file plugins.py.

◆ reconstructTemplates()

def lsst.meas.deblender.plugins.reconstructTemplates (   debResult,
  log,
  maxTempDotProd = 0.5 
)
Remove "degenerate templates"

If galaxies have substructure, such as face-on spirals, the process of identifying peaks can
"shred" the galaxy into many pieces. The templates of shredded galaxies are typically quite
similar because they represent the same galaxy, so we try to identify these "degenerate" peaks
by looking at the inner product (in pixel space) of pairs of templates.
If they are nearly parallel, we only keep one of the peaks and reject the other.
If only one of the peaks is a PSF template, the other template is used,
otherwise the one with the maximum template value is kept.

Parameters
----------
debResult: `lsst.meas.deblender.baseline.DeblenderResult`
    Container for the final deblender results.
log: `log.Log`
    LSST logger for logging purposes.
maxTempDotProd: `float`, optional
    All dot products between templates greater than ``maxTempDotProd`` will result in one
    of the templates removed.

Returns
-------
modified: `bool`
    If any degenerate templates are found, ``modified`` is ``True``.

Definition at line 1116 of file plugins.py.

◆ weightTemplates()

def lsst.meas.deblender.plugins.weightTemplates (   debResult,
  log 
)
Weight the templates to best fit the observed image in each filter

This function re-weights the templates so that their linear combination best represents
the observed image in that filter.
In the future it may be useful to simultaneously weight all of the filters together.

Parameters
----------
debResult: `lsst.meas.deblender.baseline.DeblenderResult`
    Container for the final deblender results.
log: `log.Log`
    LSST logger for logging purposes.

Returns
-------
modified: `bool`
    ``weightTemplates`` does not actually modify the ``Footprint`` templates other than
    to add a weight to them, so ``modified`` is always ``False``.

Definition at line 1047 of file plugins.py.