12 #include "boost/timer.hpp" 32 template <
typename PixelT>
40 lsst::afw::math::SpatialCellImageCandidate(xCenter, yCenter),
41 _templateMaskedImage(templateMaskedImage),
42 _scienceMaskedImage(scienceMaskedImage),
47 _isInitialized(false),
48 _useRegularization(false),
49 _fitForBackground(_policy.getBool(
"fitForBackground")),
50 _kernelSolutionOrig(),
56 int candidateCoreRadius =
_policy.
getInt(
"candidateCoreRadius");
61 "Unable to calculate core imstats for ranking Candidate %d", this->
getId());
68 "Candidate %d at %.2f %.2f with ranking %.2f",
72 template <
typename PixelT>
93 "Candidate %d at %.2f %.2f with ranking %.2f",
97 template <
typename PixelT>
101 build(basisList, Eigen::MatrixXd());
104 template <
typename PixelT>
107 Eigen::MatrixXd
const& hMat
120 if (varStats.
getValue(afwMath::MEDIAN) <= 0.0)
123 varValue = varStats.
getValue(afwMath::MEDIAN);
124 LOGL_DEBUG(
"TRACE4.ip.diffim.KernelCandidate",
125 "Candidate %d using constant variance of %.2f", this->
getId(), varValue);
153 template <
typename PixelT>
155 Eigen::MatrixXd
const& hMat)
157 bool checkConditionNumber =
_policy.
getBool(
"checkConditionNumber");
161 if (conditionNumberType ==
"SVD") {
164 else if (conditionNumberType ==
"EIGENVALUE") {
172 if (hMat.size() > 0) {
174 LOGL_DEBUG(
"TRACE4.ip.diffim.KernelCandidate.build",
175 "Using kernel regularization");
184 if (checkConditionNumber) {
186 LOGL_DEBUG(
"TRACE4.ip.diffim.KernelCandidate",
187 "Candidate %d solution has bad condition number",
202 if (checkConditionNumber) {
204 LOGL_DEBUG(
"TRACE4.ip.diffim.KernelCandidate",
205 "Candidate %d solution has bad condition number",
216 LOGL_DEBUG(
"TRACE4.ip.diffim.KernelCandidate.build",
217 "Not using kernel regularization");
225 if (checkConditionNumber) {
227 LOGL_DEBUG(
"TRACE4.ip.diffim.KernelCandidate",
228 "Candidate %d solution has bad condition number",
243 if (checkConditionNumber) {
245 LOGL_DEBUG(
"TRACE4.ip.diffim.KernelCandidate",
246 "Candidate %d solution has bad condition number",
257 template <
typename PixelT>
284 template <
typename PixelT>
311 template <
typename PixelT>
338 template <
typename PixelT>
366 template <
typename PixelT>
371 template <
typename PixelT>
399 template <
typename PixelT>
431 template <
typename PixelT>
VariancePtr getVariance() const
void setStatus(Status status)
bool _isInitialized
Has the kernel been built.
void apply(lsst::afw::image::MaskedImage< PixelT > const &image)
double getBackground(CandidateSwitch cand) const
MaskedImagePtr _scienceMaskedImage
Subimage around which you build kernel.
Class stored in SpatialCells for spatial Kernel fitting.
std::shared_ptr< StaticKernelSolution< PixelT > > _kernelSolutionOrig
Original basis solution.
afw::image::MaskedImage< PixelT > getDifferenceImage(CandidateSwitch cand)
Calculate associated difference image using internal solutions.
Image Subtraction helper functions.
std::shared_ptr< StaticKernelSolution< PixelT > > getKernelSolution(CandidateSwitch cand) const
std::shared_ptr< afw::math::Kernel > getKernel(CandidateSwitch cand) const
Return results of kernel solution.
void build(afw::math::KernelList const &basisList)
Core functionality of KernelCandidate, to build and fill a KernelSolution.
boost::shared_ptr< ImageT > getKernelImage(CandidateSwitch cand) const
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.
#define LOGL_DEBUG(logger, message...)
Declaration of classes to store the solution for convolution kernels.
bool getBool(const std::string &name) const
std::shared_ptr< afw::image::Image< afw::image::VariancePixel > > VariancePtr
pex::policy::Policy _policy
Policy.
SpatialCellImageCandidate(float const xCenter, float const yCenter)
int getInt(const std::string &name) const
VariancePtr _varianceEstimate
Estimate of the local variance.
const std::string getString(const std::string &name) const
Class used by SpatialModelCell for spatial Kernel fitting.
double getValue(Property const prop=NOTHING) const
Class to calculate difference image statistics.
double _coreFlux
Mean S/N in the science image.
double getDouble(const std::string &name) const
#define LSST_EXCEPT(type,...)
boost::shared_ptr< ImageT const > getImage() const
MaskedImagePtr _templateMaskedImage
Subimage around which you build kernel.
bool _useRegularization
Use regularization?
void _buildKernelSolution(afw::math::KernelList const &basisList, Eigen::MatrixXd const &hMat)
KernelCandidate(float const xCenter, float const yCenter, MaskedImagePtr const &templateMaskedImage, MaskedImagePtr const &scienceMaskedImage, pex::policy::Policy const &policy)
Constructor.
Image Subtraction helper functions.
double getKsum(CandidateSwitch cand) const
std::shared_ptr< StaticKernelSolution< PixelT > > _kernelSolutionPca
Most recent solution.