lsst.ip.diffim  21.0.0-2-g973f35b+8f342577b7
Public Types | Public Member Functions | Static Public Member Functions | Public 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 >:
lsst::afw::math::SpatialCellImageCandidate lsst::afw::math::SpatialCellCandidate

Public Types

enum  CandidateSwitch { ORIG = 0, PCA = 1, RECENT = 2 }
 
typedef afw::image::Image< afw::math::Kernel::PixelImageT
 
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::SourceRecordSourcePtr
 
enum  Status
 

Public Member Functions

 KernelCandidate (float const xCenter, float const yCenter, MaskedImagePtr const &templateMaskedImage, MaskedImagePtr const &scienceMaskedImage, daf::base::PropertySet const &ps)
 Constructor. More...
 
 KernelCandidate (SourcePtr const &source, MaskedImagePtr const &templateMaskedImage, MaskedImagePtr const &scienceMaskedImage, daf::base::PropertySet const &ps)
 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::KernelgetKernel (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)
 
double getChi2 () const
 
void setChi2 (double chi2)
 
float getXCenter () const
 
float getYCenter () const
 
virtual bool instantiate ()
 
virtual void setCandidateRating (double)
 
int getId () const
 
Status getStatus () const
 
void setStatus (Status status)
 
virtual bool isBad () const
 

Static Public Member Functions

static void setWidth (int width)
 
static int getWidth ()
 
static void setHeight (int height)
 
static int getHeight ()
 

Public Attributes

 BAD
 
 GOOD
 
 UNKNOWN
 

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 39 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 41 of file KernelCandidate.h.

◆ MaskedImagePtr

Definition at line 45 of file KernelCandidate.h.

◆ PixelT

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

Definition at line 42 of file KernelCandidate.h.

◆ Ptr

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

Definition at line 44 of file KernelCandidate.h.

◆ SourcePtr

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

Definition at line 47 of file KernelCandidate.h.

◆ VariancePtr

Definition at line 46 of file KernelCandidate.h.

Member Enumeration Documentation

◆ CandidateSwitch

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

Definition at line 49 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,
daf::base::PropertySet const &  ps 
)

Constructor.

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

Definition at line 33 of file KernelCandidate.cc.

◆ KernelCandidate() [2/2]

template<typename PixelT >
lsst::ip::diffim::KernelCandidate< PixelT >::KernelCandidate ( SourcePtr const &  source,
MaskedImagePtr const &  templateMaskedImage,
MaskedImagePtr const &  scienceMaskedImage,
daf::base::PropertySet const &  ps 
)

Constructor.

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

Definition at line 67 of file KernelCandidate.cc.

◆ ~KernelCandidate()

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

Destructor.

Definition at line 84 of file KernelCandidate.h.

Member Function Documentation

◆ 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.

Definition at line 87 of file KernelCandidate.cc.

◆ build() [2/2]

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

Definition at line 92 of file KernelCandidate.cc.

◆ getBackground()

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

Definition at line 244 of file KernelCandidate.cc.

◆ getCandidateRating()

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

Return Candidate rating.

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

Implements lsst::afw::math::SpatialCellImageCandidate.

Definition at line 91 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 347 of file KernelCandidate.cc.

◆ getDifferenceImage() [2/2]

template<typename PixelT >
lsst::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

Definition at line 371 of file KernelCandidate.cc.

◆ getImage()

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

Definition at line 317 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 220 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 292 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 322 of file KernelCandidate.cc.

◆ getKsum()

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

Definition at line 268 of file KernelCandidate.cc.

◆ getScienceMaskedImage()

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

Definition at line 100 of file KernelCandidate.h.

◆ getSource()

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

Return the original source.

Definition at line 95 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 99 of file KernelCandidate.h.

◆ isInitialized()

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

Definition at line 128 of file KernelCandidate.h.


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