LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Private Member Functions | Private 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< afw::math::Kernel::Pixel > lsst::afw::math::SpatialCellCandidate

Public Types

enum  CandidateSwitch { ORIG = 0, PCA = 1, RECENT = 2 }
 
typedef afw::image::Image
< afw::math::Kernel::Pixel
ImageT
 
typedef _PixelT PixelT
 
typedef boost::shared_ptr
< KernelCandidate
Ptr
 
typedef boost::shared_ptr
< afw::image::MaskedImage
< PixelT > > 
MaskedImagePtr
 
typedef boost::shared_ptr
< afw::image::Image
< afw::image::VariancePixel > > 
VariancePtr
 
typedef boost::shared_ptr
< afw::table::SourceRecord
SourcePtr
 
- Public Types inherited from lsst::afw::math::SpatialCellImageCandidate< afw::math::Kernel::Pixel >
typedef boost::shared_ptr
< SpatialCellImageCandidate
Ptr
 
typedef boost::shared_ptr
< const
SpatialCellImageCandidate
ConstPtr
 
- Public Types inherited from lsst::afw::math::SpatialCellCandidate
enum  Status { BAD = 0, GOOD = 1, UNKNOWN = 2 }
 
typedef boost::shared_ptr
< SpatialCellCandidate
Ptr
 
typedef boost::shared_ptr
< const SpatialCellCandidate
ConstPtr
 

Public Member Functions

 KernelCandidate (float const xCenter, float const yCenter, MaskedImagePtr const &templateMaskedImage, MaskedImagePtr const &scienceMaskedImage, pex::policy::Policy const &policy)
 Constructor. More...
 
 KernelCandidate (SourcePtr const &source, MaskedImagePtr const &templateMaskedImage, MaskedImagePtr const &scienceMaskedImage, pex::policy::Policy const &policy)
 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 ()
 
