22 #define DEBUG_IMAGES 0 53 template<
typename PixelT>
60 _spatialKernel(spatialKernel),
61 _spatialBackground(spatialBackground),
67 _useCoreStats(_policy.getBool(
"useCoreStats")),
68 _coreRadius(_policy.getInt(
"candidateCoreRadius"))
71 template<
typename PixelT>
77 if (kCandidate == NULL) {
79 "Failed to cast SpatialCellCandidate to KernelCandidate");
83 LOGL_DEBUG(
"TRACE2.ip.diffim.AssessSpatialKernelVisitor.processCandidate",
84 "Cannot process candidate %d, continuing", kCandidate->
getId());
88 LOGL_DEBUG(
"TRACE1.ip.diffim.AssessSpatialKernelVisitor.processCandidate",
89 "Processing candidate %d", kCandidate->
getId());
108 kImage.writeFits(str(boost::format(
"askv_k%d.fits") % kCandidate->
getId()));
109 diffim.writeFits(str(boost::format(
"askv_d%d.fits") % kCandidate->
getId()));
119 LOGL_DEBUG(
"TRACE2.ip.diffim.AssessSpatialKernelVisitor.processCandidate",
120 "Unable to calculate imstats for Candidate %d", kCandidate->
getId());
127 LOGL_DEBUG(
"TRACE4.ip.diffim.AssessSpatialKernelVisitor.processCandidate",
128 "Chi2 = %.3f",
_imstats.getVariance());
129 LOGL_DEBUG(
"TRACE4.ip.diffim.AssessSpatialKernelVisitor.processCandidate",
133 LOGL_DEBUG(
"TRACE4.ip.diffim.AssessSpatialKernelVisitor.processCandidate",
134 "Kernel Sum = %.3f", kSum);
135 LOGL_DEBUG(
"TRACE4.ip.diffim.AssessSpatialKernelVisitor.processCandidate",
136 "Background = %.3f", background);
137 LOGL_DEBUG(
"TRACE2.ip.diffim.AssessSpatialKernelVisitor.processCandidate",
138 "Candidate %d resids = %.3f +/- %.3f sigma (%d pix)",
146 if (meanIsNan || rmsIsNan) {
148 LOGL_DEBUG(
"TRACE3.ip.diffim.AssessSpatialKernelVisitor.processCandidate",
149 "Rejecting candidate %d, encountered NaN",
150 kCandidate->
getId());
158 LOGL_DEBUG(
"TRACE3.ip.diffim.AssessSpatialKernelVisitor.processCandidate",
159 "Rejecting candidate %d; bad mean residual : |%.3f| > %.3f",
167 LOGL_DEBUG(
"TRACE3.ip.diffim.AssessSpatialKernelVisitor.processCandidate",
168 "Rejecting candidate %d; bad residual rms : %.3f > %.3f",
176 LOGL_DEBUG(
"TRACE3.ip.diffim.AssessSpatialKernelVisitor.processCandidate",
177 "Spatial kernel OK");
183 LOGL_DEBUG(
"TRACE5.ip.diffim.AssessSpatialKernelVisitor.processCandidate",
184 "Sigma clipping not enabled");
193 LOGL_DEBUG(
"TRACE2.ip.diffim.AssessSpatialKernelVisitor.processCandidate",
194 "Unable to calculate core imstats for Candidate %d",
195 kCandidate->
getId());
199 LOGL_DEBUG(
"TRACE3.ip.diffim.AssessSpatialKernelVisitor.processCandidate",
200 "Candidate %d core resids = %.3f +/- %.3f sigma (%d pix)",
void setStatus(Status status)
int _nProcessed
Number of candidates processed during processCandidate()
Asseses the quality of a candidate given a spatial kernel and background model.
AssessSpatialKernelVisitor(std::shared_ptr< lsst::afw::math::LinearCombinationKernel > spatialKernel, lsst::afw::math::Kernel::SpatialFunctionPtr spatialBackground, lsst::pex::policy::Policy const &policy)
Class stored in SpatialCells for spatial Kernel fitting.
afw::image::MaskedImage< PixelT > getDifferenceImage(CandidateSwitch cand)
Calculate associated difference image using internal solutions.
bool isInitialized() const
#define LOGL_DEBUG(logger, message...)
bool getBool(const std::string &name) const
bool _useCoreStats
Extracted from policy.
int _nRejected
Number of candidates rejected during processCandidate()
std::shared_ptr< lsst::afw::math::LinearCombinationKernel > _spatialKernel
Spatial kernel function.
Class used by SpatialModelCell for spatial Kernel fitting.
ImageStatistics< PixelT > _imstats
To calculate statistics of difference image.
Class to calculate difference image statistics.
double getDouble(const std::string &name) const
#define LSST_EXCEPT(type,...)
void processCandidate(lsst::afw::math::SpatialCellCandidate *candidate)
int _nGood
Number of good candidates remaining.
Declaration of AssessSpatialKernelVisitor.
int _coreRadius
Extracted from policy.
Image Subtraction helper functions.
lsst::pex::policy::Policy _policy
Policy controlling behavior.