LSSTApplications  18.1.0
LSSTDataManagementBasePackage
Public Member Functions | Static Public Member Functions | List of all members
lsst::meas::extensions::photometryKron::KronAperture Class Reference

#include <photometryKron.h>

Public Member Functions

 KronAperture (afw::geom::Point2D const &center, afw::geom::ellipses::BaseCore const &core, float radiusForRadius=std::nanf(""))
 
 KronAperture (afw::table::SourceRecord const &source, float radiusForRadius=std::nanf(""))
 
 KronAperture (afw::table::SourceRecord const &reference, afw::geom::AffineTransform const &refToMeas, double radius, float radiusForRadius=std::nanf(""))
 
double getX () const
 Accessors. More...
 
double getY () const
 
float getRadiusForRadius () const
 
afw::geom::Point2D const & getCenter () const
 
afw::geom::ellipses::AxesgetAxes ()
 
afw::geom::ellipses::Axes const & getAxes () const
 
template<typename ImageT >
std::pair< double, double > measureFlux (ImageT const &image, double const nRadiusForFlux, double const maxSincRadius) const
 Photometer within the Kron Aperture on an image. More...
 
boost::shared_ptr< KronAperturetransform (afw::geom::AffineTransform const &trans) const
 Transform a Kron Aperture to a different frame. More...
 

Static Public Member Functions

template<typename ImageT >
static boost::shared_ptr< KronAperturedetermineRadius (ImageT const &image, afw::geom::ellipses::Axes axes, afw::geom::Point2D const &center, KronFluxControl const &ctrl)
 Determine the Kron Aperture from an image. More...
 
static afw::geom::ellipses::Axes getKronAxes (afw::geom::ellipses::Axes const &shape, afw::geom::LinearTransform const &transformation, double const radius)
 Determine Kron axes from a reference image. More...
 

Detailed Description

Definition at line 159 of file photometryKron.h.

Constructor & Destructor Documentation

◆ KronAperture() [1/3]

lsst::meas::extensions::photometryKron::KronAperture::KronAperture ( afw::geom::Point2D const &  center,
afw::geom::ellipses::BaseCore const &  core,
float  radiusForRadius = std::nanf("") 
)
inline

Definition at line 161 of file photometryKron.h.

162  :
163  _center(center),
164  _axes(core),
165  _radiusForRadius(radiusForRadius)
166  {}

◆ KronAperture() [2/3]

lsst::meas::extensions::photometryKron::KronAperture::KronAperture ( afw::table::SourceRecord const &  source,
float  radiusForRadius = std::nanf("") 
)
inlineexplicit

Definition at line 168 of file photometryKron.h.

168  :
169  _center(afw::geom::Point2D(source.getX(), source.getY())),
170  _axes(source.getShape()),
171  _radiusForRadius(radiusForRadius)
172  {}
Point< double, 2 > Point2D
Definition: Point.h:324
const char * source()
Source function that allows astChannel to source from a Stream.
Definition: Stream.h:224

◆ KronAperture() [3/3]

lsst::meas::extensions::photometryKron::KronAperture::KronAperture ( afw::table::SourceRecord const &  reference,
afw::geom::AffineTransform const &  refToMeas,
double  radius,
float  radiusForRadius = std::nanf("") 
)
inline

Definition at line 174 of file photometryKron.h.

175  :
176  _center(refToMeas(reference.getCentroid())),
177  _axes(getKronAxes(reference.getShape(), refToMeas.getLinear(), radius)),
178  _radiusForRadius(radiusForRadius)
179  {}
static afw::geom::ellipses::Axes getKronAxes(afw::geom::ellipses::Axes const &shape, afw::geom::LinearTransform const &transformation, double const radius)
Determine Kron axes from a reference image.

Member Function Documentation

◆ determineRadius()

template<typename ImageT >
boost::shared_ptr< KronAperture > lsst::meas::extensions::photometryKron::KronAperture::determineRadius ( ImageT const &  image,
afw::geom::ellipses::Axes  axes,
afw::geom::Point2D const &  center,
KronFluxControl const &  ctrl 
)
static

