lsst.ip.diffim  13.0-28-gf4bc96c+3
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
lsst::ip::diffim::KernelCandidate< _PixelT > Class Template Reference

Class stored in SpatialCells for spatial Kernel fitting. More...

#include <KernelCandidate.h>

Inheritance diagram for lsst::ip::diffim::KernelCandidate< _PixelT >:

Public Types

enum  CandidateSwitch { ORIG = 0, PCA = 1, RECENT = 2 }
 
typedef afw::image::Image< afw::math::Kernel::Pixel > ImageT
 
typedef _PixelT PixelT
 
typedef std::shared_ptr< KernelCandidatePtr
 
typedef std::shared_ptr< afw::image::MaskedImage< PixelT > > MaskedImagePtr
 
typedef std::shared_ptr< afw::image::Image< afw::image::VariancePixel > > VariancePtr
 
typedef std::shared_ptr< afw::table::SourceRecord > SourcePtr
 

Public Member Functions

 KernelCandidate (float const xCenter, float const yCenter, MaskedImagePtr const &templateMaskedImage, MaskedImagePtr const &scienceMaskedImage, pex::policy::Policy const &policy)
 Constructor. More...
 
 KernelCandidate (SourcePtr const &source, MaskedImagePtr const &templateMaskedImage, MaskedImagePtr const &scienceMaskedImage, pex::policy::Policy const &policy)
 Constructor. More...
 
virtual ~KernelCandidate ()
 Destructor. More...
 
double getCandidateRating () const
 Return Candidate rating. More...
 
SourcePtr getSource () const
 Return the original source. More...
 
MaskedImagePtr getTemplateMaskedImage ()
 Return pointers to the image pixels used in kernel determination. More...
 
MaskedImagePtr getScienceMaskedImage ()
 
std::shared_ptr< afw::math::Kernel > getKernel (CandidateSwitch cand) const
 Return results of kernel solution. More...
 
double getBackground (CandidateSwitch cand) const
 
double getKsum (CandidateSwitch cand) const
 
boost::shared_ptr< ImageTgetKernelImage (CandidateSwitch cand) const
 
boost::shared_ptr< ImageT const > getImage () const
 
std::shared_ptr< StaticKernelSolution< PixelT > > getKernelSolution (CandidateSwitch cand) const
 
afw::image::MaskedImage< PixelTgetDifferenceImage (CandidateSwitch cand)
 Calculate associated difference image using internal solutions. More...
 
afw::image::MaskedImage< PixelTgetDifferenceImage (std::shared_ptr< afw::math::Kernel > kernel, double background)
 Calculate associated difference image using input kernel and background. More...
 
bool isInitialized () const
 
void build (afw::math::KernelList const &basisList)
 Core functionality of KernelCandidate, to build and fill a KernelSolution. More...
 
void build (afw::math::KernelList const &basisList, Eigen::MatrixXd const &hMat)
 

Private Member Functions

void _buildKernelSolution (afw::math::KernelList const &basisList, Eigen::MatrixXd const &hMat)
 

Private Attributes

MaskedImagePtr _templateMaskedImage
 Subimage around which you build kernel. More...
 
MaskedImagePtr _scienceMaskedImage
 Subimage around which you build kernel. More...
 
VariancePtr _varianceEstimate
 Estimate of the local variance. More...
 
pex::policy::Policy _policy
 Policy. More...
 
SourcePtr _source
 
double _coreFlux
 Mean S/N in the science image. More...
 
bool _isInitialized
 Has the kernel been built. More...
 
bool _useRegularization
 Use regularization? More...
 
bool _fitForBackground
 
std::shared_ptr< StaticKernelSolution< PixelT > > _kernelSolutionOrig
 Original basis solution. More...
 
std::shared_ptr< StaticKernelSolution< PixelT > > _kernelSolutionPca
 Most recent solution. More...
 

Detailed Description

