lsst.pipe.tasks  21.0.0-95-g1e789892+a35ce0983c
Public Member Functions | Static Public Attributes | List of all members
lsst.pipe.tasks.scaleVariance.ScaleVarianceTask Class Reference
Inheritance diagram for lsst.pipe.tasks.scaleVariance.ScaleVarianceTask:

Public Member Functions

def __init__ (self, *args, **kwargs)
 
def subtractedBackground (self, maskedImage)
 
def run (self, maskedImage)
 
def computeScaleFactors (self, maskedImage)
 
def pixelBased (self, maskedImage)
 
def imageBased (self, maskedImage)
 

Static Public Attributes

 ConfigClass = ScaleVarianceConfig
 

Detailed Description

Scale the variance in a MaskedImage

The variance plane in a convolved or warped image (or a coadd derived
from warped images) does not accurately reflect the noise properties of
the image because variance has been lost to covariance. This Task
attempts to correct for this by scaling the variance plane to match
the observed variance in the image. This is not perfect (because we're
not tracking the covariance) but it's simple and is often good enough.

The task implements a pixel-based and an image-based correction estimator.

Definition at line 48 of file scaleVariance.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.pipe.tasks.scaleVariance.ScaleVarianceTask.__init__ (   self,
args,
**  kwargs 
)

Definition at line 63 of file scaleVariance.py.

Member Function Documentation

◆ computeScaleFactors()

def lsst.pipe.tasks.scaleVariance.ScaleVarianceTask.computeScaleFactors (   self,
  maskedImage 
)
Calculate and return both variance scaling factors without modifying the image.

Parameters
----------
maskedImage :  `lsst.afw.image.MaskedImage`
    Image for which to determine the variance rescaling factor.

Returns
-------
R : `lsst.pipe.base.Struct`
  - ``pixelFactor`` : `float` The pixel based variance rescaling factor
    or 1 if all pixels are masked or invalid.
  - ``imageFactor`` : `float` The image based variance rescaling factor
    or 1 if all pixels are masked or invalid.

Definition at line 135 of file scaleVariance.py.

◆ imageBased()

def lsst.pipe.tasks.scaleVariance.ScaleVarianceTask.imageBased (   self,
  maskedImage 
)
Determine the variance rescaling factor from image statistics

We calculate average(SNR) = stdev(image)/median(variance), and
the value should be unity. We use the interquartile range as a robust
estimator of the stdev. The variance rescaling factor is the
factor that brings this value to unity.

This may not work well if the pixels from which we measure the
standard deviation of the image are not effectively the same pixels
from which we measure the median of the variance. In that case, use
an alternate method.

Parameters
----------
maskedImage :  `lsst.afw.image.MaskedImage`
    Image for which to determine the variance rescaling factor.

Returns
-------
factor : `float`
    Variance rescaling factor or 1 if all pixels are masked or non-finite.

Definition at line 198 of file scaleVariance.py.

◆ pixelBased()

def lsst.pipe.tasks.scaleVariance.ScaleVarianceTask.pixelBased (   self,
  maskedImage 
)
Determine the variance rescaling factor from pixel statistics

We calculate SNR = image/sqrt(variance), and the distribution
for most of the background-subtracted image should have a standard
deviation of unity. We use the interquartile range as a robust estimator
of the SNR standard deviation. The variance rescaling factor is the
factor that brings that distribution to have unit standard deviation.

This may not work well if the image has a lot of structure in it, as
the assumptions are violated. In that case, use an alternate
method.

Parameters
----------
maskedImage : `lsst.afw.image.MaskedImage`
    Image for which to determine the variance rescaling factor.

Returns
-------
factor : `float`
    Variance rescaling factor or 1 if all pixels are masked or non-finite.

Definition at line 156 of file scaleVariance.py.

◆ run()

def lsst.pipe.tasks.scaleVariance.ScaleVarianceTask.run (   self,
  maskedImage 
)
Rescale the variance in a maskedImage in place.

Parameters
----------
maskedImage :  `lsst.afw.image.MaskedImage`
    Image for which to determine the variance rescaling factor. The image
    is modified in place.

Returns
-------
factor : `float`
    Variance rescaling factor.

Raises
------
RuntimeError
    If the estimated variance rescaling factor by both methods exceed the
    configured limit.

Notes
-----
The task calculates and applies the pixel-based correction unless
it is over the ``config.limit`` threshold. In this case, the image-based
method is applied.

Definition at line 96 of file scaleVariance.py.

◆ subtractedBackground()

def lsst.pipe.tasks.scaleVariance.ScaleVarianceTask.subtractedBackground (   self,
  maskedImage 
)
Context manager for subtracting the background

We need to subtract the background so that the entire image
(apart from objects, which should be clipped) will have the
image/sqrt(variance) distributed about zero.

This context manager subtracts the background, and ensures it
is restored on exit.

Parameters
----------
maskedImage : `lsst.afw.image.MaskedImage`
    Image+mask+variance to have background subtracted and restored.

Returns
-------
context : context manager
    Context manager that ensure the background is restored.

Definition at line 68 of file scaleVariance.py.

Member Data Documentation

◆ ConfigClass

lsst.pipe.tasks.scaleVariance.ScaleVarianceTask.ConfigClass = ScaleVarianceConfig
static

Definition at line 60 of file scaleVariance.py.


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