Determine the Kron Aperture from an image.

Determines the object Kron aperture, using the shape from source.getShape() (e.g. SDSS's adaptive moments)

Parameters
imageImage to measure
axesShape of aperture
centerCentre of source
ctrlcontrol the algorithm

Definition at line 233 of file KronPhotometry.cc.

239 {
240  //
241  // We might smooth the image because this is what SExtractor and Pan-STARRS do. But I don't see much gain
242  //
243  double const sigma = ctrl.smoothingSigma; // Gaussian width of smoothing sigma to apply
244  bool const smoothImage = sigma > 0;
245  int kSize = smoothImage ? 2*int(2*sigma) + 1 : 1;
246  afw::math::GaussianFunction1<afw::math::Kernel::Pixel> gaussFunc(smoothImage ? sigma : 100);
247  afw::math::SeparableKernel kernel(kSize, kSize, gaussFunc, gaussFunc);
248  bool const doNormalize = true, doCopyEdge = false;
249  afw::math::ConvolutionControl convCtrl(doNormalize, doCopyEdge);
250  double radius0 = axes.getDeterminantRadius();
251  double radius = std::numeric_limits<double>::quiet_NaN();
252  float radiusForRadius = std::nanf("");
253  for (int i = 0; i < ctrl.nIterForRadius; ++i) {
254  axes.scale(ctrl.nSigmaForRadius);
255  radiusForRadius = axes.getDeterminantRadius(); // radius we used to estimate R_K
256  //
257  // Build an elliptical Footprint of the proper size
258  //
260  afw::geom::ellipses::Ellipse(axes, center)));
261  afw::geom::Box2I bbox = !smoothImage ?
262  foot.getBBox() :
263  kernel.growBBox(foot.getBBox()); // the smallest bbox needed to convolve with Kernel
264  bbox.clip(image.getBBox());
265  ImageT subImage(image, bbox, afw::image::PARENT, smoothImage);
266  if (smoothImage) {
267  afw::math::convolve(subImage, ImageT(image, bbox, afw::image::PARENT, false), kernel, convCtrl);
268  }
269  //
270  // Find the desired first moment of the elliptical radius, which corresponds to the major axis.
271  //
272  FootprintFindMoment<ImageT, afw::detection::Psf::Image> iRFunctor(
273  subImage, center, axes.getA()/axes.getB(), axes.getTheta()
274  );
275 
276  try {
277  foot.getSpans()->applyFunctor(
278  iRFunctor, *(subImage.getImage()));
280  if (i == 0) {
281  LSST_EXCEPT_ADD(e, "Determining Kron aperture");
282  }
283  break; // use the radius we have
284  }
285 
286  if (!iRFunctor.getGood()) {
287  throw LSST_EXCEPT(BadKronException, "Bad integral defining Kron radius");
288  }
289 
290  radius = iRFunctor.getIr()*sqrt(axes.getB()/axes.getA());
291  if (radius <= radius0) {
292  break;
293  }
294  radius0 = radius;
295 
296  axes.scale(radius/axes.getDeterminantRadius()); // set axes to our current estimate of R_K
297  iRFunctor.reset();
298  }
299 
300  return std::make_shared<KronAperture>(center, axes, radiusForRadius);
301 }
static std::shared_ptr< geom::SpanSet > fromShape(int r, Stencil s=Stencil::CIRCLE, lsst::geom::Point2I offset=lsst::geom::Point2I())
Factory function for creating SpanSets from a Stencil.
Definition: SpanSet.cc:689
afw::table::Key< double > sigma
Definition: GaussianPsf.cc:50
void convolve(OutImageT &convolvedImage, InImageT const &inImage, KernelT const &kernel, ConvolutionControl const &convolutionControl=ConvolutionControl())
Convolve an Image or MaskedImage with a Kernel, setting pixels of an existing output image...
table::Box2IKey bbox
Definition: Detector.cc:169
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
Reports attempts to access elements outside a valid range of indices.
Definition: Runtime.h:89
lsst::afw::detection::Footprint Footprint
Definition: Source.h:61
T nanf(T... args)
T quiet_NaN(T... args)
T sqrt(T... args)
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects...
#define LSST_EXCEPT_ADD(e, m)
Add the current location and a message to an existing exception before rethrowing it...
Definition: Exception.h:54

