LSSTApplications
21.0.0+75b29a8a7f,21.0.0+e70536a077,21.0.0-1-ga51b5d4+62c747d40b,21.0.0-11-ga6ea59e8e+47cba9fc36,21.0.0-2-g103fe59+914993bf7c,21.0.0-2-g1367e85+e2614ded12,21.0.0-2-g45278ab+e70536a077,21.0.0-2-g4bc9b9f+7b2b5f8678,21.0.0-2-g5242d73+e2614ded12,21.0.0-2-g54e2caa+6403186824,21.0.0-2-g7f82c8f+3ac4acbffc,21.0.0-2-g8dde007+04a6aea1af,21.0.0-2-g8f08a60+9402881886,21.0.0-2-ga326454+3ac4acbffc,21.0.0-2-ga63a54e+81dd751046,21.0.0-2-gc738bc1+5f65c6e7a9,21.0.0-2-gde069b7+26c92b3210,21.0.0-2-gecfae73+0993ddc9bd,21.0.0-2-gfc62afb+e2614ded12,21.0.0-21-gba890a8+5a4f502a26,21.0.0-23-g9966ff26+03098d1af8,21.0.0-3-g357aad2+8ad216c477,21.0.0-3-g4be5c26+e2614ded12,21.0.0-3-g6d51c4a+4d2fe0280d,21.0.0-3-g7d9da8d+75b29a8a7f,21.0.0-3-gaa929c8+522e0f12c2,21.0.0-3-ge02ed75+4d2fe0280d,21.0.0-4-g3300ddd+e70536a077,21.0.0-4-gc004bbf+eac6615e82,21.0.0-4-gccdca77+f94adcd104,21.0.0-4-gd1c1571+18b81799f9,21.0.0-5-g7b47fff+4d2fe0280d,21.0.0-5-gb155db7+d2632f662b,21.0.0-5-gdf36809+637e4641ee,21.0.0-6-g722ad07+28c848f42a,21.0.0-7-g959bb79+522e0f12c2,21.0.0-7-gfd72ab2+cf01990774,21.0.0-9-g87fb7b8d+e2ab11cdd6,w.2021.04
LSSTDataManagementBasePackage
|
Go to the documentation of this file.
33 # include "Minuit2/FCNBase.h"
34 # include "Minuit2/FunctionMinimum.h"
35 # include "Minuit2/MnMigrad.h"
36 # include "Minuit2/MnMinos.h"
37 # include "Minuit2/MnPrint.h"
48 #include "ndarray/eigen.h"
56 namespace lsst {
namespace ip {
namespace diffim {
59 meas::base::FlagDefinitionList dipoleFluxFlagDefinitions;
62 meas::base::FlagDefinition
const DipoleFluxAlgorithm::FAILURE = dipoleFluxFlagDefinitions.addFailureFlag(
"general failure flag, set if anything went wrong");
63 meas::base::FlagDefinition
const DipoleFluxAlgorithm::POS_FLAG = dipoleFluxFlagDefinitions.add(
"pos_flag",
"failure flag for positive, set if anything went wrong");
64 meas::base::FlagDefinition
const DipoleFluxAlgorithm::NEG_FLAG = dipoleFluxFlagDefinitions.add(
"neg_flag",
"failure flag for negative, set if anything went wrong");
67 return dipoleFluxFlagDefinitions;
79 return dipoleCentroidFlagDefinitions;
105 int x = center.getX() -
image.getX0();
106 int y = center.getY() -
image.getY0();
108 if (x < 1 || x >=
image.getWidth() - 1 || y < 1 || y >=
image.getHeight() - 1) {
110 (
boost::format(
"Object at (%d, %d) is too close to the edge")
114 ImageT::xy_locator im =
image.xy_at(
x,
y);
117 (im(-1, 1) + im( 0, 1) + im( 1, 1) +
118 im(-1, 0) + im( 0, 0) + im( 1, 0) +
119 im(-1, -1) + im( 0, -1) + im( 1, -1));
129 -im(-1, 1) + im( 1, 1) +
130 -im(-1, 0) + im( 1, 0) +
131 -im(-1, -1) + im( 1, -1);
133 (im(-1, 1) + im( 0, 1) + im( 1, 1)) -
134 (im(-1, -1) + im( 0, -1) + im( 1, -1));
163 double posValue = peaks[posInd].getPeakValue(), negValue = 0;
165 posInd = peaks.
size() - 1;
166 posValue = peaks[posInd].getPeakValue();
168 naiveCentroid(
source, exposure, peaks[posInd].getI(),
171 if (posValue > 0. && posInd == 0 && peaks.
size() > 1) {
172 int negInd = peaks.
size() - 1;
173 negValue = peaks[negInd].getPeakValue();
174 if (posValue > 0. && negValue < 0.) {
175 naiveCentroid(
source, exposure, peaks[negInd].getI(),
185 double posValue,
double negValue)
const {
187 double pos_x, pos_y, pos_f;
188 double neg_x, neg_y, neg_f;
219 class NaiveDipoleFootprinter {
221 explicit NaiveDipoleFootprinter() : _sumPositive(0.0), _sumNegative(0.0), _numPositive(0),
226 _sumPositive = _sumNegative = 0.0;
227 _numPositive = _numNegative = 0;
236 _sumPositive += ival;
237 _varPositive += vval;
240 _sumNegative += ival;
241 _varPositive += vval;
246 double getSumPositive()
const {
return _sumPositive; }
247 double getSumNegative()
const {
return _sumNegative; }
248 double getVarPositive()
const {
return _sumPositive; }
249 double getVarNegative()
const {
return _sumNegative; }
250 int getNumPositive()
const {
return _numPositive; }
251 int getNumNegative()
const {
return _numNegative; }
274 NaiveDipoleFootprinter functor;
280 source.set(_numPositiveKey, functor.getNumPositive());
284 source.set(_numNegativeKey, functor.getNumNegative());
305 _psfDipoleFlux(psfDipoleFlux),
309 double Up()
const {
return _errorDef; }
325 if ((negFlux > 0.0) || (posFlux < 0.0)) {
330 posCenterX, posCenterY, posFlux);
331 double chi2 = fit.first;
332 int nPix = fit.second;
333 if (nPix > _maxPix) {
355 double negCenterX,
double negCenterY,
double negFlux,
356 double posCenterX,
double posCenterY,
double posFlux
375 footprint->getBBox());
391 negModelSubim += negSubim;
402 posModelSubim += posSubim;
407 residuals += posModel;
409 residuals *= residuals;
432 if (peakCatalog.
size() == 0) {
436 else if (peakCatalog.
size() == 1) {
448 ROOT::Minuit2::MnUserParameters fitPar;
465 ROOT::Minuit2::MnMigrad migrad(minimizerFunc, fitPar);
470 ROOT::Minuit2::FunctionMinimum
min = migrad(_ctrl.
maxFnCalls);
472 float minChi2 =
min.Fval();
489 double evalChi2 = fit.first;
490 int nPix = fit.second;
502 source.set(_chi2dofKey, evalChi2 / (nPix - minimizerFunc.
getNpar()));
503 source.set(_negCentroid.
getX(), minNegCentroid->getX());
504 source.set(_negCentroid.
getY(), minNegCentroid->getY());
505 source.set(_posCentroid.
getX(), minPosCentroid->getX());
506 source.set(_posCentroid.
getY(), minPosCentroid->getY());
507 source.set(_avgCentroid.
getX(), 0.5*(minNegCentroid->getX() + minPosCentroid->getX()));
508 source.set(_avgCentroid.
getY(), 0.5*(minNegCentroid->getY() + minPosCentroid->getY()));
void fail(afw::table::SourceRecord &measRecord, meas::base::MeasurementError *error=NULL) const
Handle an exception thrown by the current algorithm by setting flags in the given record.
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
std::shared_ptr< lsst::afw::detection::Psf const > getPsf() const
Return the Exposure's Psf object.
static meas::base::FlagDefinition const POS_FLAG
Record class that represents a peak in a Footprint.
void handleFailure(afw::table::BaseRecord &record, MeasurementError const *error=nullptr) const
Handle an expected or unexpected Exception thrown by a measurement algorithm.
NaiveDipoleCentroid(Control const &ctrl, std::string const &name, afw::table::Schema &schema)
Record class that contains measurements made on a single exposure.
MinimizeDipoleChi2(PsfDipoleFlux const &psfDipoleFlux, afw::table::SourceRecord &source, afw::image::Exposure< float > const &exposure)
float stepSizeCoord
"Default initial step size for coordinates in non-linear fitter" ;
Intermediate base class for algorithms that compute a centroid.
void measure(afw::table::SourceRecord &measRecord, afw::image::Exposure< float > const &exposure) const
Given an image and a pixel position, return a Centroid using a naive 3x3 weighted moment.
Exception to be thrown when a measurement algorithm experiences a known failure mode.
void measure(afw::table::SourceRecord &measRecord, afw::image::Exposure< float > const &exposure) const
Given an image and a pixel position, return a Centroid using a naive 3x3 weighted moment.
meas::base::FlagHandler _flagHandler
Defines the fields and offsets for a table.
double indexToPosition(double ind)
Convert image index to image position.
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
A FunctorKey for CentroidResult.
ResultKey const & getNegativeKeys() const
void setMaxPix(int maxPix)
MaskedImageT getMaskedImage()
Return the MaskedImage.
double getValue(Property const prop=NOTHING) const
Return the value of the desired property (if specified in the constructor)
ResultKey const & getPositiveKeys() const
ResultKey const & getPositiveKeys() const
Return the standard flux keys registered by this algorithm.
vector-type utility class to build a collection of FlagDefinitions
Statistics makeStatistics(lsst::afw::image::Image< Pixel > const &img, lsst::afw::image::Mask< image::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Handle a watered-down front-end to the constructor (no variance)
size_type size() const
Return the number of elements in the catalog.
int maxFnCalls
"Maximum function calls for non-linear fitter; 0 = unlimited" ;
virtual double operator()(std::vector< double > const ¶ms) const
A class to manipulate images, masks, and variance as a single object.
static meas::base::FlagDefinition const FAILURE
const char * source()
Source function that allows astChannel to source from a Stream.
void setErrorDef(double def)
Reports attempts to exceed implementation-defined length limits for some classes.
Class to minimize PsfDipoleFlux; this is the object that Minuit minimizes.
afw::table::CatalogT< PeakRecord > PeakCatalog
float getPeakValue() const
void fail(afw::table::SourceRecord &measRecord, meas::base::MeasurementError *error=NULL) const
Handle an exception thrown by the current algorithm by setting flags in the given record.
std::pair< double, int > chi2(afw::table::SourceRecord &source, afw::image::Exposure< float > const &exposure, double negCenterX, double negCenterY, double negFlux, double posCenterX, double poCenterY, double posFlux) const
A base class for image defects.
VariancePtr getVariance() const
Return a (shared_ptr to) the MaskedImage's variance.
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
ResultKey const & getCenterKeys() const
Return the standard centroid keys registered by this algorithm.
static meas::base::FlagDefinitionList const & getFlagDefinitions()
Simple class used to define and document flags The name and doc constitute the identity of the FlagDe...
static meas::base::FlagDefinition const NEG_FLAG
@ NPOINT
number of sample points
int getMaxY() const noexcept
reference front() const
Return the first record.
Implementation of Psf dipole flux.
int getMaxX() const noexcept
void mergeCentroids(afw::table::SourceRecord &source, double posValue, double negValue) const
afw::table::Key< CentroidElement > getX() const
Return a Key for the x coordinate.
void fail(afw::table::SourceRecord &measRecord, meas::base::MeasurementError *error=NULL) const
Handle an exception thrown by the current algorithm by setting flags in the given record.
ResultKey const & getNegativeKeys() const
static meas::base::FlagDefinition const NEG_FLAG
An integer coordinate rectangle.
int getMinX() const noexcept
A class to evaluate image statistics.
ImagePtr getImage() const
Return a (shared_ptr to) the MaskedImage's image.
A polymorphic base class for representing an image's Point Spread Function.
ImagePixelT Pixel
A pixel in this ImageBase.
lsst::geom::Box2I getBBox(ImageOrigin origin=PARENT) const
double errorDef
"How many sigma the error bars of the non-linear fitter represent" ;
void measure(afw::table::SourceRecord &measRecord, afw::image::Exposure< float > const &exposure) const
Called to measure a single child source in an image.
afw::table::Key< CentroidElement > getY() const
Return a Key for the y coordinate.
@ SUM
find sum of pixels in the image
#define CONST_PTR(...)
A shared pointer to a const object.
float stepSizeFlux
"Default initial step size for flux in non-linear fitter" ;
static meas::base::FlagDefinition const POS_FLAG
static meas::base::FlagDefinitionList const & getFlagDefinitions()
Reports errors that are due to events beyond the control of the program.
int getMinY() const noexcept
reference back() const
Return the last record.
static meas::base::FlagDefinition const FAILURE