lsst.pipe.tasks g8b9e2231ea+fa07cb600e
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Attributes | List of all members
lsst.pipe.tasks.matchBackgrounds.MatchBackgroundsTask Class Reference
Inheritance diagram for lsst.pipe.tasks.matchBackgrounds.MatchBackgroundsTask:

Public Member Functions

def __init__ (self, *args, **kwargs)
 
def run (self, expRefList, expDatasetType, imageScalerList=None, refExpDataRef=None, refImageScaler=None)
 
def selectRefExposure (self, expRefList, imageScalerList, expDatasetType)
 
def matchBackgrounds (self, refExposure, sciExposure)
 

Public Attributes

 sctrl
 
 debugDataIdString
 

Static Public Attributes

MatchBackgroundsConfig ConfigClass = MatchBackgroundsConfig
 

Protected Member Functions

def _debugPlot (self, X, Y, Z, dZ, modelImage, bbox, model, resids)
 
def _gridImage (self, maskedImage, binsize, statsFlag)
 

Static Protected Attributes

str _DefaultName = "matchBackgrounds"
 

Detailed Description

Definition at line 139 of file matchBackgrounds.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.pipe.tasks.matchBackgrounds.MatchBackgroundsTask.__init__ (   self,
args,
**  kwargs 
)

Definition at line 143 of file matchBackgrounds.py.

Member Function Documentation

◆ _debugPlot()

def lsst.pipe.tasks.matchBackgrounds.MatchBackgroundsTask._debugPlot (   self,
  X,
  Y,
  Z,
  dZ,
  modelImage,
  bbox,
  model,
  resids 
)
protected
Generate a plot showing the background fit and residuals.

It is called when lsstDebug.Info(__name__).savefig = True
Saves the fig to lsstDebug.Info(__name__).figpath
Displays on screen if lsstDebug.Info(__name__).display = True

@param X: array of x positions
@param Y: array of y positions
@param Z: array of the grid values that were interpolated
@param dZ: array of the error on the grid values
@param modelImage: image ofthe model of the fit
@param model: array of len(Z) containing the grid values predicted by the model
@param resids: Z - model

Definition at line 485 of file matchBackgrounds.py.

◆ _gridImage()

def lsst.pipe.tasks.matchBackgrounds.MatchBackgroundsTask._gridImage (   self,
  maskedImage,
  binsize,
  statsFlag 
)
protected
Private method to grid an image for debugging

Definition at line 539 of file matchBackgrounds.py.

◆ matchBackgrounds()

def lsst.pipe.tasks.matchBackgrounds.MatchBackgroundsTask.matchBackgrounds (   self,
  refExposure,
  sciExposure 
)
Match science exposure's background level to that of reference exposure.

Process creates a difference image of the reference exposure minus the science exposure, and then
generates an afw.math.Background object. It assumes (but does not require/check) that the mask plane
already has detections set. If detections have not been set/masked, sources will bias the
background estimation.
The 'background' of the difference image is smoothed by spline interpolation (by the Background class)
or by polynomial interpolation by the Approximate class. This model of difference image
is added to the science exposure in memory.
Fit diagnostics are also calculated and returned.

@param[in] refExposure: reference exposure
@param[in,out] sciExposure: science exposure; modified by changing the background level
    to match that of the reference exposure
@returns a pipBase.Struct with fields:
    - backgroundModel: an afw.math.Approximate or an afw.math.Background.
    - fitRMS: rms of the fit. This is the sqrt(mean(residuals**2)).
    - matchedMSE: the MSE of the reference and matched images: mean((refImage - matchedSciImage)**2);
      should be comparable to difference image's mean variance.
    - diffImVar: the mean variance of the difference image.

Definition at line 332 of file matchBackgrounds.py.

◆ run()

def lsst.pipe.tasks.matchBackgrounds.MatchBackgroundsTask.run (   self,
  expRefList,
  expDatasetType,
  imageScalerList = None,
  refExpDataRef = None,
  refImageScaler = None 
)
Match the backgrounds of a list of coadd temp exposures to a reference coadd temp exposure.

Choose a refExpDataRef automatically if none supplied.

@param[in] expRefList: list of data references to science exposures to be background-matched;
    all exposures must exist.
@param[in] expDatasetType: dataset type of exposures, e.g. 'goodSeeingCoadd_tempExp'
@param[in] imageScalerList: list of image scalers (coaddUtils.ImageScaler);
    if None then the images are not scaled
@param[in] refExpDataRef: data reference for the reference exposure.
    If None, then this task selects the best exposures from expRefList.
    if not None then must be one of the exposures in expRefList.
@param[in] refImageScaler: image scaler for reference image;
    ignored if refExpDataRef is None, else scaling is not performed if None

@return: a pipBase.Struct containing these fields:
- backgroundInfoList: a list of pipeBase.Struct, one per exposure in expRefList,
    each of which contains these fields:
    - isReference: this is the reference exposure (only one returned Struct will
        contain True for this value, unless the ref exposure is listed multiple times)
    - backgroundModel: differential background model (afw.Math.Background or afw.Math.Approximate).
        Add this to the science exposure to match the reference exposure.
    - fitRMS: rms of the fit. This is the sqrt(mean(residuals**2)).
    - matchedMSE: the MSE of the reference and matched images: mean((refImage - matchedSciImage)**2);
      should be comparable to difference image's mean variance.
    - diffImVar: the mean variance of the difference image.
    All fields except isReference will be None if isReference True or the fit failed.

@warning: all exposures must exist on disk

Definition at line 151 of file matchBackgrounds.py.

◆ selectRefExposure()

def lsst.pipe.tasks.matchBackgrounds.MatchBackgroundsTask.selectRefExposure (   self,
  expRefList,
  imageScalerList,
  expDatasetType 
)
Find best exposure to use as the reference exposure

Calculate an appropriate reference exposure by minimizing a cost function that penalizes
high variance,  high background level, and low coverage. Use the following config parameters:
- bestRefWeightCoverage
- bestRefWeightVariance
- bestRefWeightLevel

@param[in] expRefList: list of data references to exposures.
    Retrieves dataset type specified by expDatasetType.
    If an exposure is not found, it is skipped with a warning.
@param[in] imageScalerList: list of image scalers (coaddUtils.ImageScaler);
    must be the same length as expRefList
@param[in] expDatasetType: dataset type of exposure: e.g. 'goodSeeingCoadd_tempExp'

@return: index of best exposure

@raise pipeBase.TaskError if none of the exposures in expRefList are found.

Definition at line 268 of file matchBackgrounds.py.

Member Data Documentation

◆ _DefaultName

str lsst.pipe.tasks.matchBackgrounds.MatchBackgroundsTask._DefaultName = "matchBackgrounds"
staticprotected

Definition at line 141 of file matchBackgrounds.py.

◆ ConfigClass

MatchBackgroundsConfig lsst.pipe.tasks.matchBackgrounds.MatchBackgroundsTask.ConfigClass = MatchBackgroundsConfig
static

Definition at line 140 of file matchBackgrounds.py.

◆ debugDataIdString

lsst.pipe.tasks.matchBackgrounds.MatchBackgroundsTask.debugDataIdString

Definition at line 246 of file matchBackgrounds.py.

◆ sctrl

lsst.pipe.tasks.matchBackgrounds.MatchBackgroundsTask.sctrl

Definition at line 146 of file matchBackgrounds.py.


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