◆ getAxes() [1/2]

afw::geom::ellipses::Axes& lsst::meas::extensions::photometryKron::KronAperture::getAxes ( )
inline

Definition at line 188 of file photometryKron.h.

188 { return _axes; }

◆ getAxes() [2/2]

afw::geom::ellipses::Axes const& lsst::meas::extensions::photometryKron::KronAperture::getAxes ( ) const
inline

Definition at line 190 of file photometryKron.h.

190 { return _axes; }

◆ getCenter()

afw::geom::Point2D const& lsst::meas::extensions::photometryKron::KronAperture::getCenter ( ) const
inline

Definition at line 186 of file photometryKron.h.

186 { return _center; }

◆ getKronAxes()

afw::geom::ellipses::Axes lsst::meas::extensions::photometryKron::KronAperture::getKronAxes ( afw::geom::ellipses::Axes const &  shape,
afw::geom::LinearTransform const &  transformation,
double const  radius 
)
static

Determine Kron axes from a reference image.

Definition at line 221 of file KronPhotometry.cc.

226 {
227  afw::geom::ellipses::Axes axes(shape);
228  axes.scale(radius/axes.getDeterminantRadius());
229  return axes.transform(transformation);
230 }

◆ getRadiusForRadius()

float lsst::meas::extensions::photometryKron::KronAperture::getRadiusForRadius ( ) const
inline

Definition at line 184 of file photometryKron.h.

184 { return _radiusForRadius; }

◆ getX()

double lsst::meas::extensions::photometryKron::KronAperture::getX ( ) const
inline

Accessors.

Definition at line 182 of file photometryKron.h.

182 { return _center.getX(); }

◆ getY()

double lsst::meas::extensions::photometryKron::KronAperture::getY ( ) const
inline

Definition at line 183 of file photometryKron.h.

183 { return _center.getY(); }

◆ measureFlux()

template<typename ImageT >
std::pair< double, double > lsst::meas::extensions::photometryKron::KronAperture::measureFlux ( ImageT const &  image,
double const  nRadiusForFlux,
double const  maxSincRadius 
) const

Photometer within the Kron Aperture on an image.

Parameters
imageImage to measure
nRadiusForFluxKron radius multiplier
maxSincRadiuslargest radius that we use sinc apertyres

Definition at line 345 of file KronPhotometry.cc.

350 {
351  afw::geom::ellipses::Axes axes(getAxes()); // Copy of ellipse core, so we can scale
352  axes.scale(nRadiusForFlux);
353  afw::geom::ellipses::Ellipse const ellip(axes, getCenter());
354 
355  return photometer(image, ellip, maxSincRadius);
356 }
std::pair< double, double > photometer(ImageT const &image, afw::geom::ellipses::Ellipse const &aperture, double const maxSincRadius)
afw::geom::Point2D const & getCenter() const
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects...

◆ transform()

boost::shared_ptr< KronAperture > lsst::meas::extensions::photometryKron::KronAperture::transform ( afw::geom::AffineTransform const &  trans) const
inline

Transform a Kron Aperture to a different frame.

Definition at line 214 of file photometryKron.h.

214  {
215  afw::geom::Point2D const center = trans(getCenter());
216  afw::geom::ellipses::Axes const axes(*getAxes().transform(trans.getLinear()).copy());
217  return std::make_shared<KronAperture>(center, axes);
218  }
T copy(T... args)
afw::geom::Point2D const & getCenter() const
boost::shared_ptr< KronAperture > transform(afw::geom::AffineTransform const &trans) const
Transform a Kron Aperture to a different frame.
Point< double, 2 > Point2D
Definition: Point.h:324

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