template<typename _PixelT>
class lsst::ip::diffim::KernelCandidate< _PixelT >

Class stored in SpatialCells for spatial Kernel fitting.

Note
KernelCandidate is a single Kernel derived around a source. We'll assign them to sets of SpatialCells; these sets will then be used to fit a spatial model to the Kernel.

Definition at line 38 of file KernelCandidate.h.

Member Typedef Documentation

◆ ImageT

template<typename _PixelT>
typedef afw::image::Image<afw::math::Kernel::Pixel> lsst::ip::diffim::KernelCandidate< _PixelT >::ImageT

Definition at line 40 of file KernelCandidate.h.

◆ MaskedImagePtr

template<typename _PixelT>
typedef std::shared_ptr<afw::image::MaskedImage<PixelT> > lsst::ip::diffim::KernelCandidate< _PixelT >::MaskedImagePtr

Definition at line 44 of file KernelCandidate.h.

◆ PixelT

template<typename _PixelT>
typedef _PixelT lsst::ip::diffim::KernelCandidate< _PixelT >::PixelT

Definition at line 41 of file KernelCandidate.h.

◆ Ptr

template<typename _PixelT>
typedef std::shared_ptr<KernelCandidate> lsst::ip::diffim::KernelCandidate< _PixelT >::Ptr

Definition at line 43 of file KernelCandidate.h.

◆ SourcePtr

template<typename _PixelT>
typedef std::shared_ptr<afw::table::SourceRecord> lsst::ip::diffim::KernelCandidate< _PixelT >::SourcePtr

Definition at line 46 of file KernelCandidate.h.

◆ VariancePtr

template<typename _PixelT>
typedef std::shared_ptr<afw::image::Image<afw::image::VariancePixel> > lsst::ip::diffim::KernelCandidate< _PixelT >::VariancePtr

Definition at line 45 of file KernelCandidate.h.

Member Enumeration Documentation

◆ CandidateSwitch

template<typename _PixelT>
enum lsst::ip::diffim::KernelCandidate::CandidateSwitch
Enumerator
ORIG 
PCA 
RECENT 

Definition at line 48 of file KernelCandidate.h.

Constructor & Destructor Documentation

◆ KernelCandidate() [1/2]

template<typename _PixelT>
lsst::ip::diffim::KernelCandidate< _PixelT >::KernelCandidate ( float const  xCenter,
float const  yCenter,
MaskedImagePtr const &  templateMaskedImage,
MaskedImagePtr const &  scienceMaskedImage,
pex::policy::Policy const &  policy 
)

Constructor.

Parameters
xCenterCol position of object
yCenterRow position of object
templateMaskedImagePointer to template image
scienceMaskedImagePointer to science image
policyPolicy file

◆ KernelCandidate() [2/2]

template<typename _PixelT>
lsst::ip::diffim::KernelCandidate< _PixelT >::KernelCandidate ( SourcePtr const &  source,
MaskedImagePtr const &  templateMaskedImage,
MaskedImagePtr const &  scienceMaskedImage,
pex::policy::Policy const &  policy 
)

Constructor.

Parameters
sourcePointer to a source to use in constructing the candidate
templateMaskedImagePointer to template image
scienceMaskedImagePointer to science image
policyPolicy file

◆ ~KernelCandidate()

template<typename _PixelT>
virtual lsst::ip::diffim::KernelCandidate< _PixelT >::~KernelCandidate ( )
inlinevirtual

Destructor.

Definition at line 83 of file KernelCandidate.h.

Member Function Documentation

◆ _buildKernelSolution()

template<typename _PixelT>
void lsst::ip::diffim::KernelCandidate< PixelT >::_buildKernelSolution ( afw::math::KernelList const &  basisList,
Eigen::MatrixXd const &  hMat 
)
private

Definition at line 154 of file KernelCandidate.cc.

◆ build() [1/2]

