lsst.ip.diffim  13.0-22-g3839dbb+16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Static Private Attributes | List of all members
lsst.ip.diffim.psfMatch.PsfMatchTask Class Reference

Base class for Psf Matching; should not be called directly. More...

Inheritance diagram for lsst.ip.diffim.psfMatch.PsfMatchTask:

Public Member Functions

def __init__
 Create the psf-matching Task. More...
 

Public Attributes

 kConfig
 
 useRegularization
 
 hMat
 

Static Public Attributes

 ConfigClass = PsfMatchConfig
 

Private Member Functions

def _diagnostic
 Provide logging diagnostics on quality of spatial kernel fit. More...
 
def _displayDebug
 Provide visualization of the inputs and ouputs to the Psf-matching code. More...
 
def _createPcaBasis
 Create Principal Component basis. More...
 
def _buildCellSet
 Fill a SpatialCellSet with KernelCandidates for the Psf-matching process; override in derived classes. More...
 
def _solve
 Solve for the PSF matching kernel. More...
 

Static Private Attributes

string _DefaultName = "psfMatch"
 

Detailed Description

Base class for Psf Matching; should not be called directly.

Contents

#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Description

PsfMatchTask is a base class that implements the core functionality for matching the Psfs of two images using a spatially varying Psf-matching lsst.afw.math.LinearCombinationKernel. The Task requires the user to provide an instance of an lsst.afw.math.SpatialCellSet, filled with lsst.ip.diffim.KernelCandidate instances, and a list of lsst.afw.math.Kernels of basis shapes that will be used for the decomposition. If requested, the Task also performs background matching and returns the differential background model as an lsst.afw.math.Kernel.SpatialFunction.

#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Task initialization

Create the psf-matching Task.

Parameters
*argsarguments to be passed to lsst.pipe.base.task.Task.__init__
**kwargskeyword arguments to be passed to lsst.pipe.base.task.Task.__init__

The initialization sets the Psf-matching kernel configuration using the value of self.config.kernel.active. If the kernel is requested with regularization to moderate the bias/variance tradeoff, currently only used when a delta function kernel basis is provided, it creates a regularization matrix stored as member variable self.hMat.

#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Invoking the Task

As a base class, this Task is not directly invoked. However, run() methods that are implemented on derived classes will make use of the core _solve() functionality, which defines a sequence of lsst.afw.math.CandidateVisitor classes that iterate through the KernelCandidates, first building up a per-candidate solution and then building up a spatial model from the ensemble of candidates. Sigma clipping is performed using the mean and standard deviation of all kernel sums (to reject variable objects), on the per-candidate substamp diffim residuals (to indicate a bad choice of kernel basis shapes for that particular object), and on the substamp diffim residuals using the spatial kernel fit (to indicate a bad choice of spatial kernel order, or poor constraints on the spatial model). The _diagnostic() method logs information on the quality of the spatial fit, and also modifies the Task metadata.

#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Configuration parameters

See PsfMatchConfig, PsfMatchConfigAL, PsfMatchConfigDF, and DetectionConfig.

#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Quantities set in Metadata

spatialConditionNum
Condition number of the spatial kernel fit; via PsfMatchTask._diagnostic
spatialKernelSum

Kernel sum (10^{-0.4 * Δ zeropoint}) of the spatial Psf-matching kernel; via PsfMatchTask._diagnostic

ALBasisNGauss
If using sum-of-Gaussian basis, the number of gaussians used; via generateAlardLuptonBasisList
ALBasisDegGauss
If using sum-of-Gaussian basis, the degree of spatial variation of the Gaussians; via generateAlardLuptonBasisList
ALBasisSigGauss
If using sum-of-Gaussian basis, the widths (sigma) of the Gaussians; via generateAlardLuptonBasisList
ALKernelSize

If using sum-of-Gaussian basis, the kernel size; via generateAlardLuptonBasisList

NFalsePositivesTotal
Total number of diaSources; via KernelCandidateQa.aggregate
NFalsePositivesRefAssociated
Number of diaSources that associate with the reference catalog; via KernelCandidateQa.aggregate
NFalsePositivesRefAssociated
Number of diaSources that associate with the source catalog; via KernelCandidateQa.aggregate
NFalsePositivesUnassociated
Number of diaSources that are orphans; via KernelCandidateQa.aggregate
metric_MEAN
Mean value of substamp diffim quality metrics across all KernelCandidates, for both the per-candidate (LOCAL) and SPATIAL residuals; via KernelCandidateQa.aggregate
metric_MEDIAN
Median value of substamp diffim quality metrics across all KernelCandidates, for both the per-candidate (LOCAL) and SPATIAL residuals; via KernelCandidateQa.aggregate
metric_STDEV
Standard deviation of substamp diffim quality metrics across all KernelCandidates, for both the per-candidate (LOCAL) and SPATIAL residuals; via KernelCandidateQa.aggregate

#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Debug variables

The command line task interface supports a flag -d/–debug to import debug.py from your PYTHONPATH. The relevant contents of debug.py for this Task include:

