LSST Applications g0b6bd0c080+a72a5dd7e6,g1182afd7b4+2a019aa3bb,g17e5ecfddb+2b8207f7de,g1d67935e3f+06cf436103,g38293774b4+ac198e9f13,g396055baef+6a2097e274,g3b44f30a73+6611e0205b,g480783c3b1+98f8679e14,g48ccf36440+89c08d0516,g4b93dc025c+98f8679e14,g5c4744a4d9+a302e8c7f0,g613e996a0d+e1c447f2e0,g6c8d09e9e7+25247a063c,g7271f0639c+98f8679e14,g7a9cd813b8+124095ede6,g9d27549199+a302e8c7f0,ga1cf026fa3+ac198e9f13,ga32aa97882+7403ac30ac,ga786bb30fb+7a139211af,gaa63f70f4e+9994eb9896,gabf319e997+ade567573c,gba47b54d5d+94dc90c3ea,gbec6a3398f+06cf436103,gc6308e37c7+07dd123edb,gc655b1545f+ade567573c,gcc9029db3c+ab229f5caf,gd01420fc67+06cf436103,gd877ba84e5+06cf436103,gdb4cecd868+6f279b5b48,ge2d134c3d5+cc4dbb2e3f,ge448b5faa6+86d1ceac1d,gecc7e12556+98f8679e14,gf3ee170dca+25247a063c,gf4ac96e456+ade567573c,gf9f5ea5b4d+ac198e9f13,gff490e6085+8c2580be5c,w.2022.27
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: