36 namespace lsst {
namespace meas {
namespace base {
59 enum Method { ADAPTIVE_MOMENT,
69 double computeGaussianWidth(Method how=ADAPTIVE_MOMENT)
const;
70 double computeEffectiveArea()
const;
79 PsfAttributes::PsfAttributes(
92 PsfAttributes::PsfAttributes(
105 double PsfAttributes::computeEffectiveArea()
const {
109 for (
int iY = 0; iY !=
_psfImage->getHeight(); ++iY) {
110 afw::image::Image<double>::x_iterator end =
_psfImage->row_end(iY);
111 for (afw::image::Image<double>::x_iterator ptr =
_psfImage->row_begin(iY); ptr != end; ++ptr) {
113 sumsqr += (*ptr)*(*ptr);
116 return sum*sum/sumsqr;
140 if ((std::abs(fracShift[0]) >= 1) || (std::abs(fracShift[1]) >= 1)) {
141 std::ostringstream os;
142 os <<
"fracShift = " << fracShift <<
" too large; abs value must be < 1 in both axes";
143 throw LSST_EXCEPT(pex::exceptions::RangeError, os.str());
147 if (fracShift[0] < 0) {
148 warpingKernelPtr->setCtrX(warpingKernelPtr->getCtrX() + 1);
150 if (fracShift[1] < 0) {
151 warpingKernelPtr->setCtrY(warpingKernelPtr->getCtrY() + 1);
155 warpingKernelPtr->getDimensions());
157 std::ostringstream os;
158 os <<
"Warping kernel extends off the edge"
159 <<
"; kernel bbox = " << warpingOverlapBBox
160 <<
"; exposure bbox = " << maskedImage.
getBBox();
161 throw LSST_EXCEPT(pex::exceptions::RangeError, os.str());
163 warpingKernelPtr->setKernelParameters(std::make_pair(fracShift[0], fracShift[1]));
164 KernelImageT warpingKernelImage(warpingKernelPtr->getDimensions());
165 warpingKernelPtr->computeImage(warpingKernelImage,
true);
166 typename KernelImageT::const_xy_locator
const warpingKernelLoc = warpingKernelImage.xy_at(0,0);
171 typename MaskedImageT::const_xy_locator
const mimageLoc = maskedImage.
xy_at(subimMin.getX(), subimMin.getY());
172 return afw::math::convolveAtAPoint<MaskedImageT, MaskedImageT>(
173 mimageLoc, warpingKernelLoc, warpingKernelPtr->getWidth(), warpingKernelPtr->getHeight());
175 PeakLikelihoodFluxAlgorithm::PeakLikelihoodFluxAlgorithm(
177 std::string
const &
name,
181 FluxResultKey::addFields(schema, name,
"flux from PeakLikelihood Flux algorithm")
183 _centroidExtractor(schema, name)
185 static boost::array<FlagDefinition,N_FLAGS>
const flagDefs = {{
186 {
"flag",
"general failure flag, set if anything went wrong"}
212 throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
"exposure has no PSF");
216 std::ostringstream os;
217 os <<
"Center = " << center <<
" not in exposure bbox" << mimage.getBBox();
218 throw LSST_EXCEPT(pex::exceptions::RangeError, os.str());
226 afw::geom::Point2I ctrPixParentInd(xCtrPixParentIndFrac.first, yCtrPixParentIndFrac.first);
233 PsfAttributes psfAttr(psfPtr, ctrPixParentInd);
234 double weight = psfAttr.computeEffectiveArea();
246 double flux = mimageCtrPix.image()*
weight;
247 double var = mimageCtrPix.variance()*weight*
weight;
An include file to include the public header files for lsst::afw::math.
Defines the fields and offsets for a table.
An include file to include the header files for lsst::afw::geom.
double indexToPosition(double ind)
Convert image index to image position.
table::Key< std::string > name
Eigen matrix objects that present a view into an ndarray::Array.
tbl::Key< double > weight
virtual void fail(afw::table::SourceRecord &measRecord, MeasurementError *error=NULL) const
bool contains(Point2I const &point) const
Return true if the box contains the point.
int positionToIndex(double pos)
Convert image position to nearest integer index.
FluxResultKey _fluxResultKey
afw::table::Schema schema
Include files required for standard LSST Exception handling.
boost::shared_ptr< SeparableKernel > makeWarpingKernel(std::string name)
Return a warping kernel given its name.
A kernel described by a pair of functions: func(x, y) = colFunc(x) * rowFunc(y)
bool hasPsf() const
Does this Exposure have a Psf?
geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
A single pixel of the same type as a MaskedImage.
SafeCentroidExtractor _centroidExtractor
Exception to be thrown when a measurement algorithm experiences a known failure mode.
C++ control object for peak likelihood flux.
boost::enable_if< typename ExpressionTraits< Scalar >::IsScalar, Scalar >::type sum(Scalar const &scalar)
An integer coordinate rectangle.
xy_locator xy_at(int x, int y) const
Return an xy_locator at the point (x, y)
An include file to include the header files for lsst::afw::image.
boost::shared_ptr< lsst::afw::image::Image< double > > _psfImage
MaskedImageT getMaskedImage()
Return the MaskedImage.
virtual void measure(afw::table::SourceRecord &measRecord, afw::image::Exposure< float > const &exposure) const
A class to manipulate images, masks, and variance as a single object.
Flux flux
Measured flux in DN.
void setValue(afw::table::BaseRecord &record, int i, bool value) const
A FunctorKey for FluxResult.
boost::shared_ptr< lsst::afw::detection::Psf > getPsf()
Return the Exposure's Psf object.
#define LSST_EXCEPT(type,...)
tbl::Key< std::string > warpingKernelName
std::string warpingKernelName
"Name of warping kernel (e.g. \"lanczos4") used to compute the peak" ;
void set(Key< T > const &key, U const &value)
Set value of a field for the given key.
void handleFailure(afw::table::BaseRecord &record, MeasurementError const *error=NULL) const
afw::image::MaskedImage< T >::SinglePixel computeShiftedValue(afw::image::MaskedImage< T > const &maskedImage, std::string const &warpingKernelName, afw::geom::Point2D const &fracShift, afw::geom::Point2I const &parentInd)
Record class that contains measurements made on a single exposure.
A floating-point coordinate rectangle geometry.
A polymorphic base class for representing an image's Point Spread Function.
FluxErrElement fluxSigma
1-Sigma error (sqrt of variance) on flux in DN.
A class to represent a 2-dimensional array of pixels.
static FlagHandler addFields(afw::table::Schema &schema, std::string const &prefix, FlagDefinition const *begin, FlagDefinition const *end)
A reusable result struct for flux measurements.
Point< double, 2 > PointD