1 import sys
2 import lsstDebug
3 def DebugInfo(name):
4  di = lsstDebug.getInfo(name)
5  if name == "lsst.ip.diffim.psfMatch":
6  di.display = True # enable debug output
7  di.maskTransparency = 80 # ds9 mask transparency
8  di.displayCandidates = True # show all the candidates and residuals
9  di.displayKernelBasis = False # show kernel basis functions
10  di.displayKernelMosaic = True # show kernel realized across the image
11  di.plotKernelSpatialModel = False # show coefficients of spatial model
12  di.showBadCandidates = True # show the bad candidates (red) along with good (green)
13  return di
14 lsstDebug.Info = DebugInfo
15 lsstDebug.frame = 1

Note that if you want addional logging info, you may add to your scripts:

1 import lsst.log.utils as logUtils
2 logUtils.traceSetAt("ip.diffim", 4)

#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Example code

As a base class, there is no example code for PsfMatchTask. However, see ImagePsfMatchTask, SnapPsfMatchTask, and ModelPsfMatchTask.

#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Definition at line 528 of file psfMatch.py.

Constructor & Destructor Documentation

def lsst.ip.diffim.psfMatch.PsfMatchTask.__init__ (   self,
  args,
  kwargs 
)

Create the psf-matching Task.

Parameters
*argsarguments to be passed to lsst.pipe.base.task.Task.__init__
**kwargskeyword arguments to be passed to lsst.pipe.base.task.Task.__init__

The initialization sets the Psf-matching kernel configuration using the value of self.config.kernel.active. If the kernel is requested with regularization to moderate the bias/variance tradeoff, currently only used when a delta function kernel basis is provided, it creates a regularization matrix stored as member variable self.hMat.

Definition at line 679 of file psfMatch.py.

Member Function Documentation

def lsst.ip.diffim.psfMatch.PsfMatchTask._buildCellSet (   self,
  args 
)
private

Fill a SpatialCellSet with KernelCandidates for the Psf-matching process; override in derived classes.

Definition at line 888 of file psfMatch.py.

def lsst.ip.diffim.psfMatch.PsfMatchTask._createPcaBasis (   self,
  kernelCellSet,
  nStarPerCell,
  policy 
)
private

Create Principal Component basis.

If a principal component analysis is requested, typically when using a delta function basis, perform the PCA here and return a new basis list containing the new principal components.

Parameters
kernelCellSet,:a SpatialCellSet containing KernelCandidates, from which components are derived
nStarPerCell,:the number of stars per cell to visit when doing the PCA
policy,:input policy controlling the single kernel visitor
Returns
  • nRejectedPca: number of KernelCandidates rejected during PCA loop
  • spatialBasisList: basis list containing the principal shapes as Kernels

Definition at line 834 of file psfMatch.py.

def lsst.ip.diffim.psfMatch.PsfMatchTask._diagnostic (   self,
  kernelCellSet,
  spatialSolution,
  spatialKernel,
  spatialBg 
)
private

Provide logging diagnostics on quality of spatial kernel fit.

Parameters
kernelCellSet,:Cellset that contains the KernelCandidates used in the fitting
spatialSolution,:KernelSolution of best-fit
spatialKernel,:Best-fit spatial Kernel model
spatialBg,:Best-fit spatial background model

Definition at line 703 of file psfMatch.py.

def lsst.ip.diffim.psfMatch.PsfMatchTask._displayDebug (   self,
  kernelCellSet,
  spatialKernel,
  spatialBackground 
)
private

Provide visualization of the inputs and ouputs to the Psf-matching code.

Parameters
kernelCellSet,:the SpatialCellSet used in determining the matching kernel and background
spatialKernel,:spatially varying Psf-matching kernel
spatialBackground,:spatially varying background-matching function

Definition at line 788 of file psfMatch.py.

def lsst.ip.diffim.psfMatch.PsfMatchTask._solve (   self,
  kernelCellSet,
  basisList,
  returnOnExcept = False 
)
private

Solve for the PSF matching kernel.

Parameters
kernelCellSet,:a SpatialCellSet to use in determining the matching kernel (typically as provided by _buildCellSet)
basisList,:list of Kernels to be used in the decomposition of the spatially varying kernel (typically as provided by makeKernelBasisList)
returnOnExcept,:if True then return (None, None) if an error occurs, else raise the exception
Returns
  • psfMatchingKernel: PSF matching kernel
  • backgroundModel: differential background model

Raise Exception if unable to determine PSF matching kernel and returnOnExcept False

Definition at line 894 of file psfMatch.py.

Member Data Documentation

string lsst.ip.diffim.psfMatch.PsfMatchTask._DefaultName = "psfMatch"
staticprivate

Definition at line 677 of file psfMatch.py.

lsst.ip.diffim.psfMatch.PsfMatchTask.ConfigClass = PsfMatchConfig
static

Definition at line 676 of file psfMatch.py.

lsst.ip.diffim.psfMatch.PsfMatchTask.hMat

Definition at line 701 of file psfMatch.py.

lsst.ip.diffim.psfMatch.PsfMatchTask.kConfig

Definition at line 692 of file psfMatch.py.

lsst.ip.diffim.psfMatch.PsfMatchTask.useRegularization

Definition at line 696 of file psfMatch.py.


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