LSSTApplications  19.0.0-14-gb0260a2+72efe9b372,20.0.0+7927753e06,20.0.0+8829bf0056,20.0.0+995114c5d2,20.0.0+b6f4b2abd1,20.0.0+bddc4f4cbe,20.0.0-1-g253301a+8829bf0056,20.0.0-1-g2b7511a+0d71a2d77f,20.0.0-1-g5b95a8c+7461dd0434,20.0.0-12-g321c96ea+23efe4bbff,20.0.0-16-gfab17e72e+fdf35455f6,20.0.0-2-g0070d88+ba3ffc8f0b,20.0.0-2-g4dae9ad+ee58a624b3,20.0.0-2-g61b8584+5d3db074ba,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+226a441f5f,20.0.0-2-gf072044+8829bf0056,20.0.0-2-gf1f7952+ee58a624b3,20.0.0-20-geae50cf+e37fec0aee,20.0.0-25-g3dcad98+544a109665,20.0.0-25-g5eafb0f+ee58a624b3,20.0.0-27-g64178ef+f1f297b00a,20.0.0-3-g4cc78c6+e0676b0dc8,20.0.0-3-g8f21e14+4fd2c12c9a,20.0.0-3-gbd60e8c+187b78b4b8,20.0.0-3-gbecbe05+48431fa087,20.0.0-38-ge4adf513+a12e1f8e37,20.0.0-4-g97dc21a+544a109665,20.0.0-4-gb4befbc+087873070b,20.0.0-4-gf910f65+5d3db074ba,20.0.0-5-gdfe0fee+199202a608,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g64f541c+d529cf1a41,20.0.0-6-g9a5b7a1+a1cd37312e,20.0.0-68-ga3f3dda+5fca18c6a4,20.0.0-9-g4aef684+e18322736b,w.2020.45
LSSTDataManagementBasePackage
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"
21 #include "lsst/afw/table/Source.h"
22 #include "lsst/daf/base.h"
23 
24 namespace lsst {
25 namespace ip {
26 namespace 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  CONST_PTR(ImageT) 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 */
197  std::shared_ptr<StaticKernelSolution<PixelT> > _kernelSolutionOrig;
198 
199  /* with Pca basis */
200  std::shared_ptr<StaticKernelSolution<PixelT> > _kernelSolutionPca;
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
lsst::ip::diffim::KernelCandidate::VariancePtr
std::shared_ptr< afw::image::Image< afw::image::VariancePixel > > VariancePtr
Definition: KernelCandidate.h:46
lsst::ip::diffim::KernelCandidate::build
void build(afw::math::KernelList const &basisList)
Core functionality of KernelCandidate, to build and fill a KernelSolution.
Definition: KernelCandidate.cc:87
std::shared_ptr
STL class.
lsst::ip::diffim::KernelCandidate::PCA
@ PCA
Definition: KernelCandidate.h:51
std::vector< std::shared_ptr< Kernel > >
lsst::ip::diffim::KernelCandidate
Class stored in SpatialCells for spatial Kernel fitting.
Definition: KernelCandidate.h:39
KernelSolution.h
Declaration of classes to store the solution for convolution kernels.
lsst::ip::diffim::KernelCandidate::getCandidateRating
double getCandidateRating() const
Return Candidate rating.
Definition: KernelCandidate.h:91
lsst::ip::diffim::KernelCandidate::CandidateSwitch
CandidateSwitch
Definition: KernelCandidate.h:49
lsst::ip::diffim::KernelCandidate::SourcePtr
std::shared_ptr< afw::table::SourceRecord > SourcePtr
Definition: KernelCandidate.h:47
PTR
#define PTR(...)
Definition: base.h:41
lsst::ip::diffim::KernelCandidate::getDifferenceImage
afw::image::MaskedImage< PixelT > getDifferenceImage(CandidateSwitch cand)
Calculate associated difference image using internal solutions.
Definition: KernelCandidate.cc:347
lsst::ip::diffim::KernelCandidate::ImageT
afw::image::Image< afw::math::Kernel::Pixel > ImageT
Definition: KernelCandidate.h:41
math.h
lsst::ip::diffim::KernelCandidate::MaskedImagePtr
std::shared_ptr< afw::image::MaskedImage< PixelT > > MaskedImagePtr
Definition: KernelCandidate.h:45
lsst::afw::image::MaskedImage< PixelT >
ast::detail::source
const char * source()
Source function that allows astChannel to source from a Stream.
Definition: Stream.h:224
base.h
lsst.pipe.drivers.visualizeVisit.background
background
Definition: visualizeVisit.py:37
lsst::afw::math::SpatialCellImageCandidate
Base class for candidate objects in a SpatialCell that are able to return an Image of some sort (e....
Definition: SpatialCell.h:126
lsst::ip::diffim::KernelCandidate::getSource
SourcePtr getSource() const
Return the original source.
Definition: KernelCandidate.h:95
lsst::ip::diffim::KernelCandidate::KernelCandidate
KernelCandidate(float const xCenter, float const yCenter, MaskedImagePtr const &templateMaskedImage, MaskedImagePtr const &scienceMaskedImage, daf::base::PropertySet const &ps)
Constructor.
Definition: KernelCandidate.cc:33
lsst::ip::diffim::KernelCandidate::ORIG
@ ORIG
Definition: KernelCandidate.h:50
image.h
lsst::ip::diffim::KernelCandidate::getImage
boost::shared_ptr< ImageT const > getImage() const
Definition: KernelCandidate.cc:317
lsst::ip::diffim::KernelCandidate::getKernelImage
boost::shared_ptr< ImageT > getKernelImage(CandidateSwitch cand) const
Definition: KernelCandidate.cc:292
CONST_PTR
#define CONST_PTR(...)
A shared pointer to a const object.
Definition: base.h:47
Source.h
lsst
A base class for image defects.
Definition: imageAlgorithm.dox:1
lsst::ip::diffim::KernelCandidate::getKernel
std::shared_ptr< afw::math::Kernel > getKernel(CandidateSwitch cand) const
Return results of kernel solution.
Definition: KernelCandidate.cc:220
lsst::ip::diffim::KernelCandidate::getKernelSolution
std::shared_ptr< StaticKernelSolution< PixelT > > getKernelSolution(CandidateSwitch cand) const
Definition: KernelCandidate.cc:322
lsst::ip::diffim::KernelCandidate::getBackground
double getBackground(CandidateSwitch cand) const
Definition: KernelCandidate.cc:244
lsst::ip::diffim::KernelCandidate::isInitialized
bool isInitialized() const
Definition: KernelCandidate.h:128
lsst::daf::base::PropertySet
Class for storing generic metadata.
Definition: PropertySet.h:67
lsst::ip::diffim::KernelCandidate::PixelT
_PixelT PixelT
Definition: KernelCandidate.h:42
lsst::ip::diffim::KernelCandidate::RECENT
@ RECENT
Definition: KernelCandidate.h:52
lsst::ip::diffim::KernelCandidate::getTemplateMaskedImage
MaskedImagePtr getTemplateMaskedImage()
Return pointers to the image pixels used in kernel determination.
Definition: KernelCandidate.h:99
lsst::afw::image::Image
A class to represent a 2-dimensional array of pixels.
Definition: Image.h:58
lsst::ip::diffim::KernelCandidate::Ptr
std::shared_ptr< KernelCandidate > Ptr
Definition: KernelCandidate.h:44
lsst::ip::diffim::KernelCandidate::getKsum
double getKsum(CandidateSwitch cand) const
Definition: KernelCandidate.cc:268
lsst::ip::diffim::KernelCandidate::~KernelCandidate
virtual ~KernelCandidate()
Destructor.
Definition: KernelCandidate.h:84
lsst::ip::diffim::makeKernelCandidate
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.
Definition: KernelCandidate.h:220
lsst::ip::diffim::KernelCandidate::getScienceMaskedImage
MaskedImagePtr getScienceMaskedImage()
Definition: KernelCandidate.h:100