LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Private Attributes | List of all members
lsst::meas::base::PeakLikelihoodFluxAlgorithm Class Reference

A measurement algorithm that estimates the peak flux, using a filtered image which has been convolved with its own PSF. More...

#include <PeakLikelihoodFlux.h>

Inheritance diagram for lsst::meas::base::PeakLikelihoodFluxAlgorithm:
lsst::meas::base::SimpleAlgorithm lsst::meas::base::SingleFrameAlgorithm lsst::meas::base::ForcedAlgorithm lsst::meas::base::BaseAlgorithm lsst::meas::base::BaseAlgorithm

Public Types

enum  { FAILURE =FlagHandler::FAILURE, N_FLAGS }
 
typedef PeakLikelihoodFluxControl Control
 

Public Member Functions

 PeakLikelihoodFluxAlgorithm (Control const &ctrl, std::string const &name, afw::table::Schema &schema)
 
virtual void measure (afw::table::SourceRecord &measRecord, afw::image::Exposure< float > const &exposure) const
 
virtual void fail (afw::table::SourceRecord &measRecord, MeasurementError *error=NULL) const
 
- Public Member Functions inherited from lsst::meas::base::SimpleAlgorithm
virtual void measureForced (afw::table::SourceRecord &measRecord, afw::image::Exposure< float > const &exposure, afw::table::SourceRecord const &refRecord, afw::image::Wcs const &refWcs) const
 
virtual void measureNForced (afw::table::SourceCatalog const &measCat, afw::image::Exposure< float > const &exposure, afw::table::SourceCatalog const &refRecord, afw::image::Wcs const &refWcs) const
 
- Public Member Functions inherited from lsst::meas::base::SingleFrameAlgorithm
virtual void measureN (afw::table::SourceCatalog const &measCat, afw::image::Exposure< float > const &exposure) const
 
- Public Member Functions inherited from lsst::meas::base::BaseAlgorithm
virtual ~BaseAlgorithm ()
 

Private Attributes

Control _ctrl
 
FluxResultKey _fluxResultKey
 
FlagHandler _flagHandler
 
SafeCentroidExtractor _centroidExtractor
 

Detailed Description

A measurement algorithm that estimates the peak flux, using a filtered image which has been convolved with its own PSF.

Definition at line 71 of file PeakLikelihoodFlux.h.

Member Typedef Documentation

A typedef to the Control object for this algorithm, defined above. The control object contains the configuration parameters for this algorithm.

Definition at line 81 of file PeakLikelihoodFlux.h.

Member Enumeration Documentation

anonymous enum

Constructor & Destructor Documentation

lsst::meas::base::PeakLikelihoodFluxAlgorithm::PeakLikelihoodFluxAlgorithm ( Control const &  ctrl,
std::string const &  name,
afw::table::Schema schema 
)

Definition at line 175 of file PeakLikelihoodFlux.cc.

179  : _ctrl(ctrl),
181  FluxResultKey::addFields(schema, name, "flux from PeakLikelihood Flux algorithm")
182  ),
184 {
185  static boost::array<FlagDefinition,N_FLAGS> const flagDefs = {{
186  {"flag", "general failure flag, set if anything went wrong"}
187  }};
188  _flagHandler = FlagHandler::addFields(schema, name, flagDefs.begin(), flagDefs.end());
189 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
afw::table::Schema schema
Definition: GaussianPsf.cc:41
static FluxResultKey addFields(afw::table::Schema &schema, std::string const &name, std::string const &doc)
static FlagHandler addFields(afw::table::Schema &schema, std::string const &prefix, FlagDefinition const *begin, FlagDefinition const *end)
Definition: FlagHandler.cc:28

Member Function Documentation

void lsst::meas::base::PeakLikelihoodFluxAlgorithm::fail ( afw::table::SourceRecord measRecord,
MeasurementError error = NULL 
) const
virtual

Handle an exception thrown by the current algorithm by setting flags in the given record.

fail() is called by the measurement framework when an exception is allowed to propagate out of one the algorithm's measure() methods. It should generally set both a general failure flag for the algorithm as well as a specific flag indicating the error condition, if possible. To aid in this, if the exception was an instance of MeasurementError, it will be passed in, carrying information about what flag to set.

An algorithm can also to chose to set flags within its own measure() methods, and then just return, rather than throw an exception. However, fail() should be implemented even when all known failure modes do not throw exceptions, to ensure that unexpected exceptions thrown in lower-level code are properly handled.

Implements lsst::meas::base::BaseAlgorithm.

Definition at line 255 of file PeakLikelihoodFlux.cc.

255  {
256  _flagHandler.handleFailure(measRecord, error);
257 }
def error
Definition: log.py:108
void handleFailure(afw::table::BaseRecord &record, MeasurementError const *error=NULL) const
Definition: FlagHandler.cc:59
void lsst::meas::base::PeakLikelihoodFluxAlgorithm::measure ( afw::table::SourceRecord measRecord,
afw::image::Exposure< float > const &  exposure 
) const
virtual

Called to measure a single child source in an image.

Before this method is called, all neighbors will be replaced with noise, using the outputs of the deblender. Outputs should be saved in the given SourceRecord, which can also be used to obtain centroid (see SafeCentroidExtractor) and shape (see SafeShapeExtractor) information.

Given an image and a pixel position, return a Flux

Exceptions
lsst::pex::exceptions::InvalidParameterErrorif the exposure has no PSF.
lsst::pex::exceptions::RangeErrorif the warping (centering) kernel is not fully contained within the exposure.
lsst::pex::exceptions::RangeErrorif the center not within exposure. (This avoids insane center values from confusing the test for warping kernel within exposure).

Implements lsst::meas::base::SingleFrameAlgorithm.

Definition at line 191 of file PeakLikelihoodFlux.cc.

194  {
195  // get the value from the centroid slot only
196  afw::geom::Point2D center = _centroidExtractor(measRecord, _flagHandler);
197  FluxResult result;
198  typedef afw::image::Exposure<float>::MaskedImageT MaskedImageT;
199  MaskedImageT const& mimage = exposure.getMaskedImage();
200 
211  if (!exposure.hasPsf()) {
212  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "exposure has no PSF");
213  }
214  PTR(afw::detection::Psf const) psfPtr = exposure.getPsf();
215  if (!afw::geom::Box2D(mimage.getBBox()).contains(center)) {
216  std::ostringstream os;
217  os << "Center = " << center << " not in exposure bbox" << mimage.getBBox();
218  throw LSST_EXCEPT(pex::exceptions::RangeError, os.str());
219  }
220 
221  // compute parent index and fractional offset of ctrPix: the pixel closest to "center",
222  // the centroid of the source
223  std::pair<int, double> const xCtrPixParentIndFrac = afw::image::positionToIndex(center.getX(), true);
224  std::pair<int, double> const yCtrPixParentIndFrac = afw::image::positionToIndex(center.getY(), true);
225 
226  afw::geom::Point2I ctrPixParentInd(xCtrPixParentIndFrac.first, yCtrPixParentIndFrac.first);
227  afw::geom::Point2D ctrPixPos(
228  afw::image::indexToPosition(ctrPixParentInd[0]),
229  afw::image::indexToPosition(ctrPixParentInd[1])
230  );
231 
232  // compute weight = 1/sum(PSF^2) for PSF at ctrPix, where PSF is normalized to a sum of 1
233  PsfAttributes psfAttr(psfPtr, ctrPixParentInd);
234  double weight = psfAttr.computeEffectiveArea();
235 
236  /*
237  * Compute value of image at center of source, as shifted by a fractional pixel to center the source
238  * on ctrPix.
239  */
240  MaskedImageT::SinglePixel mimageCtrPix = computeShiftedValue(
241  mimage,
243  afw::geom::Point2D(xCtrPixParentIndFrac.second, yCtrPixParentIndFrac.second),
244  ctrPixParentInd
245  );
246  double flux = mimageCtrPix.image()*weight;
247  double var = mimageCtrPix.variance()*weight*weight;
248  result.flux = flux;
249  result.fluxSigma = std::sqrt(var);
250  measRecord.set(_fluxResultKey, result);
251  _flagHandler.setValue(measRecord, FAILURE, false);
252 
253 }
double indexToPosition(double ind)
Convert image index to image position.
Definition: ImageUtils.h:54
tbl::Key< double > weight
int positionToIndex(double pos)
Convert image position to nearest integer index.
Definition: ImageUtils.h:69
#define PTR(...)
Definition: base.h:41
Point< double, 2 > Point2D
Definition: Point.h:286
Point< int, 2 > Point2I
Definition: Point.h:283
MaskedImage< float, lsst::afw::image::MaskPixel, lsst::afw::image::VariancePixel > MaskedImageT
Definition: Exposure.h:51
if(width!=gim.getWidth()||height!=gim.getHeight()||x0!=gim.getX0()||y0!=gim.getY0())
Definition: saturated.cc:47
void setValue(afw::table::BaseRecord &record, int i, bool value) const
Definition: FlagHandler.h:72
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
std::string warpingKernelName
&quot;Name of warping kernel (e.g. \&quot;lanczos4") used to compute the peak" ;
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)

Member Data Documentation

SafeCentroidExtractor lsst::meas::base::PeakLikelihoodFluxAlgorithm::_centroidExtractor
private

Definition at line 100 of file PeakLikelihoodFlux.h.

Control lsst::meas::base::PeakLikelihoodFluxAlgorithm::_ctrl
private

Definition at line 97 of file PeakLikelihoodFlux.h.

FlagHandler lsst::meas::base::PeakLikelihoodFluxAlgorithm::_flagHandler
private

Definition at line 99 of file PeakLikelihoodFlux.h.

FluxResultKey lsst::meas::base::PeakLikelihoodFluxAlgorithm::_fluxResultKey
private

Definition at line 98 of file PeakLikelihoodFlux.h.


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