template<typename _PixelT>
void lsst::ip::diffim::KernelCandidate< _PixelT >::build ( afw::math::KernelList const &  basisList)

Core functionality of KernelCandidate, to build and fill a KernelSolution.

Note
This is an expensive step involving matrix math, and one that may be called multiple times per candidate. Use cases are:

o _isInitialized = false. This is a constructed but not initialized KernelCandidate. When build() is called, M and B are derived from the MaskedImages and the basisList. KernelCandidate owns the knowledge of how to fill this KernelSolution; the solution knows how to solve itself and how to turn that into an output kernel. This solution ends up being _kernelSolution0.

o _isInitialized = true. This is for when build() is re-called using a different basis list, e.g. one based on Pca. We need to use M and B for the spatial modeling, but do not want to override the original KernelSolution. This solution ends up as _kernelSolutionCurrent. Build KernelSolution matrices for M x = B with regularization matrix H

Note
Modified equation is (Mt.M + lambda H) x = Mt.B with lambda a degree of freedom describing the "strength" of the regularization. The larger the value of lambda, the smoother the kernel, but the larger the residuals in the difference image.
A value of lambda = Trace(Mt.M) / Tr(H) will yield essentially equivalent power in the kernel smoothness and in the diffim quality. We scale this estimate by lambdaScaling to give more/less consideration to the smoothness of the kernel.

◆ build() [2/2]

template<typename _PixelT>
void lsst::ip::diffim::KernelCandidate< _PixelT >::build ( afw::math::KernelList const &  basisList,
Eigen::MatrixXd const &  hMat 
)

◆ getBackground()

template<typename PixelT >
double lsst::ip::diffim::KernelCandidate< PixelT >::getBackground ( CandidateSwitch  cand) const

Definition at line 285 of file KernelCandidate.cc.

◆ getCandidateRating()

template<typename _PixelT>
double lsst::ip::diffim::KernelCandidate< _PixelT >::getCandidateRating ( ) const
inline

Return Candidate rating.

Note
Required method for use by SpatialCell; e.g. total flux

Definition at line 90 of file KernelCandidate.h.

◆ getDifferenceImage() [1/2]

template<typename PixelT >
lsst::afw::image::MaskedImage< PixelT > lsst::ip::diffim::KernelCandidate< PixelT >::getDifferenceImage ( CandidateSwitch  cand)

Calculate associated difference image using internal solutions.

Definition at line 400 of file KernelCandidate.cc.

◆ getDifferenceImage() [2/2]

template<typename _PixelT>
afw::image::MaskedImage<PixelT> lsst::ip::diffim::KernelCandidate< _PixelT >::getDifferenceImage ( std::shared_ptr< afw::math::Kernel >  kernel,
double  background 
)

Calculate associated difference image using input kernel and background.

Note
Useful for spatial modeling

◆ getImage()

template<typename PixelT >
std::shared_ptr< typename KernelCandidate< PixelT >::ImageT const > lsst::ip::diffim::KernelCandidate< PixelT >::getImage ( ) const

Definition at line 367 of file KernelCandidate.cc.

◆ getKernel()

template<typename PixelT >
std::shared_ptr< lsst::afw::math::Kernel > lsst::ip::diffim::KernelCandidate< PixelT >::getKernel ( CandidateSwitch  cand) const

Return results of kernel solution.

Definition at line 258 of file KernelCandidate.cc.

◆ getKernelImage()

template<typename PixelT >
std::shared_ptr< typename KernelCandidate< PixelT >::ImageT > lsst::ip::diffim::KernelCandidate< PixelT >::getKernelImage ( CandidateSwitch  cand) const

Definition at line 339 of file KernelCandidate.cc.

◆ getKernelSolution()

template<typename PixelT >
std::shared_ptr< StaticKernelSolution< PixelT > > lsst::ip::diffim::KernelCandidate< PixelT >::getKernelSolution ( CandidateSwitch  cand) const

Definition at line 372 of file KernelCandidate.cc.