afw::math::Kernel::Ptr getKernel (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
 Return the Candidate's Image. More...
 
boost::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 (afw::math::Kernel::Ptr 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, boost::shared_ptr< Eigen::MatrixXd > hMat)
 
- Public Member Functions inherited from lsst::afw::math::SpatialCellImageCandidate< afw::math::Kernel::Pixel >
 SpatialCellImageCandidate (float const xCenter, float const yCenter)
 ctor More...
 
virtual ~SpatialCellImageCandidate ()
 
double getChi2 () const
 Return the candidate's chi^2. More...
 
void setChi2 (double chi2)
 Set the candidate's chi^2. More...
 
- Public Member Functions inherited from lsst::afw::math::SpatialCellCandidate
 SpatialCellCandidate (float const xCenter, float const yCenter)
 
virtual ~SpatialCellCandidate ()
 
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...
 

Private Member Functions

void _buildKernelSolution (afw::math::KernelList const &basisList, boost::shared_ptr< Eigen::MatrixXd > hMat)
 

Private Attributes

MaskedImagePtr _templateMaskedImage
 Subimage around which you build kernel. More...
 
MaskedImagePtr _scienceMaskedImage
 Subimage around which you build kernel. More...
 
VariancePtr _varianceEstimate
 Estimate of the local variance. More...
 
pex::policy::Policy _policy
 Policy. More...
 
SourcePtr _source
 
double _coreFlux
 Mean S/N in the science image. More...
 
bool _isInitialized
 Has the kernel been built. More...
 
bool _useRegularization
 Use regularization? More...
 
bool _fitForBackground
 
boost::shared_ptr
< StaticKernelSolution< PixelT > > 
_kernelSolutionOrig
 Original basis solution. More...
 
boost::shared_ptr
< StaticKernelSolution< PixelT > > 
_kernelSolutionPca
 Most recent solution. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from lsst::afw::math::SpatialCellImageCandidate< afw::math::Kernel::Pixel >
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...
 
- Protected Attributes inherited from lsst::afw::math::SpatialCellImageCandidate< afw::math::Kernel::Pixel >
boost::shared_ptr
< lsst::afw::image::Image
< afw::math::Kernel::Pixel > > 
_image
 a pointer to the Image, for the use of the base class More...
 

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

Member Typedef Documentation

Definition at line 41 of file KernelCandidate.h.

template<typename _PixelT>
typedef boost::shared_ptr<afw::image::MaskedImage<PixelT> > lsst::ip::diffim::KernelCandidate< _PixelT >::MaskedImagePtr

Definition at line 49 of file KernelCandidate.h.

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

Definition at line 42 of file KernelCandidate.h.

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

Definition at line 48 of file KernelCandidate.h.

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

Definition at line 51 of file KernelCandidate.h.

template<typename _PixelT>
typedef boost::shared_ptr<afw::image::Image<afw::image::VariancePixel> > lsst::ip::diffim::KernelCandidate< _PixelT >::VariancePtr

Definition at line 50 of file KernelCandidate.h.

Member Enumeration Documentation

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

Definition at line 53 of file KernelCandidate.h.

Constructor & Destructor Documentation

template<typename PixelT >
lsst::ip::diffim::KernelCandidate< PixelT >::KernelCandidate ( float const  xCenter,
float const  yCenter,
MaskedImagePtr const &  templateMaskedImage,
MaskedImagePtr const &  scienceMaskedImage,
pex::policy::Policy const &  policy 
)

Constructor.

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

Definition at line 35 of file KernelCandidate.cc.

41  :
43  _templateMaskedImage(templateMaskedImage),
44  _scienceMaskedImage(scienceMaskedImage),
46  _policy(policy),
47  _source(),
48  _coreFlux(),
49  _isInitialized(false),
50  _useRegularization(false),
51  _fitForBackground(_policy.getBool("fitForBackground")),
54  {
55 
56  /* Rank by mean core S/N in science image */
57  ImageStatistics<PixelT> imstats(_policy);
58  int candidateCoreRadius = _policy.getInt("candidateCoreRadius");
59  try {
60  imstats.apply(*_scienceMaskedImage, candidateCoreRadius);
61  } catch (pexExcept::Exception& e) {
62  pexLogging::TTrace<3>("lsst.ip.diffim.KernelCandidate",
63  "Unable to calculate core imstats for ranking Candidate %d", this->getId());
65  return;
66  }
67 
68  _coreFlux = imstats.getMean();
69  pexLog::TTrace<5>("lsst.ip.diffim.KernelCandidate",
70  "Candidate %d at %.2f %.2f with ranking %.2f",
71  this->getId(), this->getXCenter(), this->getYCenter(), _coreFlux);
72  }
void setStatus(Status status)
Set the candidate&#39;s status.
Definition: SpatialCell.cc:61
int getInt(const std::string &name) const
Definition: Policy.h:603
bool _isInitialized
Has the kernel been built.
boost::shared_ptr< StaticKernelSolution< PixelT > > _kernelSolutionOrig
Original basis solution.
MaskedImagePtr _scienceMaskedImage
Subimage around which you build kernel.
bool getBool(const std::string &name) const
Definition: Policy.h:589
float getYCenter() const
Return the object&#39;s row-centre.
Definition: SpatialCell.h:98
pex::policy::Policy _policy
Policy.
int getId() const
Return the candidate&#39;s unique ID.
Definition: SpatialCell.h:109
VariancePtr _varianceEstimate
Estimate of the local variance.
float getXCenter() const
Return the object&#39;s column-centre.
Definition: SpatialCell.h:95
double _coreFlux
Mean S/N in the science image.
MaskedImagePtr _templateMaskedImage
Subimage around which you build kernel.
bool _useRegularization
Use regularization?
boost::shared_ptr< StaticKernelSolution< PixelT > > _kernelSolutionPca
Most recent solution.
template<typename PixelT >
lsst::ip::diffim::KernelCandidate< PixelT >::KernelCandidate ( SourcePtr const &  source,
MaskedImagePtr const &  templateMaskedImage,
MaskedImagePtr const &  scienceMaskedImage,
pex::policy::Policy const &  policy 
)

Constructor.

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

Definition at line 75 of file KernelCandidate.cc.

80  :
82  _templateMaskedImage(templateMaskedImage),
83  _scienceMaskedImage(scienceMaskedImage),
85  _policy(policy),
86  _source(source),
87  _coreFlux(source->getPsfFlux()),
88  _isInitialized(false),
89  _useRegularization(false),
90  _fitForBackground(_policy.getBool("fitForBackground")),
93  {
94  pexLog::TTrace<5>("lsst.ip.diffim.KernelCandidate",
95  "Candidate %d at %.2f %.2f with ranking %.2f",
96  this->getId(), this->getXCenter(), this->getYCenter(), _coreFlux);
97  }
bool _isInitialized
Has the kernel been built.
boost::shared_ptr< StaticKernelSolution< PixelT > > _kernelSolutionOrig
Original basis solution.
MaskedImagePtr _scienceMaskedImage
Subimage around which you build kernel.
bool getBool(const std::string &name) const
Definition: Policy.h:589
float getYCenter() const
Return the object&#39;s row-centre.
Definition: SpatialCell.h:98
pex::policy::Policy _policy
Policy.
int getId() const
Return the candidate&#39;s unique ID.
Definition: SpatialCell.h:109
VariancePtr _varianceEstimate
Estimate of the local variance.
float getXCenter() const
Return the object&#39;s column-centre.
Definition: SpatialCell.h:95
double _coreFlux
Mean S/N in the science image.
MaskedImagePtr _templateMaskedImage
Subimage around which you build kernel.
bool _useRegularization
Use regularization?
boost::shared_ptr< StaticKernelSolution< PixelT > > _kernelSolutionPca
Most recent solution.
template<typename _PixelT>
virtual lsst::ip::diffim::KernelCandidate< _PixelT >::~KernelCandidate ( )
inlinevirtual

Destructor.

Definition at line 88 of file KernelCandidate.h.

88 {};

Member Function Documentation

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

Definition at line 156 of file KernelCandidate.cc.

158  {
159  bool checkConditionNumber = _policy.getBool("checkConditionNumber");
160  double maxConditionNumber = _policy.getDouble("maxConditionNumber");
161  std::string conditionNumberType = _policy.getString("conditionNumberType");
163  if (conditionNumberType == "SVD") {
164  ctype = KernelSolution::SVD;
165  }
166  else if (conditionNumberType == "EIGENVALUE") {
168  }
169  else {
170  throw LSST_EXCEPT(pexExcept::Exception, "conditionNumberType not recognized");
171  }
172 
173  /* Do we have a regularization matrix? If so use it */
174  if (hMat) {
175  _useRegularization = true;
176  pexLog::TTrace<5>("lsst.ip.diffim.KernelCandidate.build",
177  "Using kernel regularization");
178 
179  if (_isInitialized) {
180  _kernelSolutionPca = boost::shared_ptr<StaticKernelSolution<PixelT> >(
181  new RegularizedKernelSolution<PixelT>(basisList, _fitForBackground, hMat, _policy)
182  );
183  _kernelSolutionPca->build(*(_templateMaskedImage->getImage()),
184  *(_scienceMaskedImage->getImage()),
186  if (checkConditionNumber) {
187  if (_kernelSolutionPca->getConditionNumber(ctype) > maxConditionNumber) {
188  pexLog::TTrace<5>("lsst.ip.diffim.KernelCandidate",
189  "Candidate %d solution has bad condition number",
190  this->getId());
192  return;
193  }
194  }
195  _kernelSolutionPca->solve();
196  }
197  else {
198  _kernelSolutionOrig = boost::shared_ptr<StaticKernelSolution<PixelT> >(
199  new RegularizedKernelSolution<PixelT>(basisList, _fitForBackground, hMat, _policy)
200  );
201  _kernelSolutionOrig->build(*(_templateMaskedImage->getImage()),
202  *(_scienceMaskedImage->getImage()),
204  if (checkConditionNumber) {
205  if (_kernelSolutionOrig->getConditionNumber(ctype) > maxConditionNumber) {
206  pexLog::TTrace<5>("lsst.ip.diffim.KernelCandidate",
207  "Candidate %d solution has bad condition number",
208  this->getId());
210  return;
211  }
212  }
213  _kernelSolutionOrig->solve();
214  }
215  }
216  else {
217  _useRegularization = false;
218  pexLog::TTrace<5>("lsst.ip.diffim.KernelCandidate.build",
219  "Not using kernel regularization");
220  if (_isInitialized) {
221  _kernelSolutionPca = boost::shared_ptr<StaticKernelSolution<PixelT> >(
222  new StaticKernelSolution<PixelT>(basisList, _fitForBackground)
223  );
224  _kernelSolutionPca->build(*(_templateMaskedImage->getImage()),
225  *(_scienceMaskedImage->getImage()),
227  if (checkConditionNumber) {
228  if (_kernelSolutionPca->getConditionNumber(ctype) > maxConditionNumber) {
229  pexLog::TTrace<5>("lsst.ip.diffim.KernelCandidate",
230  "Candidate %d solution has bad condition number",
231  this->getId());
233  return;
234  }
235  }
236  _kernelSolutionPca->solve();
237  }
238  else {
239  _kernelSolutionOrig = boost::shared_ptr<StaticKernelSolution<PixelT> >(
240  new StaticKernelSolution<PixelT>(basisList, _fitForBackground)
241  );
242  _kernelSolutionOrig->build(*(_templateMaskedImage->getImage()),
243  *(_scienceMaskedImage->getImage()),
245  if (checkConditionNumber) {
246  if (_kernelSolutionOrig->getConditionNumber(ctype) > maxConditionNumber) {
247  pexLog::TTrace<5>("lsst.ip.diffim.KernelCandidate",
248  "Candidate %d solution has bad condition number",
249  this->getId());
251  return;
252  }
253  }
254  _kernelSolutionOrig->solve();
255  }
256  }
257  }
void setStatus(Status status)
Set the candidate&#39;s status.
Definition: SpatialCell.cc:61
bool _isInitialized
Has the kernel been built.
boost::shared_ptr< StaticKernelSolution< PixelT > > _kernelSolutionOrig
Original basis solution.
MaskedImagePtr _scienceMaskedImage
Subimage around which you build kernel.
bool getBool(const std::string &name) const
Definition: Policy.h:589
const std::string getString(const std::string &name) const
Definition: Policy.h:631
pex::policy::Policy _policy
Policy.
int getId() const
Return the candidate&#39;s unique ID.
Definition: SpatialCell.h:109
VariancePtr _varianceEstimate
Estimate of the local variance.
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
double getDouble(const std::string &name) const
Definition: Policy.h:617
MaskedImagePtr _templateMaskedImage
Subimage around which you build kernel.
bool _useRegularization
Use regularization?
boost::shared_ptr< StaticKernelSolution< PixelT > > _kernelSolutionPca
Most recent solution.
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 100 of file KernelCandidate.cc.

102  {
103  build(basisList, boost::shared_ptr<Eigen::MatrixXd>());
104  }
void build(afw::math::KernelList const &basisList)
Core functionality of KernelCandidate, to build and fill a KernelSolution.
template<typename PixelT >
void lsst::ip::diffim::KernelCandidate< PixelT >::build ( afw::math::KernelList const &  basisList,
boost::shared_ptr< Eigen::MatrixXd >  hMat 
)

Definition at line 107 of file KernelCandidate.cc.

110  {
111 
112  /* Examine the policy for control over the variance estimate */
115  /* Variance estimate comes from sum of image variances */
116  var += (*(_templateMaskedImage->getVariance()));
117 
118  if (_policy.getBool("constantVarianceWeighting")) {
119  /* Constant variance weighting */
121  float varValue;
122  if (varStats.getValue(afwMath::MEDIAN) <= 0.0)
123  varValue = 1.0;
124  else
125  varValue = varStats.getValue(afwMath::MEDIAN);
126  pexLog::TTrace<5>("lsst.ip.diffim.KernelCandidate",
127  "Candidate %d using constant variance of %.2f", this->getId(), varValue);
128  var = varValue;
129 
130  }
131 
133 
134  try {
135  _buildKernelSolution(basisList, hMat);
136  } catch (pexExcept::Exception &e) {
137  throw e;
138  }
139 
140  if (_policy.getBool("iterateSingleKernel") && (!(_policy.getBool("constantVarianceWeighting")))) {
142  _varianceEstimate = diffim.getVariance();
143 
144  try {
145  _buildKernelSolution(basisList, hMat);
146  } catch (pexExcept::Exception &e) {
147  throw e;
148  }
149  }
150 
151  _isInitialized = true;
152 
153  }
bool _isInitialized
Has the kernel been built.
MaskedImagePtr _scienceMaskedImage
Subimage around which you build kernel.
void _buildKernelSolution(afw::math::KernelList const &basisList, boost::shared_ptr< Eigen::MatrixXd > hMat)
bool getBool(const std::string &name) const
Definition: Policy.h:589
afw::image::MaskedImage< PixelT > getDifferenceImage(CandidateSwitch cand)
Calculate associated difference image using internal solutions.
VariancePtr getVariance(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage&#39;s variance.
Definition: MaskedImage.h:890
double getValue(Property const prop=NOTHING) const
Return the value of the desired property (if specified in the constructor)
Definition: Statistics.cc:1009
estimate sample median
Definition: Statistics.h:70
pex::policy::Policy _policy
Policy.
int getId() const
Return the candidate&#39;s unique ID.
Definition: SpatialCell.h:109
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:77
VariancePtr _varianceEstimate
Estimate of the local variance.
MaskedImagePtr _templateMaskedImage
Subimage around which you build kernel.
Statistics makeStatistics(afwImage::Mask< afwImage::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl)
Specialization to handle Masks.
Definition: Statistics.cc:1082
A class to represent a 2-dimensional array of pixels.
Definition: Image.h:415
boost::shared_ptr< afw::image::Image< afw::image::VariancePixel > > VariancePtr
template<typename PixelT >
double lsst::ip::diffim::KernelCandidate< PixelT >::getBackground ( CandidateSwitch  cand) const

Definition at line 287 of file KernelCandidate.cc.

287  {
288  if (cand == KernelCandidate::ORIG) {
290  return _kernelSolutionOrig->getBackground();
291  else
292  throw LSST_EXCEPT(pexExcept::Exception, "Original kernel does not exist");
293  }
294  else if (cand == KernelCandidate::PCA) {
295  if (_kernelSolutionPca)
296  return _kernelSolutionPca->getBackground();
297  else
298  throw LSST_EXCEPT(pexExcept::Exception, "Pca kernel does not exist");
299  }
300  else if (cand == KernelCandidate::RECENT) {
301  if (_kernelSolutionPca)
302  return _kernelSolutionPca->getBackground();
303  else if (_kernelSolutionOrig)
304  return _kernelSolutionOrig->getBackground();
305  else
306  throw LSST_EXCEPT(pexExcept::Exception, "No kernels exist");
307  }
308  else {
309  throw LSST_EXCEPT(pexExcept::Exception, "Invalid CandidateSwitch, cannot get background");
310  }
311  }
boost::shared_ptr< StaticKernelSolution< PixelT > > _kernelSolutionOrig
Original basis solution.
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
boost::shared_ptr< StaticKernelSolution< PixelT > > _kernelSolutionPca
Most recent solution.
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::SpatialCellCandidate.

Definition at line 95 of file KernelCandidate.h.

95 { return _coreFlux; }
double _coreFlux
Mean S/N in the science image.
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 402 of file KernelCandidate.cc.

403  {
404  if (cand == KernelCandidate::ORIG) {
406  return getDifferenceImage(_kernelSolutionOrig->getKernel(),
407  _kernelSolutionOrig->getBackground());
408  else
409  throw LSST_EXCEPT(pexExcept::Exception, "Original kernel does not exist");
410  }
411  else if (cand == KernelCandidate::PCA) {
412  if (_kernelSolutionPca)
413  return getDifferenceImage(_kernelSolutionPca->getKernel(),
414  _kernelSolutionPca->getBackground());
415  else
416  throw LSST_EXCEPT(pexExcept::Exception, "Pca kernel does not exist");
417  }
418  else if (cand == KernelCandidate::RECENT) {
419  if (_kernelSolutionPca)
420  return getDifferenceImage(_kernelSolutionPca->getKernel(),
421  _kernelSolutionPca->getBackground());
422  else if (_kernelSolutionOrig)
423  return getDifferenceImage(_kernelSolutionOrig->getKernel(),
424  _kernelSolutionOrig->getBackground());
425  else
426  throw LSST_EXCEPT(pexExcept::Exception, "No kernels exist");
427  }
428  else {
429  throw LSST_EXCEPT(pexExcept::Exception, "Invalid CandidateSwitch, cannot get diffim");
430  }
431  }
boost::shared_ptr< StaticKernelSolution< PixelT > > _kernelSolutionOrig
Original basis solution.
afw::image::MaskedImage< PixelT > getDifferenceImage(CandidateSwitch cand)
Calculate associated difference image using internal solutions.
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
boost::shared_ptr< StaticKernelSolution< PixelT > > _kernelSolutionPca
Most recent solution.
template<typename PixelT >
lsst::afw::image::MaskedImage< PixelT > lsst::ip::diffim::KernelCandidate< PixelT >::getDifferenceImage ( afw::math::Kernel::Ptr  kernel,
double  background 
)

Calculate associated difference image using input kernel and background.

Note
Useful for spatial modeling

Definition at line 434 of file KernelCandidate.cc.

437  {
438  /* Make diffim and set chi2 from result */
441  *kernel,
442  background);
443  return diffIm;
444  }
MaskedImagePtr _scienceMaskedImage
Subimage around which you build kernel.
afwImage::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)
Implement fundamental difference imaging step of convolution and subtraction : D = I - (K*T + bg) whe...
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:77
MaskedImagePtr _templateMaskedImage
Subimage around which you build kernel.
template<typename PixelT >
KernelCandidate< PixelT >::ImageT::ConstPtr lsst::ip::diffim::KernelCandidate< PixelT >::getImage ( ) const
virtual

Return the Candidate's Image.

Implements lsst::afw::math::SpatialCellImageCandidate< afw::math::Kernel::Pixel >.

Definition at line 369 of file KernelCandidate.cc.

369  {
371  }
boost::shared_ptr< ImageT > getKernelImage(CandidateSwitch cand) const
template<typename PixelT >
lsst::afw::math::Kernel::Ptr lsst::ip::diffim::KernelCandidate< PixelT >::getKernel ( CandidateSwitch  cand) const

Return results of kernel solution.

Definition at line 260 of file KernelCandidate.cc.

260  {
261  if (cand == KernelCandidate::ORIG) {
263  return _kernelSolutionOrig->getKernel();
264  else
265  throw LSST_EXCEPT(pexExcept::Exception, "Original kernel does not exist");
266  }
267  else if (cand == KernelCandidate::PCA) {
268  if (_kernelSolutionPca)
269  return _kernelSolutionPca->getKernel();
270  else
271  throw LSST_EXCEPT(pexExcept::Exception, "Pca kernel does not exist");
272  }
273  else if (cand == KernelCandidate::RECENT) {
274  if (_kernelSolutionPca)
275  return _kernelSolutionPca->getKernel();
276  else if (_kernelSolutionOrig)
277  return _kernelSolutionOrig->getKernel();
278  else
279  throw LSST_EXCEPT(pexExcept::Exception, "No kernels exist");
280  }
281  else {
282  throw LSST_EXCEPT(pexExcept::Exception, "Invalid CandidateSwitch, cannot get kernel");
283  }
284  }
boost::shared_ptr< StaticKernelSolution< PixelT > > _kernelSolutionOrig
Original basis solution.
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
boost::shared_ptr< StaticKernelSolution< PixelT > > _kernelSolutionPca
Most recent solution.
template<typename PixelT >
KernelCandidate< PixelT >::ImageT::Ptr lsst::ip::diffim::KernelCandidate< PixelT >::getKernelImage ( CandidateSwitch  cand) const

Definition at line 341 of file KernelCandidate.cc.

342  {
343  if (cand == KernelCandidate::ORIG) {
345  return _kernelSolutionOrig->makeKernelImage();
346  else
347  throw LSST_EXCEPT(pexExcept::Exception, "Original kernel does not exist");
348  }
349  else if (cand == KernelCandidate::PCA) {
350  if (_kernelSolutionPca)
351  return _kernelSolutionPca->makeKernelImage();
352  else
353  throw LSST_EXCEPT(pexExcept::Exception, "Pca kernel does not exist");
354  }
355  else if (cand == KernelCandidate::RECENT) {
356  if (_kernelSolutionPca)
357  return _kernelSolutionPca->makeKernelImage();
358  else if (_kernelSolutionOrig)
359  return _kernelSolutionOrig->makeKernelImage();
360  else
361  throw LSST_EXCEPT(pexExcept::Exception, "No kernels exist");
362  }
363  else {
364  throw LSST_EXCEPT(pexExcept::Exception, "Invalid CandidateSwitch, cannot get kernel image");
365  }
366  }
boost::shared_ptr< StaticKernelSolution< PixelT > > _kernelSolutionOrig
Original basis solution.
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
boost::shared_ptr< StaticKernelSolution< PixelT > > _kernelSolutionPca
Most recent solution.
template<typename PixelT >
boost::shared_ptr< StaticKernelSolution< PixelT > > lsst::ip::diffim::KernelCandidate< PixelT >::getKernelSolution ( CandidateSwitch  cand) const

Definition at line 374 of file KernelCandidate.cc.

375  {
376  if (cand == KernelCandidate::ORIG) {
378  return _kernelSolutionOrig;
379  else
380  throw LSST_EXCEPT(pexExcept::Exception, "Original kernel does not exist");
381  }
382  else if (cand == KernelCandidate::PCA) {
383  if (_kernelSolutionPca)
384  return _kernelSolutionPca;
385  else
386  throw LSST_EXCEPT(pexExcept::Exception, "Pca kernel does not exist");
387  }
388  else if (cand == KernelCandidate::RECENT) {
389  if (_kernelSolutionPca)
390  return _kernelSolutionPca;
391  else if (_kernelSolutionOrig)
392  return _kernelSolutionOrig;
393  else
394  throw LSST_EXCEPT(pexExcept::Exception, "No kernels exist");
395  }
396  else {
397  throw LSST_EXCEPT(pexExcept::Exception, "Invalid CandidateSwitch, cannot get solution");
398  }
399  }
boost::shared_ptr< StaticKernelSolution< PixelT > > _kernelSolutionOrig
Original basis solution.
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
boost::shared_ptr< StaticKernelSolution< PixelT > > _kernelSolutionPca
Most recent solution.
template<typename PixelT >
double lsst::ip::diffim::KernelCandidate< PixelT >::getKsum ( CandidateSwitch  cand) const

Definition at line 314 of file KernelCandidate.cc.

314  {
315  if (cand == KernelCandidate::ORIG) {
317  return _kernelSolutionOrig->getKsum();
318  else
319  throw LSST_EXCEPT(pexExcept::Exception, "Original kernel does not exist");
320  }
321  else if (cand == KernelCandidate::PCA) {
322  if (_kernelSolutionPca)
323  return _kernelSolutionPca->getKsum();
324  else
325  throw LSST_EXCEPT(pexExcept::Exception, "Pca kernel does not exist");
326  }
327  else if (cand == KernelCandidate::RECENT) {
328  if (_kernelSolutionPca)
329  return _kernelSolutionPca->getKsum();
330  else if (_kernelSolutionOrig)
331  return _kernelSolutionOrig->getKsum();
332  else
333  throw LSST_EXCEPT(pexExcept::Exception, "No kernels exist");
334  }
335  else {
336  throw LSST_EXCEPT(pexExcept::Exception, "Invalid CandidateSwitch, cannot get kSum");
337  }
338  }
boost::shared_ptr< StaticKernelSolution< PixelT > > _kernelSolutionOrig
Original basis solution.
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
boost::shared_ptr< StaticKernelSolution< PixelT > > _kernelSolutionPca
Most recent solution.
template<typename _PixelT>
MaskedImagePtr lsst::ip::diffim::KernelCandidate< _PixelT >::getScienceMaskedImage ( )
inline

Definition at line 104 of file KernelCandidate.h.

104 {return _scienceMaskedImage;}
MaskedImagePtr _scienceMaskedImage
Subimage around which you build kernel.
template<typename _PixelT>
SourcePtr lsst::ip::diffim::KernelCandidate< _PixelT >::getSource ( ) const
inline

Return the original source.

Definition at line 99 of file KernelCandidate.h.

99 { return _source; }
template<typename _PixelT>
MaskedImagePtr lsst::ip::diffim::KernelCandidate< _PixelT >::getTemplateMaskedImage ( )
inline

Return pointers to the image pixels used in kernel determination.

Definition at line 103 of file KernelCandidate.h.

103 {return _templateMaskedImage;}
MaskedImagePtr _templateMaskedImage
Subimage around which you build kernel.
template<typename _PixelT>
bool lsst::ip::diffim::KernelCandidate< _PixelT >::isInitialized ( ) const
inline

Definition at line 132 of file KernelCandidate.h.

132 {return _isInitialized;}
bool _isInitialized
Has the kernel been built.

Member Data Documentation

template<typename _PixelT>
double lsst::ip::diffim::KernelCandidate< _PixelT >::_coreFlux
private

Mean S/N in the science image.

Definition at line 195 of file KernelCandidate.h.

template<typename _PixelT>
bool lsst::ip::diffim::KernelCandidate< _PixelT >::_fitForBackground
private

Definition at line 198 of file KernelCandidate.h.

template<typename _PixelT>
bool lsst::ip::diffim::KernelCandidate< _PixelT >::_isInitialized
private

Has the kernel been built.

Definition at line 196 of file KernelCandidate.h.

template<typename _PixelT>
boost::shared_ptr<StaticKernelSolution<PixelT> > lsst::ip::diffim::KernelCandidate< _PixelT >::_kernelSolutionOrig
private

Original basis solution.

Definition at line 201 of file KernelCandidate.h.

template<typename _PixelT>
boost::shared_ptr<StaticKernelSolution<PixelT> > lsst::ip::diffim::KernelCandidate< _PixelT >::_kernelSolutionPca
private

Most recent solution.

Definition at line 204 of file KernelCandidate.h.

template<typename _PixelT>
pex::policy::Policy lsst::ip::diffim::KernelCandidate< _PixelT >::_policy
private

Policy.

Definition at line 193 of file KernelCandidate.h.

template<typename _PixelT>
MaskedImagePtr lsst::ip::diffim::KernelCandidate< _PixelT >::_scienceMaskedImage
private

Subimage around which you build kernel.

Definition at line 191 of file KernelCandidate.h.

template<typename _PixelT>
SourcePtr lsst::ip::diffim::KernelCandidate< _PixelT >::_source
private

Definition at line 194 of file KernelCandidate.h.

template<typename _PixelT>
MaskedImagePtr lsst::ip::diffim::KernelCandidate< _PixelT >::_templateMaskedImage
private

Subimage around which you build kernel.

Definition at line 190 of file KernelCandidate.h.

template<typename _PixelT>
bool lsst::ip::diffim::KernelCandidate< _PixelT >::_useRegularization
private

Use regularization?

Definition at line 197 of file KernelCandidate.h.

template<typename _PixelT>
VariancePtr lsst::ip::diffim::KernelCandidate< _PixelT >::_varianceEstimate
private

Estimate of the local variance.

Definition at line 192 of file KernelCandidate.h.


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