LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
Classes | Public Types | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
lsst::meas::base::SincCoeffs< PixelT > Class Template Reference

#include <SincCoeffs.h>

Classes

struct  FuzzyCompare
 

Public Types

typedef afw::image::Image< PixelT > CoeffT
 

Static Public Member Functions

static void cache (float rInner, float rOuter)
 
static boost::shared_ptr
< CoeffT const > 
get (afw::geom::ellipses::Axes const &outerEllipse, float const innerRadiusFactor=0.0)
 
static boost::shared_ptr< CoeffTcalculate (afw::geom::ellipses::Axes const &outerEllipse, double const innerFactor=0.0)
 Calculate the coefficients for an aperture. More...
 

Private Types

typedef std::map< float,
boost::shared_ptr< CoeffT >
, FuzzyCompare< float > > 
CoeffMap
 
typedef std::map< float,
CoeffMap, FuzzyCompare< float > > 
CoeffMapMap
 

Private Member Functions

 SincCoeffs ()
 
 SincCoeffs (SincCoeffs const &)
 
void operator= (SincCoeffs const &)
 
boost::shared_ptr< CoeffT const > _lookup (afw::geom::ellipses::Axes const &outerEllipse, double const innerRadiusFactor=0.0) const
 

Static Private Member Functions

static SincCoeffsgetInstance ()
 

Private Attributes

CoeffMapMap _cache
 

Detailed Description

template<typename PixelT>
class lsst::meas::base::SincCoeffs< PixelT >

A singleton to calculate and cache the coefficients for sinc photometry

Caching is only performed for circular apertures (because elliptical apertures are assumed to be generated dynamically, and hence not expected to recur). Caching must be explicitly requested for a particular circular aperture (using the 'cache' method).

Definition at line 43 of file SincCoeffs.h.

Member Typedef Documentation

template<typename PixelT>
typedef std::map<float, boost::shared_ptr< CoeffT >, FuzzyCompare<float> > lsst::meas::base::SincCoeffs< PixelT >::CoeffMap
private

Definition at line 83 of file SincCoeffs.h.

template<typename PixelT>
typedef std::map<float, CoeffMap, FuzzyCompare<float> > lsst::meas::base::SincCoeffs< PixelT >::CoeffMapMap
private

Definition at line 84 of file SincCoeffs.h.

template<typename PixelT>
typedef afw::image::Image<PixelT> lsst::meas::base::SincCoeffs< PixelT >::CoeffT

Definition at line 46 of file SincCoeffs.h.

Constructor & Destructor Documentation

template<typename PixelT>
lsst::meas::base::SincCoeffs< PixelT >::SincCoeffs ( )
inlineprivate

Definition at line 85 of file SincCoeffs.h.

85 : _cache() {};
template<typename PixelT>
lsst::meas::base::SincCoeffs< PixelT >::SincCoeffs ( SincCoeffs< PixelT > const &  )
private

Member Function Documentation

template<typename PixelT >
boost::shared_ptr< typename SincCoeffs< PixelT >::CoeffT const > lsst::meas::base::SincCoeffs< PixelT >::_lookup ( afw::geom::ellipses::Axes const &  outerEllipse,
double const  innerRadiusFactor = 0.0 
) const
private

Definition at line 540 of file SincCoeffs.cc.

541 {
542  if (innerFactor < 0.0 || innerFactor > 1.0) {
543  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
544  (boost::format("innerFactor = %f is not between 0 and 1") % innerFactor).str());
545  }
546 
547  CONST_PTR(typename SincCoeffs<PixelT>::CoeffT) const null = CONST_PTR(SincCoeffs<PixelT>::CoeffT)();
548 
549  // We only cache circular apertures
550  if (!FuzzyCompare<float>().isEqual(axes.getA(), axes.getB())) {
551  return null;
552  }
553  typename CoeffMapMap::const_iterator iter1 = _cache.find(axes.getA());
554  if (iter1 == _cache.end()) {
555  return null;
556  }
557  typename CoeffMap::const_iterator iter2 = iter1->second.find(innerFactor);
558  return (iter2 == iter1->second.end()) ? null : iter2->second;
559 }
#define CONST_PTR(...)
Definition: base.h:47
if(width!=gim.getWidth()||height!=gim.getHeight()||x0!=gim.getX0()||y0!=gim.getY0())
Definition: saturated.cc:47
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
afw::image::Image< PixelT > CoeffT
Definition: SincCoeffs.h:46
template<typename PixelT >
void lsst::meas::base::SincCoeffs< PixelT >::cache ( float  rInner,
float  rOuter 
)
static