◆ getKsum()

template<typename PixelT >
double lsst::ip::diffim::KernelCandidate< PixelT >::getKsum ( CandidateSwitch  cand) const

Definition at line 312 of file KernelCandidate.cc.

◆ getScienceMaskedImage()

template<typename _PixelT>
MaskedImagePtr lsst::ip::diffim::KernelCandidate< _PixelT >::getScienceMaskedImage ( )
inline

Definition at line 99 of file KernelCandidate.h.

◆ getSource()

template<typename _PixelT>
SourcePtr lsst::ip::diffim::KernelCandidate< _PixelT >::getSource ( ) const
inline

Return the original source.

Definition at line 94 of file KernelCandidate.h.

◆ getTemplateMaskedImage()

template<typename _PixelT>
MaskedImagePtr lsst::ip::diffim::KernelCandidate< _PixelT >::getTemplateMaskedImage ( )
inline

Return pointers to the image pixels used in kernel determination.

Definition at line 98 of file KernelCandidate.h.

◆ isInitialized()

template<typename _PixelT>
bool lsst::ip::diffim::KernelCandidate< _PixelT >::isInitialized ( ) const
inline

Definition at line 127 of file KernelCandidate.h.

Member Data Documentation

◆ _coreFlux

template<typename _PixelT>
double lsst::ip::diffim::KernelCandidate< _PixelT >::_coreFlux
private

Mean S/N in the science image.

Definition at line 190 of file KernelCandidate.h.

◆ _fitForBackground

template<typename _PixelT>
bool lsst::ip::diffim::KernelCandidate< _PixelT >::_fitForBackground
private

Definition at line 193 of file KernelCandidate.h.

◆ _isInitialized

template<typename _PixelT>
bool lsst::ip::diffim::KernelCandidate< _PixelT >::_isInitialized
private

Has the kernel been built.

Definition at line 191 of file KernelCandidate.h.

◆ _kernelSolutionOrig

template<typename _PixelT>
std::shared_ptr<StaticKernelSolution<PixelT> > lsst::ip::diffim::KernelCandidate< _PixelT >::_kernelSolutionOrig
private

Original basis solution.

Definition at line 196 of file KernelCandidate.h.

◆ _kernelSolutionPca

template<typename _PixelT>
std::shared_ptr<StaticKernelSolution<PixelT> > lsst::ip::diffim::KernelCandidate< _PixelT >::_kernelSolutionPca
private

Most recent solution.

Definition at line 199 of file KernelCandidate.h.

◆ _policy

template<typename _PixelT>
pex::policy::Policy lsst::ip::diffim::KernelCandidate< _PixelT >::_policy
private

Policy.

Definition at line 188 of file KernelCandidate.h.

◆ _scienceMaskedImage

template<typename _PixelT>
MaskedImagePtr lsst::ip::diffim::KernelCandidate< _PixelT >::_scienceMaskedImage
private

Subimage around which you build kernel.

Definition at line 186 of file KernelCandidate.h.

◆ _source

template<typename _PixelT>
SourcePtr lsst::ip::diffim::KernelCandidate< _PixelT >::_source
private

Definition at line 189 of file KernelCandidate.h.

◆ _templateMaskedImage

template<typename _PixelT>
MaskedImagePtr lsst::ip::diffim::KernelCandidate< _PixelT >::_templateMaskedImage
private

Subimage around which you build kernel.

Definition at line 185 of file KernelCandidate.h.

◆ _useRegularization

template<typename _PixelT>
bool lsst::ip::diffim::KernelCandidate< _PixelT >::_useRegularization
private

Use regularization?

Definition at line 192 of file KernelCandidate.h.

◆ _varianceEstimate

template<typename _PixelT>
VariancePtr lsst::ip::diffim::KernelCandidate< _PixelT >::_varianceEstimate
private

Estimate of the local variance.

Definition at line 187 of file KernelCandidate.h.


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