lsst.ip.diffim  14.0-10-g81837af+10
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:
lsst.ip.diffim.imagePsfMatch.ImagePsfMatchTask lsst.ip.diffim.modelPsfMatch.ModelPsfMatchTask lsst.ip.diffim.snapPsfMatch.SnapPsfMatchTask lsst.ip.diffim.zogy.ZogyImagePsfMatchTask

Public Member Functions

def __init__ (self, args, kwargs)
 Create the psf-matching Task. More...
 

Public Attributes

 kConfig
 
 useRegularization
 
 hMat
 

Static Public Attributes

 ConfigClass = PsfMatchConfig
 

Private Member Functions

def _diagnostic (self, kernelCellSet, spatialSolution, spatialKernel, spatialBg)
 Provide logging diagnostics on quality of spatial kernel fit. More...
 
def _displayDebug (self, kernelCellSet, spatialKernel, spatialBackground)
 Provide visualization of the inputs and ouputs to the Psf-matching code. More...
 
def _createPcaBasis (self, kernelCellSet, nStarPerCell, policy)
 Create Principal Component basis. More...
 
def _buildCellSet (self, args)
 Fill a SpatialCellSet with KernelCandidates for the Psf-matching process; override in derived classes. More...
 
def _solve (self, kernelCellSet, basisList, returnOnExcept=False)
 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:

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

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

import lsst.log.utils as logUtils
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

◆ __init__()

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

◆ _buildCellSet()

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.

◆ _createPcaBasis()

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
kernelCellSeta SpatialCellSet containing KernelCandidates, from which components are derived
nStarPerCellthe number of stars per cell to visit when doing the PCA
policyinput 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.

◆ _diagnostic()

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

Provide logging diagnostics on quality of spatial kernel fit.

Parameters
kernelCellSetCellset that contains the KernelCandidates used in the fitting
spatialSolutionKernelSolution of best-fit
spatialKernelBest-fit spatial Kernel model
spatialBgBest-fit spatial background model

Definition at line 703 of file psfMatch.py.

◆ _displayDebug()

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
kernelCellSetthe SpatialCellSet used in determining the matching kernel and background
spatialKernelspatially varying Psf-matching kernel
spatialBackgroundspatially varying background-matching function

Definition at line 788 of file psfMatch.py.

◆ _solve()

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

Solve for the PSF matching kernel.

Parameters
kernelCellSeta SpatialCellSet to use in determining the matching kernel (typically as provided by _buildCellSet)
basisListlist of Kernels to be used in the decomposition of the spatially varying kernel (typically as provided by makeKernelBasisList)
returnOnExceptif 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

◆ _DefaultName

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

Definition at line 677 of file psfMatch.py.

◆ ConfigClass

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

Definition at line 676 of file psfMatch.py.

◆ hMat

lsst.ip.diffim.psfMatch.PsfMatchTask.hMat

Definition at line 701 of file psfMatch.py.

◆ kConfig

lsst.ip.diffim.psfMatch.PsfMatchTask.kConfig

Definition at line 692 of file psfMatch.py.

◆ useRegularization

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: