LSSTApplications
20.0.0
LSSTDataManagementBasePackage
|
Class stored in SpatialCells for spatial Kernel fitting.
More...
#include <KernelCandidate.h>
|
| 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::Kernel > | getKernel (CandidateSwitch cand) const |
| Return results of kernel solution. More...
|
|
double | getBackground (CandidateSwitch cand) const |
|
double | getKsum (CandidateSwitch cand) const |
|
boost::shared_ptr< ImageT > | getKernelImage (CandidateSwitch cand) const |
|
boost::shared_ptr< ImageT const > | getImage () const |
|
std::shared_ptr< StaticKernelSolution< PixelT > > | getKernelSolution (CandidateSwitch cand) const |
|
afw::image::MaskedImage< PixelT > | getDifferenceImage (CandidateSwitch cand) |
| Calculate associated difference image using internal solutions. More...
|
|
afw::image::MaskedImage< PixelT > | getDifferenceImage (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 |
| Return the candidate's chi^2. More...
|
|
void | setChi2 (double chi2) |
| Set the candidate's chi^2. More...
|
|
float | getXCenter () const |
| Return the object's column-centre. More...
|
|
float | getYCenter () const |
| Return the object's row-centre. More...
|
|
virtual bool | instantiate () |
| Do anything needed to make this candidate usable. More...
|
|
virtual void | setCandidateRating (double) |
| Set the candidate's rating. More...
|
|
int | getId () const |
| Return the candidate's unique ID. More...
|
|
Status | getStatus () const |
| Return the candidate's status. More...
|
|
void | setStatus (Status status) |
| Set the candidate's status. More...
|
|
virtual bool | isBad () const |
| Is this candidate unacceptable? More...
|
|
|
static void | setWidth (int width) |
| Set the width of the image that getImage should return. More...
|
|
static int | getWidth () |
| Return the width of the image that getImage should return. More...
|
|
static void | setHeight (int height) |
| Set the height of the image that getImage should return. More...
|
|
static int | getHeight () |
| Return the height of the image that getImage should return. More...
|
|
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.
◆ ImageT
template<typename _PixelT >
◆ MaskedImagePtr
template<typename _PixelT >
◆ PixelT
template<typename _PixelT >
◆ Ptr
template<typename _PixelT >
◆ SourcePtr
template<typename _PixelT >
◆ VariancePtr
template<typename _PixelT >
◆ CandidateSwitch
template<typename _PixelT >
◆ Status
◆ KernelCandidate() [1/2]
template<typename PixelT >
Constructor.
- Parameters
-
xCenter | Col position of object |
yCenter | Row position of object |
templateMaskedImage | Pointer to template image |
scienceMaskedImage | Pointer to science image |
ps | PropertySet |
Definition at line 33 of file KernelCandidate.cc.
38 _templateMaskedImage(templateMaskedImage),
39 _scienceMaskedImage(scienceMaskedImage),
44 _isInitialized(
false),
45 _useRegularization(
false),
46 _fitForBackground(ps.getAsBool(
"fitForBackground")),
47 _kernelSolutionOrig(),
48 _kernelSolutionPca() {
50 ImageStatistics<PixelT> imstats(ps);
51 int candidateCoreRadius = _ps->getAsInt(
"candidateCoreRadius");
53 imstats.apply(*_scienceMaskedImage, candidateCoreRadius);
56 "Unable to calculate core imstats for ranking Candidate %d", this->
getId());
61 _coreFlux = imstats.getMean();
62 LOGL_DEBUG(
"TRACE4.ip.diffim.KernelCandidate",
"Candidate %d at %.2f %.2f with ranking %.2f",
◆ KernelCandidate() [2/2]
template<typename PixelT >
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 |
Definition at line 67 of file KernelCandidate.cc.
71 _templateMaskedImage(templateMaskedImage),
72 _scienceMaskedImage(scienceMaskedImage),
76 _coreFlux(
source->getPsfInstFlux()),
77 _isInitialized(
false),
78 _useRegularization(
false),
79 _fitForBackground(ps.getAsBool(
"fitForBackground")),
80 _kernelSolutionOrig(),
81 _kernelSolutionPca() {
82 LOGL_DEBUG(
"TRACE4.ip.diffim.KernelCandidate",
"Candidate %d at %.2f %.2f with ranking %.2f",
◆ ~KernelCandidate()
template<typename _PixelT >
◆ build() [1/2]
template<typename PixelT >
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.
88 build(basisList, Eigen::MatrixXd());
◆ build() [2/2]
template<typename PixelT >
Definition at line 92 of file KernelCandidate.cc.
98 var += (*(_templateMaskedImage->getVariance()));
100 if (_ps->getAsBool(
"constantVarianceWeighting")) {
108 LOGL_DEBUG(
"TRACE4.ip.diffim.KernelCandidate",
"Candidate %d using constant variance of %.2f",
109 this->
getId(), varValue);
116 _buildKernelSolution(basisList, hMat);
121 if (_ps->getAsBool(
"iterateSingleKernel") && (!(_ps->getAsBool(
"constantVarianceWeighting")))) {
126 _buildKernelSolution(basisList, hMat);
132 _isInitialized =
true;
◆ getBackground()
template<typename PixelT >
Definition at line 244 of file KernelCandidate.cc.
246 if (_kernelSolutionOrig)
247 return _kernelSolutionOrig->getBackground();
251 if (_kernelSolutionPca)
252 return _kernelSolutionPca->getBackground();
256 if (_kernelSolutionPca)
257 return _kernelSolutionPca->getBackground();
258 else if (_kernelSolutionOrig)
259 return _kernelSolutionOrig->getBackground();
◆ getCandidateRating()
template<typename _PixelT >
◆ getChi2()
double lsst::afw::math::SpatialCellImageCandidate::getChi2 |
( |
| ) |
const |
|
inlineinherited |
◆ getDifferenceImage() [1/2]
template<typename PixelT >
Calculate associated difference image using internal solutions.
Definition at line 347 of file KernelCandidate.cc.
349 if (_kernelSolutionOrig)
350 return getDifferenceImage(_kernelSolutionOrig->getKernel(), _kernelSolutionOrig->getBackground());
354 if (_kernelSolutionPca)
355 return getDifferenceImage(_kernelSolutionPca->getKernel(), _kernelSolutionPca->getBackground());
359 if (_kernelSolutionPca)
360 return getDifferenceImage(_kernelSolutionPca->getKernel(), _kernelSolutionPca->getBackground());
361 else if (_kernelSolutionOrig)
362 return getDifferenceImage(_kernelSolutionOrig->getKernel(), _kernelSolutionOrig->getBackground());
◆ getDifferenceImage() [2/2]
template<typename PixelT >
Calculate associated difference image using input kernel and background.
- Note
- Useful for spatial modeling
Definition at line 371 of file KernelCandidate.cc.
◆ getHeight()
static int lsst::afw::math::SpatialCellImageCandidate::getHeight |
( |
| ) |
|
|
inlinestaticinherited |
Return the height of the image that getImage should return.
Definition at line 147 of file SpatialCell.h.
◆ getId()
int lsst::afw::math::SpatialCellCandidate::getId |
( |
| ) |
const |
|
inlineinherited |
◆ getImage()
template<typename PixelT >
◆ getKernel()
template<typename PixelT >
Return results of kernel solution.
Definition at line 220 of file KernelCandidate.cc.
222 if (_kernelSolutionOrig)
223 return _kernelSolutionOrig->getKernel();
227 if (_kernelSolutionPca)
228 return _kernelSolutionPca->getKernel();
232 if (_kernelSolutionPca)
233 return _kernelSolutionPca->getKernel();
234 else if (_kernelSolutionOrig)
235 return _kernelSolutionOrig->getKernel();
◆ getKernelImage()
template<typename PixelT >
Definition at line 292 of file KernelCandidate.cc.
295 if (_kernelSolutionOrig)
296 return _kernelSolutionOrig->makeKernelImage();
300 if (_kernelSolutionPca)
301 return _kernelSolutionPca->makeKernelImage();
305 if (_kernelSolutionPca)
306 return _kernelSolutionPca->makeKernelImage();
307 else if (_kernelSolutionOrig)
308 return _kernelSolutionOrig->makeKernelImage();
◆ getKernelSolution()
template<typename PixelT >
Definition at line 322 of file KernelCandidate.cc.
325 if (_kernelSolutionOrig)
326 return _kernelSolutionOrig;
330 if (_kernelSolutionPca)
331 return _kernelSolutionPca;
335 if (_kernelSolutionPca)
336 return _kernelSolutionPca;
337 else if (_kernelSolutionOrig)
338 return _kernelSolutionOrig;
◆ getKsum()
template<typename PixelT >
Definition at line 268 of file KernelCandidate.cc.
270 if (_kernelSolutionOrig)
271 return _kernelSolutionOrig->getKsum();
275 if (_kernelSolutionPca)
276 return _kernelSolutionPca->getKsum();
280 if (_kernelSolutionPca)
281 return _kernelSolutionPca->getKsum();
282 else if (_kernelSolutionOrig)
283 return _kernelSolutionOrig->getKsum();
◆ getScienceMaskedImage()
template<typename _PixelT >
◆ getSource()
template<typename _PixelT >
◆ getStatus()
Status lsst::afw::math::SpatialCellCandidate::getStatus |
( |
| ) |
const |
|
inlineinherited |
◆ getTemplateMaskedImage()
template<typename _PixelT >
Return pointers to the image pixels used in kernel determination.
Definition at line 99 of file KernelCandidate.h.
99 {
return _templateMaskedImage;}
◆ getWidth()
static int lsst::afw::math::SpatialCellImageCandidate::getWidth |
( |
| ) |
|
|
inlinestaticinherited |
Return the width of the image that getImage should return.
Definition at line 142 of file SpatialCell.h.
◆ getXCenter()
float lsst::afw::math::SpatialCellCandidate::getXCenter |
( |
| ) |
const |
|
inlineinherited |
Return the object's column-centre.
Definition at line 90 of file SpatialCell.h.
◆ getYCenter()
float lsst::afw::math::SpatialCellCandidate::getYCenter |
( |
| ) |
const |
|
inlineinherited |
Return the object's row-centre.
Definition at line 93 of file SpatialCell.h.
◆ instantiate()
virtual bool lsst::afw::math::SpatialCellCandidate::instantiate |
( |
| ) |
|
|
inlinevirtualinherited |
Do anything needed to make this candidate usable.
Definition at line 96 of file SpatialCell.h.
◆ isBad()
virtual bool lsst::afw::math::SpatialCellCandidate::isBad |
( |
| ) |
const |
|
inlinevirtualinherited |
Is this candidate unacceptable?
Definition at line 110 of file SpatialCell.h.
110 {
return (_status ==
BAD); }
◆ isInitialized()
template<typename _PixelT >
◆ setCandidateRating()
virtual void lsst::afw::math::SpatialCellCandidate::setCandidateRating |
( |
double |
| ) |
|
|
inlinevirtualinherited |
◆ setChi2()
void lsst::afw::math::SpatialCellImageCandidate::setChi2 |
( |
double |
chi2 | ) |
|
|
inlineinherited |
◆ setHeight()
static void lsst::afw::math::SpatialCellImageCandidate::setHeight |
( |
int |
height | ) |
|
|
inlinestaticinherited |
Set the height of the image that getImage should return.
Definition at line 145 of file SpatialCell.h.
145 { _height = height; }
◆ setStatus()
void lsst::afw::math::SpatialCellCandidate::setStatus |
( |
Status |
status | ) |
|
|
inherited |
◆ setWidth()
static void lsst::afw::math::SpatialCellImageCandidate::setWidth |
( |
int |
width | ) |
|
|
inlinestaticinherited |
Set the width of the image that getImage should return.
Definition at line 140 of file SpatialCell.h.
The documentation for this class was generated from the following files:
- /j/snowflake/release/lsstsw/stack/1a1d771/Linux64/ip_diffim/20.0.0/include/lsst/ip/diffim/KernelCandidate.h
- /j/snowflake/release/lsstsw/stack/1a1d771/Linux64/ip_diffim/20.0.0/src/KernelCandidate.cc
std::shared_ptr< afw::image::Image< afw::image::VariancePixel > > VariancePtr
void build(afw::math::KernelList const &basisList)
Core functionality of KernelCandidate, to build and fill a KernelSolution.
void setStatus(Status status)
Set the candidate's status.
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
lsst::afw::image::MaskedImage< PixelT > convolveAndSubtract(lsst::afw::image::MaskedImage< PixelT > const &templateImage, lsst::afw::image::MaskedImage< PixelT > const &scienceMaskedImage, lsst::afw::math::Kernel const &convolutionKernel, BackgroundT background, bool invert=true)
Execute fundamental task of convolving template and subtracting it from science image.
double getValue(Property const prop=NOTHING) const
Return the value of the desired property (if specified in the constructor)
afw::image::MaskedImage< PixelT > getDifferenceImage(CandidateSwitch cand)
Calculate associated difference image using internal solutions.
Statistics makeStatistics(lsst::afw::image::Image< Pixel > const &img, lsst::afw::image::Mask< image::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Handle a watered-down front-end to the constructor (no variance)
float getXCenter() const
Return the object's column-centre.
const char * source()
Source function that allows astChannel to source from a Stream.
Base class for candidate objects in a SpatialCell that are able to return an Image of some sort (e....
int getId() const
Return the candidate's unique ID.
boost::shared_ptr< ImageT > getKernelImage(CandidateSwitch cand) const
VariancePtr getVariance() const
Return a (shared_ptr to) the MaskedImage's variance.
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Reports invalid arguments.
#define LOGL_DEBUG(logger, message...)
Provides consistent interface for LSST exceptions.
A class to represent a 2-dimensional array of pixels.
float getYCenter() const
Return the object's row-centre.
@ MEDIAN
estimate sample median