LSSTApplications  8.0.0.0+107,8.0.0.1+13,9.1+18,9.2,master-g084aeec0a4,master-g0aced2eed8+6,master-g15627eb03c,master-g28afc54ef9,master-g3391ba5ea0,master-g3d0fb8ae5f,master-g4432ae2e89+36,master-g5c3c32f3ec+17,master-g60f1e072bb+1,master-g6a3ac32d1b,master-g76a88a4307+1,master-g7bce1f4e06+57,master-g8ff4092549+31,master-g98e65bf68e,master-ga6b77976b1+53,master-gae20e2b580+3,master-gb584cd3397+53,master-gc5448b162b+1,master-gc54cf9771d,master-gc69578ece6+1,master-gcbf758c456+22,master-gcec1da163f+63,master-gcf15f11bcc,master-gd167108223,master-gf44c96c709
LSSTDataManagementBasePackage
Classes | Functions
lsst::meas::algorithms::photometry Namespace Reference

Classes

struct  fuzzyCompare
 
class  SincCoeffs
 

Functions

template<typename MaskedImageT >
std::pair< double, double > calculateSincApertureFlux (MaskedImageT const &mimage, afw::geom::ellipses::Ellipse const &ellipse, double const innerFactor)
 

Function Documentation

template<typename MaskedImageT >
std::pair< double, double > lsst::meas::algorithms::photometry::calculateSincApertureFlux ( MaskedImageT const &  mimage,
afw::geom::ellipses::Ellipse const &  ellipse,
double const  innerFactor 
)

Workhorse routine to calculate elliptical aperture fluxes

Calculate the flux in an elliptical annulus

The outer boundary is defined by an ellipse, while the inner boundary is a scaled version of the outer ellipse.

Parameters
mimageImage to measure
ellipseOuter aperture
innerFactorScale to apply to ellipse for inner boundary

Definition at line 687 of file SincFlux.cc.

689 {
690  double flux = std::numeric_limits<double>::quiet_NaN();
691  double fluxErr = std::numeric_limits<double>::quiet_NaN();
692 
693  typedef typename MaskedImageT::Image Image;
694  typedef typename Image::Pixel Pixel;
695  typedef typename Image::Ptr ImagePtr;
696 
697  // BBox for data image
698  afwGeom::BoxI imageBBox(mimage.getBBox());
699 
700 
701  // make the coeff image
702  // compute c_i as double integral over aperture def g_i(), and sinc()
703  CONST_PTR(Image) cimage0 = SincCoeffs<Pixel>::get(ellipse.getCore(), innerFactor);
704 
705  // as long as we're asked for the same radius, we don't have to recompute cimage0
706  // shift to center the aperture on the object being measured
707  ImagePtr cimage = afwMath::offsetImage(*cimage0, ellipse.getCenter().getX(), ellipse.getCenter().getY());
708  afwGeom::BoxI bbox(cimage->getBBox());
709 #if 0
710  // I (Steve Bickerton) think this should work, but doesn't.
711  // For the time being, I'll do the bounds check here
712  // ... should determine why bbox/image behaviour not as expected.
713  afwGeom::BoxI mbbox(mimage.getBBox());
714  bbox.clip(mbbox);
715  afwGeom::Point2I cimXy0(cimage->getXY0());
716  bbox.shift(-cimage->getX0(), -cimage->getY0());
717  cimage = typename Image::Ptr(new Image(*cimage, bbox, false));
718  cimage->setXY0(cimXy0);
719 #else
720  int x1 = (cimage->getX0() < mimage.getX0()) ? mimage.getX0() : cimage->getX0();
721  int y1 = (cimage->getY0() < mimage.getY0()) ? mimage.getY0() : cimage->getY0();
722  int x2 = (cimage->getX0() + cimage->getWidth() > mimage.getX0() + mimage.getWidth()) ?
723  mimage.getX0() + mimage.getWidth() - 1 : cimage->getX0() + cimage->getWidth() - 1;
724  int y2 = (cimage->getY0() + cimage->getHeight() > mimage.getY0() + mimage.getHeight()) ?
725  mimage.getY0() + mimage.getHeight() - 1 : cimage->getY0() + cimage->getHeight() - 1;
726 
727  // if the dimensions changed, put the image in a smaller bbox
728  if ( (x2 - x1 + 1 != cimage->getWidth()) || (y2 - y1 + 1 != cimage->getHeight()) ) {
729  bbox = afwGeom::BoxI(afwGeom::Point2I(x1 - cimage->getX0(), y1 - cimage->getY0()),
730  afwGeom::Extent2I(x2 - x1 + 1, y2 - y1 + 1));
731  cimage = ImagePtr(new Image(*cimage, bbox, afwImage::LOCAL, false));
732 
733  // shift back to correct place
734  cimage = afwMath::offsetImage(*cimage, x1, y1);
735  bbox = afwGeom::BoxI(afwGeom::Point2I(x1, y1),
736  afwGeom::Extent2I(x2-x1+1, y2-y1+1));
737  }
738 #endif
739 
740  // pass the image and cimage into the wfluxFunctor to do the sum
741  FootprintWeightFlux<MaskedImageT, Image> wfluxFunctor(mimage, cimage);
742 
743  afwDet::Footprint foot(bbox, imageBBox);
744  wfluxFunctor.apply(foot);
745  flux = wfluxFunctor.getSum();
746  fluxErr = ::sqrt(wfluxFunctor.getSumVar());
747 
748  return std::make_pair(flux, fluxErr);
749 }
Box2I BoxI
Definition: Box.h:479
An integer coordinate rectangle.
Definition: Box.h:53
void shift(Extent< T, N > const &offset)
Shift the point by the given offset.
Definition: Point.h:110
#define CONST_PTR(...)
Definition: base.h:47
A set of pixels in an Image.
Definition: Footprint.h:73
ImageT::Ptr offsetImage(ImageT const &image, float dx, float dy, std::string const &algorithmName="lanczos5", unsigned int buffer=0)
Return an image offset by (dx, dy) using the specified algorithm.
Definition: offsetImage.cc:55
void clip(Box2I const &other)
Shrink this to ensure that other.contains(*this).