LSST Applications g0b6bd0c080+a72a5dd7e6,g1182afd7b4+2a019aa3bb,g17e5ecfddb+2b8207f7de,g1d67935e3f+06cf436103,g38293774b4+ac198e9f13,g396055baef+6a2097e274,g3b44f30a73+6611e0205b,g480783c3b1+98f8679e14,g48ccf36440+89c08d0516,g4b93dc025c+98f8679e14,g5c4744a4d9+a302e8c7f0,g613e996a0d+e1c447f2e0,g6c8d09e9e7+25247a063c,g7271f0639c+98f8679e14,g7a9cd813b8+124095ede6,g9d27549199+a302e8c7f0,ga1cf026fa3+ac198e9f13,ga32aa97882+7403ac30ac,ga786bb30fb+7a139211af,gaa63f70f4e+9994eb9896,gabf319e997+ade567573c,gba47b54d5d+94dc90c3ea,gbec6a3398f+06cf436103,gc6308e37c7+07dd123edb,gc655b1545f+ade567573c,gcc9029db3c+ab229f5caf,gd01420fc67+06cf436103,gd877ba84e5+06cf436103,gdb4cecd868+6f279b5b48,ge2d134c3d5+cc4dbb2e3f,ge448b5faa6+86d1ceac1d,gecc7e12556+98f8679e14,gf3ee170dca+25247a063c,gf4ac96e456+ade567573c,gf9f5ea5b4d+ac198e9f13,gff490e6085+8c2580be5c,w.2022.27
LSST Data Management Base Package
KernelCandidate.h
Go to the documentation of this file.
1// -*- lsst-c++ -*-
12#ifndef LSST_IP_DIFFIM_KERNELCANDIDATE_H
13#define LSST_IP_DIFFIM_KERNELCANDIDATE_H
14
15#include <memory>
16#include "Eigen/Core"
17
18#include "lsst/afw/math.h"
19#include "lsst/afw/image.h"
22#include "lsst/daf/base.h"
23
24namespace lsst {
25namespace ip {
26namespace diffim {
27
28
38 template <typename _PixelT>
40 public:
42 typedef _PixelT PixelT; // _after_ afw::math::Kernel::Pixel
43 public:
48
50 ORIG = 0,
51 PCA = 1,
52 RECENT = 2
53 };
54
64 KernelCandidate(float const xCenter,
65 float const yCenter,
66 MaskedImagePtr const& templateMaskedImage,
67 MaskedImagePtr const& scienceMaskedImage,
68 daf::base::PropertySet const& ps);
69
80 MaskedImagePtr const& templateMaskedImage,
81 MaskedImagePtr const& scienceMaskedImage,
82 daf::base::PropertySet const& ps);
84 virtual ~KernelCandidate() {};
85
91 double getCandidateRating() const { return _coreFlux; }
95 SourcePtr getSource() const { return _source; }
99 MaskedImagePtr getTemplateMaskedImage() {return _templateMaskedImage;}
100 MaskedImagePtr getScienceMaskedImage() {return _scienceMaskedImage;}
101
107 double getBackground(CandidateSwitch cand) const;
108 double getKsum(CandidateSwitch cand) const;
110 std::shared_ptr<ImageT const> getImage() const; // For SpatialCellImageCandidate
112
117
125 double background
126 );
127
128 bool isInitialized() const {return _isInitialized;}
129
130
165 /*
166 * @note This method uses an estimate of the variance which is the
167 * straight difference of the 2 images. If requested in the PropertySet
168 * ("iterateSingleKernel"), the kernel will be rebuilt using the
169 * variance of the difference image resulting from this first
170 * approximate step. This is particularly useful when convolving a
171 * single-depth science image; the variance (and thus resulting kernel)
172 * generally converges after 1 iteration. If
173 * "constantVarianceWeighting" is requested in the PropertySet, no iterations
174 * will be performed even if requested.
175 */
176
177 void build(
178 afw::math::KernelList const& basisList
179 );
180 void build(
181 afw::math::KernelList const& basisList,
182 Eigen::MatrixXd const& hMat
183 );
184
185 private:
186 MaskedImagePtr _templateMaskedImage;
187 MaskedImagePtr _scienceMaskedImage;
188 VariancePtr _varianceEstimate;
190 SourcePtr _source;
191 double _coreFlux;
192 bool _isInitialized;
193 bool _useRegularization;
194 bool _fitForBackground;
195
196 /* best single raw kernel */
198
199 /* with Pca basis */
201
202 void _buildKernelSolution(afw::math::KernelList const& basisList,
203 Eigen::MatrixXd const& hMat);
204 };
205
206
218 template <typename PixelT>
220 makeKernelCandidate(float const xCenter,
221 float const yCenter,
222 std::shared_ptr<afw::image::MaskedImage<PixelT> > const& templateMaskedImage,
223 std::shared_ptr<afw::image::MaskedImage<PixelT> > const& scienceMaskedImage,
224 daf::base::PropertySet const& ps){
225
227 templateMaskedImage,
228 scienceMaskedImage,
229 ps));
230 }
231
243 template <typename PixelT>
246 std::shared_ptr<afw::image::MaskedImage<PixelT> > const& templateMaskedImage,
247 std::shared_ptr<afw::image::MaskedImage<PixelT> > const& scienceMaskedImage,
248 daf::base::PropertySet const& ps){
249
251 templateMaskedImage,
252 scienceMaskedImage,
253 ps));
254 }
255
256
257}}} // end of namespace lsst::ip::diffim
258
259#endif
Declaration of classes to store the solution for convolution kernels.
A class to represent a 2-dimensional array of pixels.
Definition: Image.h:51
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:73
Base class for candidate objects in a SpatialCell that are able to return an Image of some sort (e....
Definition: SpatialCell.h:124
Class for storing generic metadata.
Definition: PropertySet.h:66
Class stored in SpatialCells for spatial Kernel fitting.
std::shared_ptr< ImageT const > getImage() const
std::shared_ptr< afw::image::MaskedImage< PixelT > > MaskedImagePtr
std::shared_ptr< afw::image::Image< afw::image::VariancePixel > > VariancePtr
virtual ~KernelCandidate()
Destructor.
afw::image::Image< afw::math::Kernel::Pixel > ImageT
afw::image::MaskedImage< PixelT > getDifferenceImage(CandidateSwitch cand)
Calculate associated difference image using internal solutions.
double getCandidateRating() const
Return Candidate rating.
std::shared_ptr< KernelCandidate > Ptr
MaskedImagePtr getTemplateMaskedImage()
Return pointers to the image pixels used in kernel determination.
double getBackground(CandidateSwitch cand) const
double getKsum(CandidateSwitch cand) const
std::shared_ptr< afw::table::SourceRecord > SourcePtr
std::shared_ptr< StaticKernelSolution< PixelT > > getKernelSolution(CandidateSwitch cand) const
std::shared_ptr< afw::math::Kernel > getKernel(CandidateSwitch cand) const
Return results of kernel solution.
KernelCandidate(float const xCenter, float const yCenter, MaskedImagePtr const &templateMaskedImage, MaskedImagePtr const &scienceMaskedImage, daf::base::PropertySet const &ps)
Constructor.
SourcePtr getSource() const
Return the original source.
std::shared_ptr< ImageT > getKernelImage(CandidateSwitch cand) const
void build(afw::math::KernelList const &basisList)
Core functionality of KernelCandidate, to build and fill a KernelSolution.
const char * source()
Source function that allows astChannel to source from a Stream.
Definition: Stream.h:224
std::shared_ptr< KernelCandidate< PixelT > > makeKernelCandidate(float const xCenter, float const yCenter, std::shared_ptr< afw::image::MaskedImage< PixelT > > const &templateMaskedImage, std::shared_ptr< afw::image::MaskedImage< PixelT > > const &scienceMaskedImage, daf::base::PropertySet const &ps)
Return a KernelCandidate pointer of the right sort.
A base class for image defects.