Template Class KernelCandidate

Inheritance Relationships

Base Type

Class Documentation

template<typename _PixelT>
class KernelCandidate : public lsst::afw::math::SpatialCellImageCandidate

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.

Public Types

enum CandidateSwitch

Values:

ORIG = 0
PCA = 1
RECENT = 2
typedef afw::image::Image<afw::math::Kernel::Pixel> ImageT
typedef _PixelT PixelT
typedef std::shared_ptr<KernelCandidate> Ptr
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 Functions

KernelCandidate(float const xCenter, float const yCenter, MaskedImagePtr const &templateMaskedImage, MaskedImagePtr const &scienceMaskedImage, daf::base::PropertySet const &ps)

Constructor.

Parameters
  • xCenter: Col position of object

  • yCenter: Row position of object

  • templateMaskedImage: Pointer to template image

  • scienceMaskedImage: Pointer to science image

  • ps: PropertySet

KernelCandidate(SourcePtr const &source, MaskedImagePtr const &templateMaskedImage, MaskedImagePtr const &scienceMaskedImage, daf::base::PropertySet const &ps)

Constructor.

Parameters
  • source: Pointer to a source to use in constructing the candidate

  • templateMaskedImage: Pointer to template image

  • scienceMaskedImage: Pointer to science image

  • ps: PropertySet

virtual ~KernelCandidate()

Destructor.

double getCandidateRating() const

Return Candidate rating.

Note

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

SourcePtr getSource() const

Return the original source.

MaskedImagePtr getTemplateMaskedImage()

Return pointers to the image pixels used in kernel determination.

MaskedImagePtr getScienceMaskedImage()
std::shared_ptr<afw::math::Kernel> getKernel(CandidateSwitch cand) const

Return results of kernel solution.

double getBackground(CandidateSwitch cand) const
double getKsum(CandidateSwitch cand) const
PTR(ImageT) const
CONST_PTR(ImageT) const
std::shared_ptr<StaticKernelSolution<PixelT>> getKernelSolution(CandidateSwitch cand) const
afw::image::MaskedImage<PixelT> getDifferenceImage(CandidateSwitch cand)

Calculate associated difference image using internal solutions.

afw::image::MaskedImage<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

bool isInitialized() const
void build(afw::math::KernelList const &basisList)

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

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

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

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.

Note

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.

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