LSST Applications g0265f82a02+0e5473021a,g02d81e74bb+bd2ed33bd6,g1470d8bcf6+c6d6eb38e2,g14a832a312+9d12ad093c,g2079a07aa2+86d27d4dc4,g2305ad1205+91a32aca49,g295015adf3+88246b6574,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g3ddfee87b4+c34e8be1fa,g487adcacf7+85dcfbcc36,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+ea1711114f,g5a732f18d5+53520f316c,g64a986408d+bd2ed33bd6,g858d7b2824+bd2ed33bd6,g8a8a8dda67+585e252eca,g99cad8db69+016a06b37a,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+ef4e3a5875,gb0e22166c9+60f28cb32d,gb6a65358fc+0e5473021a,gba4ed39666+c2a2e4ac27,gbb8dafda3b+b6d7b42999,gc120e1dc64+f745648b3a,gc28159a63d+0e5473021a,gcf0d15dbbd+c34e8be1fa,gdaeeff99f8+f9a426f77a,ge6526c86ff+508d0e0a30,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gf18bd8381d+8d59551888,gf1cff7945b+bd2ed33bd6,w.2024.16
LSST Data Management Base Package
Loading...
Searching...
No Matches
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.
 
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.
 
std::shared_ptr< KronAperturetransform (geom::AffineTransform const &trans) const
 Transform a Kron Aperture to a different frame.
 

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.
 
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.
 

Detailed Description

Definition at line 163 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 165 of file photometryKron.h.

166 :
167 _center(center),
168 _axes(core),
169 _radiusForRadius(radiusForRadius)
170 {}

◆ KronAperture() [2/3]

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

Definition at line 172 of file photometryKron.h.

172 :
173 _center(geom::Point2D(source.getX(), source.getY())),
174 _axes(source.getShape()),
175 _radiusForRadius(radiusForRadius)
176 {}
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 178 of file photometryKron.h.

179 :
180 _center(refToMeas(reference.getCentroid())),
181 _axes(getKronAxes(reference.getShape(), refToMeas.getLinear(), radius)),
182 _radiusForRadius(radiusForRadius)
183 {}
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 //
260 afw::detection::Footprint foot(afw::geom::SpanSet::fromShape(
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
299 if (radius > ctrl.maxRadius) {
300 throw LSST_EXCEPT(BadKronException, "Kron radius too large");
301 }
302
303 iRFunctor.reset();
304 }
305
306 return std::make_shared<KronAperture>(center, axes, radiusForRadius);
307}
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
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
void clip(Box2I const &other) noexcept
Shrink this to ensure that other.contains(*this).
Definition Box.cc:189
Reports attempts to access elements outside a valid range of indices.
Definition Runtime.h:89
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.
T nanf(T... args)
T quiet_NaN(T... args)

◆ getAxes() [1/2]

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

Definition at line 192 of file photometryKron.h.

192{ return _axes; }

◆ getAxes() [2/2]

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

Definition at line 194 of file photometryKron.h.

194{ return _axes; }

◆ getCenter()

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

Definition at line 190 of file photometryKron.h.

190{ 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 188 of file photometryKron.h.

188{ return _radiusForRadius; }

◆ getX()

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

Accessors.

Definition at line 186 of file photometryKron.h.

186{ return _center.getX(); }

◆ getY()

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

Definition at line 187 of file photometryKron.h.

187{ 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 351 of file KronPhotometry.cc.

356{
357 afw::geom::ellipses::Axes axes(getAxes()); // Copy of ellipse core, so we can scale
358 axes.scale(nRadiusForFlux);
359 afw::geom::ellipses::Ellipse const ellip(axes, getCenter());
360
361 return photometer(image, ellip, maxSincRadius);
362}
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 218 of file photometryKron.h.

218 {
219 geom::Point2D const center = trans(getCenter());
220 afw::geom::ellipses::Axes const axes(*getAxes().transform(trans.getLinear()).copy());
221 return std::make_shared<KronAperture>(center, axes);
222 }
table::Key< int > transform

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