LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
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/afw/image.h"
43 #include "lsst/afw/detection.h"
44 #include "lsst/afw/detection/FootprintArray.cc"
45 #include "lsst/afw/table.h"
46 #include "lsst/afw/math.h"
47 #include "lsst/afw/geom.h"
49 #include "ndarray/eigen.h"
50 
51 namespace pexExceptions = lsst::pex::exceptions;
52 namespace afwDet = lsst::afw::detection;
53 namespace afwImage = lsst::afw::image;
54 namespace afwMath = lsst::afw::math;
55 namespace afwGeom = lsst::afw::geom;
56 
57 namespace lsst { namespace ip { namespace diffim {
58 
59  int const NEGCENTXPAR(0); // Parameter for the x-component of the negative lobe centroid
60  int const NEGCENTYPAR(1); // Parameter for the y-component of the negative lobe centroid
61  int const NEGFLUXPAR(2); // Parameter for the flux of the negative lobe
62  int const POSCENTXPAR(3); // Parameter for the x-component of the positive lobe centroid
63  int const POSCENTYPAR(4); // Parameter for the y-component of the positive lobe centroid
64  int const POSFLUXPAR(5); // Parameter for the flux of the positive lobe
65 
66 
67 namespace {
68 
69 void naiveCentroid(
70  afw::table::SourceRecord & source,
71  afw::image::Exposure<float> const& exposure,
72  afw::geom::Point2I const & center,
73  meas::base::CentroidResultKey const & keys
74  )
75 {
76  typedef afw::image::Image<float> ImageT;
77  ImageT const& image = *exposure.getMaskedImage().getImage();
78  // set to the input centroid, just in case all else fails
79  source.set(keys.getX(), center.getX());
80  source.set(keys.getY(), center.getY());
81 
82  int x = center.getX() - image.getX0();
83  int y = center.getY() - image.getY0();
84 
85  if (x < 1 || x >= image.getWidth() - 1 || y < 1 || y >= image.getHeight() - 1) {
86  throw LSST_EXCEPT(pex::exceptions::LengthError,
87  (boost::format("Object at (%d, %d) is too close to the edge")
88  % x % y).str());
89  }
90 
91  ImageT::xy_locator im = image.xy_at(x, y);
92 
93  double const sum =
94  (im(-1, 1) + im( 0, 1) + im( 1, 1) +
95  im(-1, 0) + im( 0, 0) + im( 1, 0) +
96  im(-1, -1) + im( 0, -1) + im( 1, -1));
97 
98 
99  if (sum == 0.0) {
100  throw LSST_EXCEPT(pexExceptions::RuntimeError,
101  (boost::format("Object at (%d, %d) has no counts") %
102  x % y).str());
103  }
104 
105  double const sum_x =
106  -im(-1, 1) + im( 1, 1) +
107  -im(-1, 0) + im( 1, 0) +
108  -im(-1, -1) + im( 1, -1);
109  double const sum_y =
110  (im(-1, 1) + im( 0, 1) + im( 1, 1)) -
111  (im(-1, -1) + im( 0, -1) + im( 1, -1));
112 
113  float xx = afw::image::indexToPosition(x + image.getX0()) + sum_x / sum;
114  float yy = afw::image::indexToPosition(y + image.getY0()) + sum_y / sum;
115  source.set(keys.getX(), xx);
116  source.set(keys.getY(), yy);
117 }
118 
119 } // anonymous namespace
120 
121 
123  Control const & ctrl,
124  std::string const & name,
126 ) : DipoleCentroidAlgorithm(ctrl, name, schema, "unweighted first moment centroid"),
127  _ctrl(ctrl)
128 { }
129 
134  afw::table::SourceRecord & source,
135  afw::image::Exposure<float> const & exposure
136 ) const {
137  afw::detection::PeakCatalog const& peaks = source.getFootprint()->getPeaks();
138 
139  int posInd = 0;
140  double posValue = peaks[posInd].getPeakValue(), negValue = 0;
141  if (posValue < 0.) { /* All peaks are negative so use the *most* negative value */
142  posInd = peaks.size() - 1;
143  posValue = peaks[posInd].getPeakValue();
144  }
145  naiveCentroid(source, exposure, peaks[posInd].getI(),
146  (posValue >= 0 ? getPositiveKeys() : getNegativeKeys()));
147 
148  if (posValue > 0. && posInd == 0 && peaks.size() > 1) { /* See if there's also a negative peak */
149  int negInd = peaks.size() - 1;
150  negValue = peaks[negInd].getPeakValue();
151  if (posValue > 0. && negValue < 0.) {
152  naiveCentroid(source, exposure, peaks[negInd].getI(),
153  (negValue >= 0 ? getPositiveKeys() : getNegativeKeys()));
154  }
155  }
156 
157  mergeCentroids(source, posValue, negValue);
158 
159 }
160 
162  double posValue, double negValue) const {
163 
164  double pos_x, pos_y, pos_f;
165  double neg_x, neg_y, neg_f;
166 
167  pos_x = source.get(getPositiveKeys().getX());
168  pos_y = source.get(getPositiveKeys().getY());
169  pos_f = posValue;
170 
171  neg_x = source.get(getNegativeKeys().getX());
172  neg_y = source.get(getNegativeKeys().getY());
173  neg_f = -negValue;
174 
175  if(std::isfinite(pos_x) && std::isfinite(pos_y) &&
176  std::isfinite(neg_x) && std::isfinite(neg_y)) {
177  source.set(getCenterKeys().getX(), (pos_x * pos_f + neg_x * neg_f) / (pos_f + neg_f));
178  source.set(getCenterKeys().getY(), (pos_y * pos_f + neg_y * neg_f) / (pos_f + neg_f));
179  } else if (std::isfinite(pos_x) && std::isfinite(pos_y)) {
180  source.set(getCenterKeys().getX(), pos_x);
181  source.set(getCenterKeys().getY(), pos_y);
182  } else {
183  source.set(getCenterKeys().getX(), neg_x);
184  source.set(getCenterKeys().getY(), neg_y);
185  }
186 }
187 
190  _flagHandler.handleFailure(measRecord, error);
191 }
192 
193 
194 namespace {
195 
196 class NaiveDipoleFootprinter : public afw::detection::FootprintFunctor< afw::image::MaskedImage<float> > {
197 public:
198  explicit NaiveDipoleFootprinter(afw::image::MaskedImage<float> const& mimage
199  ) : afw::detection::FootprintFunctor< afw::image::MaskedImage<float> >(mimage),
200  _sumPositive(0.0), _sumNegative(0.0), _numPositive(0), _numNegative(0) {}
201 
203  void reset() {
204  _sumPositive = _sumNegative = 0.0;
206  }
207  void reset(afwDet::Footprint const&) {}
208 
210  void operator()( afw::image::MaskedImage<float>::xy_locator loc,
211  int,
212  int
213  ) {
214  afw::image::MaskedImage<float>::Image::Pixel ival = loc.image(0, 0);
215  afw::image::MaskedImage<float>::Image::Pixel vval = loc.variance(0, 0);
216  if (ival >= 0.0) {
217  _sumPositive += ival;
218  _varPositive += vval;
219  ++_numPositive;
220  } else {
221  _sumNegative += ival;
222  _varPositive += vval;
223  ++_numNegative;
224  }
225  }
226 
227  double getSumPositive() const { return _sumPositive; }
228  double getSumNegative() const { return _sumNegative; }
229  double getVarPositive() const { return _sumPositive; }
230  double getVarNegative() const { return _sumNegative; }
231  int getNumPositive() const { return _numPositive; }
232  int getNumNegative() const { return _numNegative; }
233 
234 private:
235  double _sumPositive;
236  double _sumNegative;
237  double _varPositive;
238  double _varNegative;
241 };
242 
243 } // anonymous namespace
244 
245 
250  afw::table::SourceRecord & source,
251  afw::image::Exposure<float> const & exposure
252 ) const {
253  typedef afw::image::Exposure<float>::MaskedImageT MaskedImageT;
254 
255  NaiveDipoleFootprinter functor(exposure.getMaskedImage());
256  functor.apply(*source.getFootprint());
257 
258  source.set(getPositiveKeys().getFlux(), functor.getSumPositive());
259  source.set(getPositiveKeys().getFluxSigma(), ::sqrt(functor.getVarPositive()));
260  source.set(_numPositiveKey, functor.getNumPositive());
261 
262  source.set(getNegativeKeys().getFlux(), functor.getSumNegative());
263  source.set(getNegativeKeys().getFluxSigma(), ::sqrt(functor.getVarNegative()));
264  source.set(_numNegativeKey, functor.getNumNegative());
265 }
266 
268  _flagHandler.handleFailure(measRecord, error);
269 }
270 
271 
275 class MinimizeDipoleChi2 : public ROOT::Minuit2::FCNBase {
276 public:
277  explicit MinimizeDipoleChi2(PsfDipoleFlux const& psfDipoleFlux,
278  afw::table::SourceRecord & source,
279  afw::image::Exposure<float> const& exposure
280  ) : _errorDef(1.0),
281  _nPar(6),
282  _maxPix(1e4),
283  _bigChi2(1e10),
284  _psfDipoleFlux(psfDipoleFlux),
285  _source(source),
286  _exposure(exposure)
287  {}
288  double Up() const { return _errorDef; }
289  void setErrorDef(double def) { _errorDef = def; }
290  int getNpar() const { return _nPar; }
291  int getMaxPix() const { return _maxPix; }
292  void setMaxPix(int maxPix) { _maxPix = maxPix; }
293 
294  // Evaluate our cost function (in this case chi^2)
295  virtual double operator()(std::vector<double> const & params) const {
296  double negCenterX = params[NEGCENTXPAR];
297  double negCenterY = params[NEGCENTYPAR];
298  double negFlux = params[NEGFLUXPAR];
299  double posCenterX = params[POSCENTXPAR];
300  double posCenterY = params[POSCENTYPAR];
301  double posFlux = params[POSFLUXPAR];
302 
303  /* Restrict negative dipole to be negative; positive to be positive */
304  if ((negFlux > 0.0) || (posFlux < 0.0)) {
305  return _bigChi2;
306  }
307 
308  std::pair<double,int> fit = _psfDipoleFlux.chi2(_source, _exposure, negCenterX, negCenterY, negFlux,
309  posCenterX, posCenterY, posFlux);
310  double chi2 = fit.first;
311  int nPix = fit.second;
312  if (nPix > _maxPix) {
313  return _bigChi2;
314  }
315 
316  return chi2;
317  }
318 
319 private:
320  double _errorDef; // how much cost function has changed at the +- 1 error points
321  int _nPar; // number of parameters in the fit; hard coded for MinimizeDipoleChi2
322  int _maxPix; // maximum number of pixels that shoud be in the footprint;
323  // prevents too much centroid wander
324  double _bigChi2; // large value to tell fitter when it has gone into bad region of parameter space
325 
329 };
330 
331 std::pair<double,int> PsfDipoleFlux::chi2(
332  afw::table::SourceRecord & source,
333  afw::image::Exposure<float> const& exposure,
334  double negCenterX, double negCenterY, double negFlux,
335  double posCenterX, double posCenterY, double posFlux
336 ) const {
337 
338  afw::geom::Point2D negCenter(negCenterX, negCenterY);
339  afw::geom::Point2D posCenter(posCenterX, posCenterY);
340 
341  CONST_PTR(afw::detection::Footprint) footprint = source.getFootprint();
342 
343  /*
344  * Fit for the superposition of Psfs at the two centroids.
345  */
346  CONST_PTR(afwDet::Psf) psf = exposure.getPsf();
347  PTR(afwImage::Image<afwMath::Kernel::Pixel>) negPsf = psf->computeImage(negCenter);
348  PTR(afwImage::Image<afwMath::Kernel::Pixel>) posPsf = psf->computeImage(posCenter);
349 
350  afwImage::Image<double> negModel(footprint->getBBox());
351  afwImage::Image<double> posModel(footprint->getBBox());
352  afwImage::Image<float> data(*(exposure.getMaskedImage().getImage()),footprint->getBBox());
354  footprint->getBBox());
355 
356  afwGeom::Box2I negPsfBBox = negPsf->getBBox();
357  afwGeom::Box2I posPsfBBox = posPsf->getBBox();
358  afwGeom::Box2I negModelBBox = negModel.getBBox();
359  afwGeom::Box2I posModelBBox = posModel.getBBox();
360 
361  // Portion of the negative Psf that overlaps the model
362  int negXmin = std::max(negPsfBBox.getMinX(), negModelBBox.getMinX());
363  int negYmin = std::max(negPsfBBox.getMinY(), negModelBBox.getMinY());
364  int negXmax = std::min(negPsfBBox.getMaxX(), negModelBBox.getMaxX());
365  int negYmax = std::min(negPsfBBox.getMaxY(), negModelBBox.getMaxY());
366  afwGeom::Box2I negBBox = afwGeom::Box2I(afwGeom::Point2I(negXmin, negYmin),
367  afwGeom::Point2I(negXmax, negYmax));
368  afwImage::Image<afwMath::Kernel::Pixel> negSubim(*negPsf, negBBox);
369  afwImage::Image<double> negModelSubim(negModel, negBBox);
370  negModelSubim += negSubim;
371 
372  // Portion of the positive Psf that overlaps the model
373  int posXmin = std::max(posPsfBBox.getMinX(), posModelBBox.getMinX());
374  int posYmin = std::max(posPsfBBox.getMinY(), posModelBBox.getMinY());
375  int posXmax = std::min(posPsfBBox.getMaxX(), posModelBBox.getMaxX());
376  int posYmax = std::min(posPsfBBox.getMaxY(), posModelBBox.getMaxY());
377  afwGeom::Box2I posBBox = afwGeom::Box2I(afwGeom::Point2I(posXmin, posYmin),
378  afwGeom::Point2I(posXmax, posYmax));
379  afwImage::Image<afwMath::Kernel::Pixel> posSubim(*posPsf, posBBox);
380  afwImage::Image<double> posModelSubim(posModel, posBBox);
381  posModelSubim += posSubim;
382 
383  negModel *= negFlux; // scale negative model to image
384  posModel *= posFlux; // scale positive model to image
385  afwImage::Image<double> residuals(negModel, true); // full model contains negative lobe...
386  residuals += posModel; // plus positive lobe...
387  residuals -= data; // minus the data...
388  residuals *= residuals; // squared...
389  residuals /= var; // divided by the variance : [(model-data)/sigma]**2
391  double chi2 = stats.getValue(afwMath::SUM);
392  int nPix = stats.getValue(afwMath::NPOINT);
393  return std::pair<double,int>(chi2, nPix);
394 }
395 
397  afw::table::SourceRecord & source,
398  afw::image::Exposure<float> const & exposure
399 ) const {
400 
401  typedef afw::image::Exposure<float>::MaskedImageT MaskedImageT;
402 
403  CONST_PTR(afw::detection::Footprint) footprint = source.getFootprint();
404  if (!footprint) {
405  throw LSST_EXCEPT(pex::exceptions::RuntimeError,
406  (boost::format("No footprint for source %d") % source.getId()).str());
407  }
408 
409  afw::detection::PeakCatalog peakCatalog = afw::detection::PeakCatalog(footprint->getPeaks());
410 
411  if (peakCatalog.size() == 0) {
412  throw LSST_EXCEPT(pex::exceptions::RuntimeError,
413  (boost::format("No peak for source %d") % source.getId()).str());
414  }
415  else if (peakCatalog.size() == 1) {
416  // No deblending to do
417  return;
418  }
419 
420  // For N>=2, just measure the brightest-positive and brightest-negative
421  // peaks. peakCatalog is automatically ordered by peak flux, with the most
422  // positive one (brightest) being first
423  afw::detection::PeakRecord const& positivePeak = peakCatalog.front();
424  afw::detection::PeakRecord const& negativePeak = peakCatalog.back();
425 
426  // Set up fit parameters and param names
427  ROOT::Minuit2::MnUserParameters fitPar;
428 
429  fitPar.Add((boost::format("P%d")%NEGCENTXPAR).str(), negativePeak.getFx(), _ctrl.stepSizeCoord);
430  fitPar.Add((boost::format("P%d")%NEGCENTYPAR).str(), negativePeak.getFy(), _ctrl.stepSizeCoord);
431  fitPar.Add((boost::format("P%d")%NEGFLUXPAR).str(), negativePeak.getPeakValue(), _ctrl.stepSizeFlux);
432  fitPar.Add((boost::format("P%d")%POSCENTXPAR).str(), positivePeak.getFx(), _ctrl.stepSizeCoord);
433  fitPar.Add((boost::format("P%d")%POSCENTYPAR).str(), positivePeak.getFy(), _ctrl.stepSizeCoord);
434  fitPar.Add((boost::format("P%d")%POSFLUXPAR).str(), positivePeak.getPeakValue(), _ctrl.stepSizeFlux);
435 
436  // Create the minuit object that knows how to minimise our functor
437  //
438  MinimizeDipoleChi2 minimizerFunc(*this, source, exposure);
439  minimizerFunc.setErrorDef(_ctrl.errorDef);
440 
441  //
442  // tell minuit about it
443  //
444  ROOT::Minuit2::MnMigrad migrad(minimizerFunc, fitPar);
445 
446  //
447  // And let it loose
448  //
449  ROOT::Minuit2::FunctionMinimum min = migrad(_ctrl.maxFnCalls);
450 
451  float minChi2 = min.Fval();
452  bool const isValid = min.IsValid() && std::isfinite(minChi2);
453 
454  if (true || isValid) { // calculate coeffs even in minuit is unhappy
455 
456  /* I need to call chi2 one more time to grab nPix to calculate chi2/dof.
457  Turns out that the Minuit operator method has to be const, and the
458  measurement _apply method has to be const, so I can't store nPix as a
459  private member variable anywhere. Consted into a corner.
460  */
461  std::pair<double,int> fit = chi2(source, exposure,
462  min.UserState().Value(NEGCENTXPAR),
463  min.UserState().Value(NEGCENTYPAR),
464  min.UserState().Value(NEGFLUXPAR),
465  min.UserState().Value(POSCENTXPAR),
466  min.UserState().Value(POSCENTYPAR),
467  min.UserState().Value(POSFLUXPAR));
468  double evalChi2 = fit.first;
469  int nPix = fit.second;
470 
471  PTR(afw::geom::Point2D) minNegCentroid(new afw::geom::Point2D(min.UserState().Value(NEGCENTXPAR),
472  min.UserState().Value(NEGCENTYPAR)));
473  source.set(getNegativeKeys().getFlux(), min.UserState().Value(NEGFLUXPAR));
474  source.set(getNegativeKeys().getFluxSigma(), min.UserState().Error(NEGFLUXPAR));
475 
476  PTR(afw::geom::Point2D) minPosCentroid(new afw::geom::Point2D(min.UserState().Value(POSCENTXPAR),
477  min.UserState().Value(POSCENTYPAR)));
478  source.set(getPositiveKeys().getFlux(), min.UserState().Value(POSFLUXPAR));
479  source.set(getPositiveKeys().getFluxSigma(), min.UserState().Error(POSFLUXPAR));
480 
481  source.set(_chi2dofKey, evalChi2 / (nPix - minimizerFunc.getNpar()));
482  source.set(_negCentroid.getX(), minNegCentroid->getX());
483  source.set(_negCentroid.getY(), minNegCentroid->getY());
484  source.set(_posCentroid.getX(), minPosCentroid->getX());
485  source.set(_posCentroid.getY(), minPosCentroid->getY());
486  source.set(_avgCentroid.getX(), 0.5*(minNegCentroid->getX() + minPosCentroid->getX()));
487  source.set(_avgCentroid.getY(), 0.5*(minNegCentroid->getY() + minPosCentroid->getY()));
488 
489  }
490 }
491 
493  _flagHandler.handleFailure(measRecord, error);
494 }
495 }}} // 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; ;
An include file to include the header files for lsst::afw::geom.
double _sumNegative
meas::base::CentroidResultKey _avgCentroid
int const NEGFLUXPAR(2)
Implementation of Psf dipole flux.
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
int getMinY() const
Definition: Box.h:125
afw::table::Key< int > _numNegativeKey
ResultKey const & getCenterKeys() const
Return the standard centroid keys registered by this algorithm.
afw::table::Key< CentroidElement > getY() const
Return a Key for the y coordinate.
double _varNegative
afw::table::Schema schema
Definition: GaussianPsf.cc:41
Include files required for standard LSST Exception handling.
PixelT Pixel
A pixel in this ImageBase.
Definition: Image.h:132
int const NEGCENTXPAR(0)
reference back() const
Return the last record.
Definition: Catalog.h:437
MinimizeDipoleChi2(PsfDipoleFlux const &psfDipoleFlux, afw::table::SourceRecord &source, afw::image::Exposure< float > const &exposure)
ImagePtr getImage(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage&#39;s image.
Definition: MaskedImage.h:875
size_type size() const
Return the number of elements in the catalog.
Definition: Catalog.h:402
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...
meas::base::CentroidResultKey _negCentroid
Point< int, 2 > Point2I
Definition: Point.h:285
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.
void set(Key< T > const &key, U const &value)
Set value of a field for the given key.
Definition: BaseRecord.h:145
ResultKey const & getNegativeKeys() const
A class to evaluate image statistics.
Definition: Statistics.h:212
An integer coordinate rectangle.
Definition: Box.h:53
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...
int getMinX() const
Definition: Box.h:124
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.
int getMaxX() const
Definition: Box.h:128
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::CatalogT< PeakRecord > PeakCatalog
Definition: Peak.h:225
MaskedImageT getMaskedImage()
Return the MaskedImage.
Definition: Exposure.h:153
Class to minimize PsfDipoleFlux; this is the object that Minuit minimizes.
An include file to include the header files for lsst::afw::detection.
afw::table::Key< CentroidElement > getX() const
Return a Key for the x coordinate.
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
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; ;
double x
Field< T >::Value get(Key< T > const &key) const
Return the value of a field for the given key.
Definition: BaseRecord.h:132
int _numPositive
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...
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
Handle an exception thrown by the current algorithm by setting flags in the given record...
RecordId getId() const
Convenience accessors for the keys in the minimal reference schema.
Definition: Simple.h:204
boost::shared_ptr< lsst::afw::detection::Psf > getPsf()
Return the Exposure&#39;s Psf object.
Definition: Exposure.h:227
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
int const POSFLUXPAR(5)
int _numNegative
int const NEGCENTYPAR(1)
#define PTR(...)
Definition: base.h:41
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; ;
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
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 handleFailure(afw::table::BaseRecord &record, MeasurementError const *error=NULL) const
Handle an expected or unexpected Exception thrown by a measurement algorithm.
Definition: FlagHandler.cc:77
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
afw::table::Key< int > _numPositiveKey
find sum of pixels in the image
Definition: Statistics.h:78
int getMaxY() const
Definition: Box.h:129
reference front() const
Return the first record.
Definition: Catalog.h:434
#define CONST_PTR(...)
A shared pointer to a const object.
Definition: base.h:47
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.
boost::shared_ptr< Footprint > getFootprint() const
Definition: Source.h:88
A class to represent a 2-dimensional array of pixels.
Definition: Image.h:416
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...