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 Member Functions | Private Types | Private Attributes | List of all members
lsst::meas::algorithms::evalChi2Visitor< PixelT > Class Template Reference

A class to pass around to all our PsfCandidates to evaluate the PSF fit's X^2. More...

Inheritance diagram for lsst::meas::algorithms::evalChi2Visitor< PixelT >:
lsst::afw::math::CandidateVisitor

Public Member Functions

 evalChi2Visitor (afwMath::Kernel const &kernel, double lambda)
 
void reset ()
 
void processCandidate (afwMath::SpatialCellCandidate *candidate)
 
double getValue () const
 
- Public Member Functions inherited from lsst::afw::math::CandidateVisitor
 CandidateVisitor ()
 
virtual ~CandidateVisitor ()
 

Private Types

typedef afwImage::Image< PixelT > Image
 
typedef afwImage::MaskedImage
< PixelT > 
MaskedImage
 
typedef afwImage::Exposure
< PixelT > 
Exposure
 
typedef afwImage::Image
< afwMath::Kernel::Pixel
KImage
 

Private Attributes

double _chi2
 
afwMath::Kernel const & _kernel
 
double _lambda
 
KImage::Ptr _kImage
 

Detailed Description

template<typename PixelT>
class lsst::meas::algorithms::evalChi2Visitor< PixelT >

A class to pass around to all our PsfCandidates to evaluate the PSF fit's X^2.

Definition at line 449 of file SpatialModelPsf.cc.

Member Typedef Documentation

template<typename PixelT>
typedef afwImage::Exposure<PixelT> lsst::meas::algorithms::evalChi2Visitor< PixelT >::Exposure
private

Definition at line 452 of file SpatialModelPsf.cc.

template<typename PixelT>
typedef afwImage::Image<PixelT> lsst::meas::algorithms::evalChi2Visitor< PixelT >::Image
private

Definition at line 450 of file SpatialModelPsf.cc.

template<typename PixelT>
typedef afwImage::Image<afwMath::Kernel::Pixel> lsst::meas::algorithms::evalChi2Visitor< PixelT >::KImage
private

Definition at line 454 of file SpatialModelPsf.cc.

template<typename PixelT>
typedef afwImage::MaskedImage<PixelT> lsst::meas::algorithms::evalChi2Visitor< PixelT >::MaskedImage
private

Definition at line 451 of file SpatialModelPsf.cc.

Constructor & Destructor Documentation

template<typename PixelT>
lsst::meas::algorithms::evalChi2Visitor< PixelT >::evalChi2Visitor ( afwMath::Kernel const &  kernel,
double  lambda 
)
inlineexplicit

Definition at line 456 of file SpatialModelPsf.cc.

458  :
460  _chi2(0.0), _kernel(kernel), _lambda(lambda),
461  _kImage(KImage::Ptr(new KImage(kernel.getDimensions()))) {
462  }
afwImage::Image< afwMath::Kernel::Pixel > KImage
boost::shared_ptr< Image< PixelT > > Ptr
Definition: Image.h:418

Member Function Documentation

template<typename PixelT>
double lsst::meas::algorithms::evalChi2Visitor< PixelT >::getValue ( ) const
inline

Definition at line 506 of file SpatialModelPsf.cc.

template<typename PixelT>
void lsst::meas::algorithms::evalChi2Visitor< PixelT >::processCandidate ( afwMath::SpatialCellCandidate candidate)
inlinevirtual

Reimplemented from lsst::afw::math::CandidateVisitor.

Definition at line 469 of file SpatialModelPsf.cc.

469  {
470  PsfCandidate<PixelT> *imCandidate = dynamic_cast<PsfCandidate<PixelT> *>(candidate);
471  if (imCandidate == NULL) {
472  throw LSST_EXCEPT(lsst::pex::exceptions::LogicError,
473  "Failed to cast SpatialCellCandidate to PsfCandidate");
474  }
475 
476  double const xcen = imCandidate->getSource()->getX();
477  double const ycen = imCandidate->getSource()->getY();
478 
479  _kernel.computeImage(*_kImage, true, xcen, ycen);
480  typename MaskedImage::ConstPtr data;
481  try {
482  data = imCandidate->getOffsetImage(WARP_ALGORITHM, WARP_BUFFER);
483  } catch(lsst::pex::exceptions::LengthError &) {
484  return;
485  }
486 
487  try {
488  std::pair<double, double> result = fitKernel(*_kImage, *data, _lambda, false,
489  imCandidate->getSource()->getId());
490 
491  double dchi2 = result.first; // chi^2 from this object
492  double const amp = result.second; // estimate of amplitude of model at this point
493 
494  imCandidate->setChi2(dchi2);
495  imCandidate->setAmplitude(amp);
496 
497  _chi2 += dchi2;
498  } catch(lsst::pex::exceptions::RangeError &e) {
499  imCandidate->setStatus(afwMath::SpatialCellCandidate::BAD);
500  imCandidate->setChi2(std::numeric_limits<double>::quiet_NaN());
501  imCandidate->setAmplitude(std::numeric_limits<double>::quiet_NaN());
502  }
503  }
boost::shared_ptr< const MaskedImage > ConstPtr
Definition: MaskedImage.h:88
double computeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize, double x=0.0, double y=0.0) const
Compute an image (pixellized representation of the kernel) in place.
Definition: Kernel.cc:94
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
template<typename PixelT>
void lsst::meas::algorithms::evalChi2Visitor< PixelT >::reset ( )
inlinevirtual

Reimplemented from lsst::afw::math::CandidateVisitor.

Definition at line 464 of file SpatialModelPsf.cc.

464  {
465  _chi2 = 0.0;
466  }

Member Data Documentation

template<typename PixelT>
double lsst::meas::algorithms::evalChi2Visitor< PixelT >::_chi2
mutableprivate

Definition at line 509 of file SpatialModelPsf.cc.

template<typename PixelT>
afwMath::Kernel const& lsst::meas::algorithms::evalChi2Visitor< PixelT >::_kernel
private

Definition at line 510 of file SpatialModelPsf.cc.

template<typename PixelT>
KImage::Ptr lsst::meas::algorithms::evalChi2Visitor< PixelT >::_kImage
mutableprivate

Definition at line 512 of file SpatialModelPsf.cc.

template<typename PixelT>
double lsst::meas::algorithms::evalChi2Visitor< PixelT >::_lambda
private

Definition at line 511 of file SpatialModelPsf.cc.


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