LSSTApplications  11.0-13-gbb96280,12.1.rc1,12.1.rc1+1,12.1.rc1+2,12.1.rc1+5,12.1.rc1+8,12.1.rc1-1-g06d7636+1,12.1.rc1-1-g253890b+5,12.1.rc1-1-g3d31b68+7,12.1.rc1-1-g3db6b75+1,12.1.rc1-1-g5c1385a+3,12.1.rc1-1-g83b2247,12.1.rc1-1-g90cb4cf+6,12.1.rc1-1-g91da24b+3,12.1.rc1-2-g3521f8a,12.1.rc1-2-g39433dd+4,12.1.rc1-2-g486411b+2,12.1.rc1-2-g4c2be76,12.1.rc1-2-gc9c0491,12.1.rc1-2-gda2cd4f+6,12.1.rc1-3-g3391c73+2,12.1.rc1-3-g8c1bd6c+1,12.1.rc1-3-gcf4b6cb+2,12.1.rc1-4-g057223e+1,12.1.rc1-4-g19ed13b+2,12.1.rc1-4-g30492a7
LSSTDataManagementBasePackage
DipoleAlgorithms.cc
Go to the documentation of this file.
1 /*
2  * LSST Data Management System
3  * Copyright 2008-2015 AURA/LSST
4  *
5  * This product includes software developed by the
6  * LSST Project (http://www.lsst.org/).
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the LSST License Statement and
19  * the GNU General Public License along with this program. If not,
20  * see <http://www.lsstcorp.org/LegalNotices/>.
21  */
22 
26 #include <iostream> // std::cout
27 #include <algorithm> // std::sort
28 #include <functional> // std::binary_function
29 #include <limits> // std::numeric_limits
30 #include <cmath> // std::sqrt
31 
32 #if !defined(DOXYGEN)
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"
38 #endif
39 
40 #include <memory>
41 #include "lsst/pex/exceptions.h"
42 #include "lsst/pex/logging/Trace.h"
43 #include "lsst/afw/image.h"
44 #include "lsst/afw/detection.h"
45 #include "lsst/afw/detection/FootprintArray.cc"
46 #include "lsst/afw/table.h"
47 #include "lsst/afw/math.h"
48 #include "lsst/afw/geom.h"
50 #include "ndarray/eigen.h"
51 
52 namespace pexExceptions = lsst::pex::exceptions;
53 namespace afwDet = lsst::afw::detection;
54 namespace afwImage = lsst::afw::image;
55 namespace afwMath = lsst::afw::math;
56 namespace afwGeom = lsst::afw::geom;
57 
58 namespace lsst { namespace ip { namespace diffim {
59 
60  int const NEGCENTXPAR(0); // Parameter for the x-component of the negative lobe centroid
61  int const NEGCENTYPAR(1); // Parameter for the y-component of the negative lobe centroid
62  int const NEGFLUXPAR(2); // Parameter for the flux of the negative lobe
63  int const POSCENTXPAR(3); // Parameter for the x-component of the positive lobe centroid
64  int const POSCENTYPAR(4); // Parameter for the y-component of the positive lobe centroid
65  int const POSFLUXPAR(5); // Parameter for the flux of the positive lobe
66 
67 
68 namespace {
69 
70 void naiveCentroid(
71  afw::table::SourceRecord & source,
72  afw::image::Exposure<float> const& exposure,
73  afw::geom::Point2I const & center,
74  meas::base::CentroidResultKey const & keys
75  )
76 {
77  typedef afw::image::Image<float> ImageT;
78  ImageT const& image = *exposure.getMaskedImage().getImage();
79  // set to the input centroid, just in case all else fails
80  source.set(keys.getX(), center.getX());
81  source.set(keys.getY(), center.getY());
82 
83  int x = center.getX() - image.getX0();
84  int y = center.getY() - image.getY0();
85 
86  if (x < 1 || x >= image.getWidth() - 1 || y < 1 || y >= image.getHeight() - 1) {
87  throw LSST_EXCEPT(pex::exceptions::LengthError,
88  (boost::format("Object at (%d, %d) is too close to the edge")
89  % x % y).str());
90  }
91 
92  ImageT::xy_locator im = image.xy_at(x, y);
93 
94  double const sum =
95  (im(-1, 1) + im( 0, 1) + im( 1, 1) +
96  im(-1, 0) + im( 0, 0) + im( 1, 0) +
97  im(-1, -1) + im( 0, -1) + im( 1, -1));
98 
99 
100  if (sum == 0.0) {
101  throw LSST_EXCEPT(pexExceptions::RuntimeError,
102  (boost::format("Object at (%d, %d) has no counts") %
103  x % y).str());
104  }
105 
106  double const sum_x =
107  -im(-1, 1) + im( 1, 1) +
108  -im(-1, 0) + im( 1, 0) +
109  -im(-1, -1) + im( 1, -1);
110  double const sum_y =
111  (im(-1, 1) + im( 0, 1) + im( 1, 1)) -
112  (im(-1, -1) + im( 0, -1) + im( 1, -1));
113 
114  float xx = afw::image::indexToPosition(x + image.getX0()) + sum_x / sum;
115  float yy = afw::image::indexToPosition(y + image.getY0()) + sum_y / sum;
116  source.set(keys.getX(), xx);
117  source.set(keys.getY(), yy);
118 }
119 
120 } // anonymous namespace
121 
122 
124  Control const & ctrl,
125  std::string const & name,
127 ) : DipoleCentroidAlgorithm(ctrl, name, schema, "unweighted first moment centroid"),
128  _ctrl(ctrl)
129 { }
130 
135  afw::table::SourceRecord & source,
136  afw::image::Exposure<float> const & exposure
137 ) const {
138  afw::detection::PeakCatalog const& peaks = source.getFootprint()->getPeaks();
139 
140  int posInd = 0;
141  double posValue = peaks[posInd].getPeakValue(), negValue = 0;
142  if (posValue < 0.) { /* All peaks are negative so use the *most* negative value */
143  posInd = peaks.size() - 1;
144  posValue = peaks[posInd].getPeakValue();
145  }
146  naiveCentroid(source, exposure, peaks[posInd].getI(),
147  (posValue >= 0 ? getPositiveKeys() : getNegativeKeys()));
148 
149  if (posValue > 0. && posInd == 0 && peaks.size() > 1) { /* See if there's also a negative peak */
150  int negInd = peaks.size() - 1;
151  negValue = peaks[negInd].getPeakValue();
152  if (posValue > 0. && negValue < 0.) {
153  naiveCentroid(source, exposure, peaks[negInd].getI(),
154  (negValue >= 0 ? getPositiveKeys() : getNegativeKeys()));
155  }
156  }
157 
158  mergeCentroids(source, posValue, negValue);
159 
160 }
161 
163  double posValue, double negValue) const {
164 
165  double pos_x, pos_y, pos_f;
166  double neg_x, neg_y, neg_f;
167 
168  pos_x = source.get(getPositiveKeys().getX());
169  pos_y = source.get(getPositiveKeys().getY());
170  pos_f = posValue;
171 
172  neg_x = source.get(getNegativeKeys().getX());
173  neg_y = source.get(getNegativeKeys().getY());
174  neg_f = -negValue;
175 
176  if(std::isfinite(pos_x) && std::isfinite(pos_y) &&
177  std::isfinite(neg_x) && std::isfinite(neg_y)) {
178  source.set(getCenterKeys().getX(), (pos_x * pos_f + neg_x * neg_f) / (pos_f + neg_f));
179  source.set(getCenterKeys().getY(), (pos_y * pos_f + neg_y * neg_f) / (pos_f + neg_f));
180  } else if (std::isfinite(pos_x) && std::isfinite(pos_y)) {
181  source.set(getCenterKeys().getX(), pos_x);
182  source.set(getCenterKeys().getY(), pos_y);
183  } else {
184  source.set(getCenterKeys().getX(), neg_x);
185  source.set(getCenterKeys().getY(), neg_y);
186  }
187 }
188 
191  _flagHandler.handleFailure(measRecord, error);
192 }
193 
194 
195 namespace {
196 
197 class NaiveDipoleFootprinter : public afw::detection::FootprintFunctor< afw::image::MaskedImage<float> > {
198 public:
199  explicit NaiveDipoleFootprinter(afw::image::MaskedImage<float> const& mimage
200  ) : afw::detection::FootprintFunctor< afw::image::MaskedImage<float> >(mimage),
201  _sumPositive(0.0), _sumNegative(0.0), _numPositive(0), _numNegative(0) {}
202 
204  void reset() {
205  _sumPositive = _sumNegative = 0.0;
207  }
208  void reset(afwDet::Footprint const&) {}
209 
211  void operator()( afw::image::MaskedImage<float>::xy_locator loc,
212  int,
213  int
214  ) {
215  afw::image::MaskedImage<float>::Image::Pixel ival = loc.image(0, 0);
216  afw::image::MaskedImage<float>::Image::Pixel vval = loc.variance(0, 0);
217  if (ival >= 0.0) {
218  _sumPositive += ival;
219  _varPositive += vval;
220  ++_numPositive;
221  } else {
222  _sumNegative += ival;
223  _varPositive += vval;
224  ++_numNegative;
225  }
226  }
227 
228  double getSumPositive() const { return _sumPositive; }
229  double getSumNegative() const { return _sumNegative; }
230  double getVarPositive() const { return _sumPositive; }
231  double getVarNegative() const { return _sumNegative; }
232  int getNumPositive() const { return _numPositive; }
233  int getNumNegative() const { return _numNegative; }
234 
235 private:
236  double _sumPositive;
237  double _sumNegative;
238  double _varPositive;
239  double _varNegative;
242 };
243 
244 } // anonymous namespace
245 
246 
251  afw::table::SourceRecord & source,
252  afw::image::Exposure<float> const & exposure
253 ) const {
254  typedef afw::image::Exposure<float>::MaskedImageT MaskedImageT;
255 
256  NaiveDipoleFootprinter functor(exposure.getMaskedImage());
257  functor.apply(*source.getFootprint());
258 
259  source.set(getPositiveKeys().getFlux(), functor.getSumPositive());
260  source.set(getPositiveKeys().getFluxSigma(), ::sqrt(functor.getVarPositive()));
261  source.set(_numPositiveKey, functor.getNumPositive());
262 
263  source.set(getNegativeKeys().getFlux(), functor.getSumNegative());
264  source.set(getNegativeKeys().getFluxSigma(), ::sqrt(functor.getVarNegative()));
265  source.set(_numNegativeKey, functor.getNumNegative());
266 }
267 
269  _flagHandler.handleFailure(measRecord, error);
270 }
271 
272 
276 class MinimizeDipoleChi2 : public ROOT::Minuit2::FCNBase {
277 public:
278  explicit MinimizeDipoleChi2(PsfDipoleFlux const& psfDipoleFlux,
279  afw::table::SourceRecord & source,
280  afw::image::Exposure<float> const& exposure
281  ) : _errorDef(1.0),
282  _nPar(6),
283  _maxPix(1e4),
284  _bigChi2(1e10),
285  _psfDipoleFlux(psfDipoleFlux),
286  _source(source),
287  _exposure(exposure)
288  {}
289  double Up() const { return _errorDef; }
290  void setErrorDef(double def) { _errorDef = def; }
291  int getNpar() const { return _nPar; }
292  int getMaxPix() const { return _maxPix; }
293  void setMaxPix(int maxPix) { _maxPix = maxPix; }
294 
295  // Evaluate our cost function (in this case chi^2)
296  virtual double operator()(std::vector<double> const & params) const {
297  double negCenterX = params[NEGCENTXPAR];
298  double negCenterY = params[NEGCENTYPAR];
299  double negFlux = params[NEGFLUXPAR];
300  double posCenterX = params[POSCENTXPAR];
301  double posCenterY = params[POSCENTYPAR];
302  double posFlux = params[POSFLUXPAR];
303 
304  /* Restrict negative dipole to be negative; positive to be positive */
305  if ((negFlux > 0.0) || (posFlux < 0.0)) {
306  return _bigChi2;
307  }
308 
309  std::pair<double,int> fit = _psfDipoleFlux.chi2(_source, _exposure, negCenterX, negCenterY, negFlux,
310  posCenterX, posCenterY, posFlux);
311  double chi2 = fit.first;
312  int nPix = fit.second;
313  if (nPix > _maxPix) {
314  return _bigChi2;
315  }
316 
317  return chi2;
318  }
319 
320 private:
321  double _errorDef; // how much cost function has changed at the +- 1 error points
322  int _nPar; // number of parameters in the fit; hard coded for MinimizeDipoleChi2
323  int _maxPix; // maximum number of pixels that shoud be in the footprint;
324  // prevents too much centroid wander
325  double _bigChi2; // large value to tell fitter when it has gone into bad region of parameter space
326 
330 };
331 
332 std::pair<double,int> PsfDipoleFlux::chi2(
333  afw::table::SourceRecord & source,
334  afw::image::Exposure<float> const& exposure,
335  double negCenterX, double negCenterY, double negFlux,
336  double posCenterX, double posCenterY, double posFlux
337 ) const {
338 
339  afw::geom::Point2D negCenter(negCenterX, negCenterY);
340  afw::geom::Point2D posCenter(posCenterX, posCenterY);
341 
342  CONST_PTR(afw::detection::Footprint) footprint = source.getFootprint();
343 
344  /*
345  * Fit for the superposition of Psfs at the two centroids.
346  */
347  CONST_PTR(afwDet::Psf) psf = exposure.getPsf();
348  PTR(afwImage::Image<afwMath::Kernel::Pixel>) negPsf = psf->computeImage(negCenter);
349  PTR(afwImage::Image<afwMath::Kernel::Pixel>) posPsf = psf->computeImage(posCenter);
350 
351  afwImage::Image<double> negModel(footprint->getBBox());
352  afwImage::Image<double> posModel(footprint->getBBox());
353  afwImage::Image<float> data(*(exposure.getMaskedImage().getImage()),footprint->getBBox());
355  footprint->getBBox());
356 
357  afwGeom::Box2I negPsfBBox = negPsf->getBBox();
358  afwGeom::Box2I posPsfBBox = posPsf->getBBox();
359  afwGeom::Box2I negModelBBox = negModel.getBBox();
360  afwGeom::Box2I posModelBBox = posModel.getBBox();
361 
362  // Portion of the negative Psf that overlaps the model
363  int negXmin = std::max(negPsfBBox.getMinX(), negModelBBox.getMinX());
364  int negYmin = std::max(negPsfBBox.getMinY(), negModelBBox.getMinY());
365  int negXmax = std::min(negPsfBBox.getMaxX(), negModelBBox.getMaxX());
366  int negYmax = std::min(negPsfBBox.getMaxY(), negModelBBox.getMaxY());
367  afwGeom::Box2I negBBox = afwGeom::Box2I(afwGeom::Point2I(negXmin, negYmin),
368  afwGeom::Point2I(negXmax, negYmax));
369  afwImage::Image<afwMath::Kernel::Pixel> negSubim(*negPsf, negBBox);
370  afwImage::Image<double> negModelSubim(negModel, negBBox);
371  negModelSubim += negSubim;
372 
373  // Portion of the positive Psf that overlaps the model
374  int posXmin = std::max(posPsfBBox.getMinX(), posModelBBox.getMinX());
375  int posYmin = std::max(posPsfBBox.getMinY(), posModelBBox.getMinY());
376  int posXmax = std::min(posPsfBBox.getMaxX(), posModelBBox.getMaxX());
377  int posYmax = std::min(posPsfBBox.getMaxY(), posModelBBox.getMaxY());
378  afwGeom::Box2I posBBox = afwGeom::Box2I(afwGeom::Point2I(posXmin, posYmin),
379  afwGeom::Point2I(posXmax, posYmax));
380  afwImage::Image<afwMath::Kernel::Pixel> posSubim(*posPsf, posBBox);
381  afwImage::Image<double> posModelSubim(posModel, posBBox);
382  posModelSubim += posSubim;
383 
384  negModel *= negFlux; // scale negative model to image
385  posModel *= posFlux; // scale positive model to image
386  afwImage::Image<double> residuals(negModel, true); // full model contains negative lobe...
387  residuals += posModel; // plus positive lobe...
388  residuals -= data; // minus the data...
389  residuals *= residuals; // squared...
390  residuals /= var; // divided by the variance : [(model-data)/sigma]**2
392  double chi2 = stats.getValue(afwMath::SUM);
393  int nPix = stats.getValue(afwMath::NPOINT);
394  return std::pair<double,int>(chi2, nPix);
395 }
396 
398  afw::table::SourceRecord & source,
399  afw::image::Exposure<float> const & exposure
400 ) const {
401 
402  typedef afw::image::Exposure<float>::MaskedImageT MaskedImageT;
403 
404  CONST_PTR(afw::detection::Footprint) footprint = source.getFootprint();
405  if (!footprint) {
406  throw LSST_EXCEPT(pex::exceptions::RuntimeError,
407  (boost::format("No footprint for source %d") % source.getId()).str());
408  }
409 
410  afw::detection::PeakCatalog peakCatalog = afw::detection::PeakCatalog(footprint->getPeaks());
411 
412  if (peakCatalog.size() == 0) {
413  throw LSST_EXCEPT(pex::exceptions::RuntimeError,
414  (boost::format("No peak for source %d") % source.getId()).str());
415  }
416  else if (peakCatalog.size() == 1) {
417  // No deblending to do
418  return;
419  }
420 
421  // For N>=2, just measure the brightest-positive and brightest-negative
422  // peaks. peakCatalog is automatically ordered by peak flux, with the most
423  // positive one (brightest) being first
424  afw::detection::PeakRecord const& positivePeak = peakCatalog.front();
425  afw::detection::PeakRecord const& negativePeak = peakCatalog.back();
426 
427  // Set up fit parameters and param names
428  ROOT::Minuit2::MnUserParameters fitPar;
429 
430  fitPar.Add((boost::format("P%d")%NEGCENTXPAR).str(), negativePeak.getFx(), _ctrl.stepSizeCoord);
431  fitPar.Add((boost::format("P%d")%NEGCENTYPAR).str(), negativePeak.getFy(), _ctrl.stepSizeCoord);
432  fitPar.Add((boost::format("P%d")%NEGFLUXPAR).str(), negativePeak.getPeakValue(), _ctrl.stepSizeFlux);
433  fitPar.Add((boost::format("P%d")%POSCENTXPAR).str(), positivePeak.getFx(), _ctrl.stepSizeCoord);
434  fitPar.Add((boost::format("P%d")%POSCENTYPAR).str(), positivePeak.getFy(), _ctrl.stepSizeCoord);
435  fitPar.Add((boost::format("P%d")%POSFLUXPAR).str(), positivePeak.getPeakValue(), _ctrl.stepSizeFlux);
436 
437  // Create the minuit object that knows how to minimise our functor
438  //
439  MinimizeDipoleChi2 minimizerFunc(*this, source, exposure);
440  minimizerFunc.setErrorDef(_ctrl.errorDef);
441 
442  //
443  // tell minuit about it
444  //
445  ROOT::Minuit2::MnMigrad migrad(minimizerFunc, fitPar);
446 
447  //
448  // And let it loose
449  //
450  ROOT::Minuit2::FunctionMinimum min = migrad(_ctrl.maxFnCalls);
451 
452  float minChi2 = min.Fval();
453  bool const isValid = min.IsValid() && std::isfinite(minChi2);
454 
455  if (true || isValid) { // calculate coeffs even in minuit is unhappy
456 
457  /* I need to call chi2 one more time to grab nPix to calculate chi2/dof.
458  Turns out that the Minuit operator method has to be const, and the
459  measurement _apply method has to be const, so I can't store nPix as a
460  private member variable anywhere. Consted into a corner.
461  */
462  std::pair<double,int> fit = chi2(source, exposure,
463  min.UserState().Value(NEGCENTXPAR),
464  min.UserState().Value(NEGCENTYPAR),
465  min.UserState().Value(NEGFLUXPAR),
466  min.UserState().Value(POSCENTXPAR),
467  min.UserState().Value(POSCENTYPAR),
468  min.UserState().Value(POSFLUXPAR));
469  double evalChi2 = fit.first;
470  int nPix = fit.second;
471 
472  PTR(afw::geom::Point2D) minNegCentroid(new afw::geom::Point2D(min.UserState().Value(NEGCENTXPAR),
473  min.UserState().Value(NEGCENTYPAR)));
474  source.set(getNegativeKeys().getFlux(), min.UserState().Value(NEGFLUXPAR));
475  source.set(getNegativeKeys().getFluxSigma(), min.UserState().Error(NEGFLUXPAR));
476 
477  PTR(afw::geom::Point2D) minPosCentroid(new afw::geom::Point2D(min.UserState().Value(POSCENTXPAR),
478  min.UserState().Value(POSCENTYPAR)));
479  source.set(getPositiveKeys().getFlux(), min.UserState().Value(POSFLUXPAR));
480  source.set(getPositiveKeys().getFluxSigma(), min.UserState().Error(POSFLUXPAR));
481 
482  source.set(_chi2dofKey, evalChi2 / (nPix - minimizerFunc.getNpar()));
483  source.set(_negCentroid.getX(), minNegCentroid->getX());
484  source.set(_negCentroid.getY(), minNegCentroid->getY());
485  source.set(_posCentroid.getX(), minPosCentroid->getX());
486  source.set(_posCentroid.getY(), minPosCentroid->getY());
487  source.set(_avgCentroid.getX(), 0.5*(minNegCentroid->getX() + minPosCentroid->getX()));
488  source.set(_avgCentroid.getY(), 0.5*(minNegCentroid->getY() + minPosCentroid->getY()));
489 
490  }
491 }
492 
494  _flagHandler.handleFailure(measRecord, error);
495 }
496 }}} // namespace lsst::ip::diffim
int y
An include file to include the public header files for lsst::afw::math.
Defines the fields and offsets for a table.
Definition: Schema.h:44
afw::table::Key< float > _chi2dofKey
float stepSizeFlux
&quot;Default initial step size for flux in non-linear fitter&quot; ;
int getMaxY() const
Definition: Box.h:129
An include file to include the header files for lsst::afw::geom.
double _sumNegative
meas::base::CentroidResultKey _avgCentroid
int const NEGFLUXPAR(2)
double indexToPosition(double ind)
Convert image index to image position.
Definition: ImageUtils.h:54
table::Key< std::string > name
Definition: ApCorrMap.cc:71
void mergeCentroids(afw::table::SourceRecord &source, double posValue, double negValue) const
afw::table::Key< int > _numNegativeKey
ResultKey const & getCenterKeys() const
Return the standard centroid keys registered by this algorithm.
double _varNegative
afw::table::Schema schema
Definition: GaussianPsf.cc:41
definition of the Trace messaging facilities
PixelT Pixel
A pixel in this ImageBase.
Definition: Image.h:133
int const NEGCENTXPAR(0)
MinimizeDipoleChi2(PsfDipoleFlux const &psfDipoleFlux, afw::table::SourceRecord &source, afw::image::Exposure< float > const &exposure)
boost::shared_ptr< Footprint > getFootprint() const
Definition: Source.h:88
ImagePtr getImage(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage&#39;s image.
Definition: MaskedImage.h:875
void fail(afw::table::SourceRecord &measRecord, meas::base::MeasurementError *error=NULL) const
meas::base::CentroidResultKey _negCentroid
Point< int, 2 > Point2I
Definition: PSF.h:39
#define CONST_PTR(...)
Definition: base.h:47
Exception to be thrown when a measurement algorithm experiences a known failure mode.
Definition: exceptions.h:48
ResultKey const & getPositiveKeys() const
Return the standard flux keys registered by this algorithm.
size_type size() const
Return the number of elements in the catalog.
Definition: Catalog.h:402
ResultKey const & getNegativeKeys() const
void handleFailure(afw::table::BaseRecord &record, MeasurementError const *error=NULL) const
Definition: FlagHandler.cc:77
An integer coordinate rectangle.
Definition: Box.h:53
void measure(afw::table::SourceRecord &measRecord, afw::image::Exposure< float > const &exposure) const
int const POSCENTXPAR(3)
VariancePtr getVariance(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage&#39;s variance.
Definition: MaskedImage.h:896
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
afw::image::Exposure< float > const & _exposure
meas::base::CentroidResultKey _posCentroid
double getValue(Property const prop=NOTHING) const
Return the value of the desired property (if specified in the constructor)
Definition: Statistics.cc:1034
def error
Definition: log.py:103
An include file to include the header files for lsst::afw::image.
void measure(afw::table::SourceRecord &measRecord, afw::image::Exposure< float > const &exposure) const
afw::table::CatalogT< PeakRecord > PeakCatalog
Definition: Peak.h:225
MaskedImageT getMaskedImage()
Return the MaskedImage.
Definition: Exposure.h:148
An include file to include the header files for lsst::afw::detection.
int getMinY() const
Definition: Box.h:125
ResultKey const & getNegativeKeys() const
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:78
number of sample points
Definition: Statistics.h:66
virtual double operator()(std::vector< double > const &params) const
afw::table::Key< CentroidElement > getX() const
Return a Key for the x coordinate.
int getMinX() const
Definition: Box.h:124
RecordId getId() const
Convenience accessors for the keys in the minimal reference schema.
Definition: Simple.h:204
NaiveDipoleCentroid(Control const &ctrl, std::string const &name, afw::table::Schema &schema)
int const POSCENTYPAR(4)
double errorDef
&quot;How many sigma the error bars of the non-linear fitter represent&quot; ;
afw::table::Key< CentroidElement > getY() const
Return a Key for the y coordinate.
double x
int _numPositive
void fail(afw::table::SourceRecord &measRecord, meas::base::MeasurementError *error=NULL) const
double _varPositive
A set of pixels in an Image.
Definition: Footprint.h:62
Intermediate base class for algorithms that compute a centroid.
int maxFnCalls
&quot;Maximum function calls for non-linear fitter; 0 = unlimited&quot; ;
void fail(afw::table::SourceRecord &measRecord, meas::base::MeasurementError *error=NULL) const
boost::shared_ptr< lsst::afw::detection::Psf > getPsf()
Return the Exposure&#39;s Psf object.
Definition: Exposure.h:222
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
int const POSFLUXPAR(5)
int _numNegative
int const NEGCENTYPAR(1)
float getFy() const
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:215
float stepSizeCoord
&quot;Default initial step size for coordinates in non-linear fitter&quot; ;
#define PTR(...)
Definition: base.h:41
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
reference back() const
Return the last record.
Definition: Catalog.h:437
Statistics makeStatistics(afwImage::Mask< afwImage::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl)
Specialization to handle Masks.
Definition: Statistics.cc:1107
ResultKey const & getPositiveKeys() const
double _sumPositive
void set(Key< T > const &key, U const &value)
Set value of a field for the given key.
Definition: BaseRecord.h:145
Field< T >::Value get(Key< T > const &key) const
Return the value of a field for the given key.
Definition: BaseRecord.h:132
reference front() const
Return the first record.
Definition: Catalog.h:434
float getPeakValue() const
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:219
Record class that contains measurements made on a single exposure.
Definition: Source.h:80
float getFx() const
Convenience accessors for the keys in the minimal schema.
Definition: Peak.h:214
afw::table::SourceRecord & _source
int getMaxX() const
Definition: Box.h:128
afw::table::Key< int > _numPositiveKey
find sum of pixels in the image
Definition: Statistics.h:78
Include files required for standard LSST Exception handling.
A polymorphic base class for representing an image&#39;s Point Spread Function.
Definition: Psf.h:68
Record class that represents a peak in a Footprint.
Definition: Peak.h:40
A functor class to allow users to process all the pixels in a Footprint.
A class to represent a 2-dimensional array of pixels.
Definition: PSF.h:43
void measure(afw::table::SourceRecord &measRecord, afw::image::Exposure< float > const &exposure) const