LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
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 (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, geom::AffineTransform const &refToMeas, double radius, float radiusForRadius=std::nanf(""))
 
double getX () const
 Accessors. More...
 
double getY () const
 
float getRadiusForRadius () const
 
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...
 
std::shared_ptr< KronAperturetransform (geom::AffineTransform const &trans) const
 Transform a Kron Aperture to a different frame. More...
 

Static Public Member Functions

template<typename ImageT >
static std::shared_ptr< KronAperturedetermineRadius (ImageT const &image, afw::geom::ellipses::Axes axes, 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, geom::LinearTransform const &transformation, double const radius)
 Determine Kron axes from a reference image. More...
 

Detailed Description

Definition at line 160 of file photometryKron.h.

Constructor & Destructor Documentation

◆ KronAperture() [1/3]

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

Definition at line 162 of file photometryKron.h.

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

◆ KronAperture() [2/3]

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

Definition at line 169 of file photometryKron.h.

169  :
170  _center(geom::Point2D(source.getX(), source.getY())),
171  _axes(source.getShape()),
172  _radiusForRadius(radiusForRadius)
173  {}
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,
geom::AffineTransform const &  refToMeas,
double  radius,
float  radiusForRadius = std::nanf("") 
)
inline

Definition at line 175 of file photometryKron.h.

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

Member Function Documentation

◆ determineRadius()

template<typename ImageT >
std::shared_ptr< KronAperture > lsst::meas::extensions::photometryKron::KronAperture::determineRadius ( ImageT const &  image,
afw::geom::ellipses::Axes  axes,
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 234 of file KronPhotometry.cc.

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

◆ getAxes() [1/2]

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

Definition at line 189 of file photometryKron.h.

189 { return _axes; }

◆ getAxes() [2/2]

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

Definition at line 191 of file photometryKron.h.

191 { return _axes; }

◆ getCenter()

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

Definition at line 187 of file photometryKron.h.

187 { return _center; }

◆ getKronAxes()

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

Determine Kron axes from a reference image.

Definition at line 222 of file KronPhotometry.cc.

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

◆ getRadiusForRadius()

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

Definition at line 185 of file photometryKron.h.

185 { return _radiusForRadius; }

◆ getX()

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

Accessors.

Definition at line 183 of file photometryKron.h.

183 { return _center.getX(); }

◆ getY()

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

Definition at line 184 of file photometryKron.h.

184 { 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 346 of file KronPhotometry.cc.

351 {
352  afw::geom::ellipses::Axes axes(getAxes()); // Copy of ellipse core, so we can scale
353  axes.scale(nRadiusForFlux);
354  afw::geom::ellipses::Ellipse const ellip(axes, getCenter());
355 
356  return photometer(image, ellip, maxSincRadius);
357 }
std::pair< double, double > photometer(ImageT const &image, afw::geom::ellipses::Ellipse const &aperture, double const maxSincRadius)

◆ transform()

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

Transform a Kron Aperture to a different frame.

Definition at line 215 of file photometryKron.h.

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

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