Cache the coefficients for a particular aperture

The aperture is a circular annulus.

Definition at line 515 of file SincCoeffs.cc.

516 {
517  if (r1 < 0.0 || r2 < r1) {
518  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
519  (boost::format("Invalid r1,r2 = %f,%f") % r1 % r2).str());
520  }
521  double const innerFactor = r1/r2;
522  afw::geom::ellipses::Axes axes(r2, r2, 0.0);
523  if (!getInstance()._lookup(axes, innerFactor)) {
524  PTR(typename SincCoeffs<PixelT>::CoeffT) coeff = calculate(axes, innerFactor);
525  coeff->markPersistent();
526  getInstance()._cache[r2][innerFactor] = coeff;
527  }
528 }
#define PTR(...)
Definition: base.h:41
static SincCoeffs & getInstance()
Definition: SincCoeffs.cc:508
boost::shared_ptr< CoeffT const > _lookup(afw::geom::ellipses::Axes const &outerEllipse, double const innerRadiusFactor=0.0) const
Definition: SincCoeffs.cc:540
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
static boost::shared_ptr< CoeffT > calculate(afw::geom::ellipses::Axes const &outerEllipse, double const innerFactor=0.0)
Calculate the coefficients for an aperture.
Definition: SincCoeffs.cc:563
template<typename PixelT >
boost::shared_ptr< typename SincCoeffs< PixelT >::CoeffT > lsst::meas::base::SincCoeffs< PixelT >::calculate ( afw::geom::ellipses::Axes const &  outerEllipse,
double const  innerFactor = 0.0 
)
static

Calculate the coefficients for an aperture.

Definition at line 563 of file SincCoeffs.cc.

564 {
565  if (innerFactor < 0.0 || innerFactor > 1.0) {
566  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
567  (boost::format("innerFactor = %f is not between 0 and 1") % innerFactor).str());
568  }
569 
570  // Kspace-real is fastest, but only slightly faster than kspace cplx
571  // but real won't work for elliptical apertures due to symmetries assumed for real transform
572 
573  double const rad1 = axes.getA() * innerFactor;
574  double const rad2 = axes.getA();
575  // if there's no angle and no ellipticity
576  if (FuzzyCompare<float>().isEqual(axes.getA(), axes.getB())) {
577  // here we call the real transform
578  return calcImageKSpaceReal<PixelT>(rad1, rad2);
579  } else {
580  // here we call the complex transform
581  double const ellipticity = 1.0 - axes.getB()/axes.getA();
582  return calcImageKSpaceCplx<PixelT>(rad1, rad2, axes.getTheta(), ellipticity);
583  }
584 }
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
template<typename PixelT >
boost::shared_ptr< typename SincCoeffs< PixelT >::CoeffT const > lsst::meas::base::SincCoeffs< PixelT >::get ( afw::geom::ellipses::Axes const &  outerEllipse,
float const  innerRadiusFactor = 0.0 
)
static

Get the coefficients for an aperture

Coefficients are retrieved from the cache, if available; otherwise they will be generated.

Definition at line 532 of file SincCoeffs.cc.

533 {
534  CONST_PTR(CoeffT) coeff = getInstance()._lookup(axes, innerFactor);
535  return coeff ? coeff : calculate(axes, innerFactor);
536 }
#define CONST_PTR(...)
Definition: base.h:47
static SincCoeffs & getInstance()
Definition: SincCoeffs.cc:508
boost::shared_ptr< CoeffT const > _lookup(afw::geom::ellipses::Axes const &outerEllipse, double const innerRadiusFactor=0.0) const
Definition: SincCoeffs.cc:540
static boost::shared_ptr< CoeffT > calculate(afw::geom::ellipses::Axes const &outerEllipse, double const innerFactor=0.0)
Calculate the coefficients for an aperture.
Definition: SincCoeffs.cc:563
afw::image::Image< PixelT > CoeffT
Definition: SincCoeffs.h:46
template<typename PixelT >
SincCoeffs< PixelT > & lsst::meas::base::SincCoeffs< PixelT >::getInstance ( )
staticprivate

Definition at line 508 of file SincCoeffs.cc.

509 {
510  static SincCoeffs<PixelT> instance;
511  return instance;
512 }
template<typename PixelT>
void lsst::meas::base::SincCoeffs< PixelT >::operator= ( SincCoeffs< PixelT > const &  )
private

Member Data Documentation

template<typename PixelT>
CoeffMapMap lsst::meas::base::SincCoeffs< PixelT >::_cache
private

Definition at line 99 of file SincCoeffs.h.


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