LSSTApplications  8.0.0.0+107,8.0.0.1+13,9.1+18,9.2,master-g084aeec0a4,master-g0aced2eed8+6,master-g15627eb03c,master-g28afc54ef9,master-g3391ba5ea0,master-g3d0fb8ae5f,master-g4432ae2e89+36,master-g5c3c32f3ec+17,master-g60f1e072bb+1,master-g6a3ac32d1b,master-g76a88a4307+1,master-g7bce1f4e06+57,master-g8ff4092549+31,master-g98e65bf68e,master-ga6b77976b1+53,master-gae20e2b580+3,master-gb584cd3397+53,master-gc5448b162b+1,master-gc54cf9771d,master-gc69578ece6+1,master-gcbf758c456+22,master-gcec1da163f+63,master-gcf15f11bcc,master-gd167108223,master-gf44c96c709
LSSTDataManagementBasePackage
dipoleAlgorithm.cc
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2008-2013 LSST Corporation.
6  *
7  * This product includes software developed by the
8  * LSST Project (http://www.lsst.org/).
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the LSST License Statement and
21  * the GNU General Public License along with this program. If not,
22  * see <http://www.lsstcorp.org/LegalNotices/>.
23  */
24 
28 #include <iostream> // std::cout
29 #include <algorithm> // std::sort
30 #include <functional> // std::binary_function
31 #include <limits> // std::numeric_limits
32 #include <cmath> // std::sqrt
33 
34 #if !defined(DOXYGEN)
35 # include "Minuit2/FCNBase.h"
36 # include "Minuit2/FunctionMinimum.h"
37 # include "Minuit2/MnMigrad.h"
38 # include "Minuit2/MnMinos.h"
39 # include "Minuit2/MnPrint.h"
40 #endif
41 
42 #include "boost/shared_ptr.hpp"
43 #include "lsst/pex/exceptions.h"
44 #include "lsst/pex/logging/Trace.h"
45 #include "lsst/afw/image.h"
46 #include "lsst/afw/detection.h"
47 #include "lsst/afw/detection/FootprintArray.cc"
48 #include "lsst/afw/table.h"
49 #include "lsst/afw/math.h"
50 #include "lsst/afw/geom.h"
51 #include "lsst/meas/algorithms.h"
53 #include "ndarray/eigen.h"
54 
55 namespace pexExceptions = lsst::pex::exceptions;
56 namespace pexLogging = lsst::pex::logging;
57 namespace afwDet = lsst::afw::detection;
58 namespace afwImage = lsst::afw::image;
59 namespace afwTable = lsst::afw::table;
60 namespace afwMath = lsst::afw::math;
61 namespace afwGeom = lsst::afw::geom;
62 namespace measAlgorithms = lsst::meas::algorithms;
63 
64 namespace lsst {
65 namespace ip {
66 namespace diffim {
67 
68  int const NEGCENTXPAR(0); // Parameter for the x-component of the negative lobe centroid
69  int const NEGCENTYPAR(1); // Parameter for the y-component of the negative lobe centroid
70  int const NEGFLUXPAR(2); // Parameter for the flux of the negative lobe
71  int const POSCENTXPAR(3); // Parameter for the x-component of the positive lobe centroid
72  int const POSCENTYPAR(4); // Parameter for the y-component of the positive lobe centroid
73  int const POSFLUXPAR(5); // Parameter for the flux of the positive lobe
74 
80 public:
81 
83  DipoleCentroidAlgorithm(ctrl, schema, "unweighted 3x3 first moment centroid")
84  {}
85 
86 private:
87 
88  template <typename PixelT>
89  void _apply(
90  afw::table::SourceRecord & source,
91  afw::image::Exposure<PixelT> const & exposure,
92  afw::geom::Point2D const & center
93  ) const;
94 
96 };
97 
103 public:
104 
106  DipoleFluxAlgorithm(ctrl, schema, "raw flux counts"),
107  _numPositiveKey(schema.addField<int>(ctrl.name+".npos", "number of positive pixels", "dn")),
108  _numNegativeKey(schema.addField<int>(ctrl.name+".nneg", "number of negative pixels", "dn"))
109  {}
110 
111 private:
112  template <typename PixelT>
113  void _apply(
114  afw::table::SourceRecord & source,
115  afw::image::Exposure<PixelT> const & exposure,
116  afw::geom::Point2D const & center
117  ) const;
118 
120 
123 };
124 
125 
126 
127 namespace {
128 
129 template<typename PixelT>
130 void naiveCentroid(
131  afw::table::SourceRecord & source,
132  afw::image::Exposure<PixelT> const& exposure,
133  afw::geom::Point2I const & center,
135  )
136 {
137  source.set(keys.meas, afw::geom::Point2D(center));
138  typedef afw::image::Image<PixelT> ImageT;
139  ImageT const& image = *exposure.getMaskedImage().getImage();
140 
141  int x = center.getX() - image.getX0();
142  int y = center.getY() - image.getY0();
143 
144  if (x < 1 || x >= image.getWidth() - 1 || y < 1 || y >= image.getHeight() - 1) {
145  throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
146  (boost::format("Object at (%d, %d) is too close to the edge")
147  % x % y).str());
148  }
149 
150  typename ImageT::xy_locator im = image.xy_at(x, y);
151 
152  double const sum =
153  (im(-1, 1) + im( 0, 1) + im( 1, 1) +
154  im(-1, 0) + im( 0, 0) + im( 1, 0) +
155  im(-1, -1) + im( 0, -1) + im( 1, -1));
156 
157 
158  if (sum == 0.0) {
159  throw LSST_EXCEPT(pexExceptions::RuntimeError,
160  (boost::format("Object at (%d, %d) has no counts") %
161  x % y).str());
162  }
163 
164  double const sum_x =
165  -im(-1, 1) + im( 1, 1) +
166  -im(-1, 0) + im( 1, 0) +
167  -im(-1, -1) + im( 1, -1);
168  double const sum_y =
169  (im(-1, 1) + im( 0, 1) + im( 1, 1)) -
170  (im(-1, -1) + im( 0, -1) + im( 1, -1));
171 
172  source.set(keys.flag, false);
173  source.set(
174  keys.meas,
176  lsst::afw::image::indexToPosition(x + image.getX0()) + sum_x / sum,
177  lsst::afw::image::indexToPosition(y + image.getY0()) + sum_y / sum
178  )
179  );
180 }
181 
182 } // anonymous namespace
183 
184 
188 template<typename PixelT>
190  afw::table::SourceRecord & source,
191  afw::image::Exposure<PixelT> const& exposure,
192  afw::geom::Point2D const & center
193 ) const {
194  source.set(getPositiveKeys().flag, true); // say we've failed so that's the result if we throw
195  source.set(getNegativeKeys().flag, true); // say we've failed so that's the result if we throw
196 
197  afw::detection::Footprint::PeakList const& peaks = source.getFootprint()->getPeaks();
198 
199  naiveCentroid(source, exposure, peaks[0]->getI(), (peaks[0]->getPeakValue() >= 0 ?
200  getPositiveKeys() :
201  getNegativeKeys()));
202  if (peaks.size() > 1) {
203  naiveCentroid(source, exposure, peaks[1]->getI(), (peaks[1]->getPeakValue() >= 0 ?
204  getPositiveKeys() :
205  getNegativeKeys()));
206  }
207 }
208 
210 
212  return boost::make_shared<NaiveDipoleCentroidControl>(*this);
213 }
214 
216  afw::table::Schema & schema,
217  PTR(daf::base::PropertyList) const &
218 ) const {
219  return boost::make_shared<NaiveDipoleCentroid>(*this, boost::ref(schema));
220 }
221 
222 
223 
224 namespace {
225 
226 template <typename MaskedImageT>
227 class NaiveDipoleFootprinter : public afw::detection::FootprintFunctor<MaskedImageT> {
228 public:
229  explicit NaiveDipoleFootprinter(MaskedImageT const& mimage
230  ) : afw::detection::FootprintFunctor<MaskedImageT>(mimage),
231  _sumPositive(0.0), _sumNegative(0.0), _numPositive(0), _numNegative(0) {}
232 
234  void reset() {
235  _sumPositive = _sumNegative = 0.0;
237  }
238  void reset(afwDet::Footprint const&) {}
239 
241  void operator()(typename MaskedImageT::xy_locator loc,
242  int,
243  int
244  ) {
245  typename MaskedImageT::Image::Pixel ival = loc.image(0, 0);
246  typename MaskedImageT::Image::Pixel vval = loc.variance(0, 0);
247  if (ival >= 0.0) {
248  _sumPositive += ival;
249  _varPositive += vval;
250  ++_numPositive;
251  } else {
252  _sumNegative += ival;
253  _varPositive += vval;
254  ++_numNegative;
255  }
256  }
257 
258  double getSumPositive() const { return _sumPositive; }
259  double getSumNegative() const { return _sumNegative; }
260  double getVarPositive() const { return _sumPositive; }
261  double getVarNegative() const { return _sumNegative; }
262  int getNumPositive() const { return _numPositive; }
263  int getNumNegative() const { return _numNegative; }
264 
265 private:
266  double _sumPositive;
267  double _sumNegative;
268  double _varPositive;
269  double _varNegative;
272 };
273 
274 } // anonymous namespace
275 
276 
277 
281 template<typename PixelT>
283  afw::table::SourceRecord & source,
284  afw::image::Exposure<PixelT> const& exposure,
285  afw::geom::Point2D const & center
286 ) const {
287  source.set(getPositiveKeys().flag, true); // say we've failed so that's the result if we throw
288  source.set(getNegativeKeys().flag, true); // say we've failed so that's the result if we throw
289 
290  typedef typename afw::image::Exposure<PixelT>::MaskedImageT MaskedImageT;
291 
292  NaiveDipoleFootprinter<MaskedImageT> functor(exposure.getMaskedImage());
293  functor.apply(*source.getFootprint());
294 
295  source.set(getPositiveKeys().meas, functor.getSumPositive());
296  source.set(getPositiveKeys().err, ::sqrt(functor.getVarPositive()));
297  source.set(_numPositiveKey, functor.getNumPositive());
298  source.set(getPositiveKeys().flag, false);
299 
300  source.set(getNegativeKeys().meas, functor.getSumNegative());
301  source.set(getNegativeKeys().err, ::sqrt(functor.getVarNegative()));
302  source.set(_numNegativeKey, functor.getNumNegative());
303  source.set(getNegativeKeys().flag, false);
304 }
305 
307 
309  return boost::make_shared<NaiveDipoleFluxControl>(*this);
310 }
311 
313  afw::table::Schema & schema,
314  PTR(daf::base::PropertyList) const &
315 ) const {
316  return boost::make_shared<NaiveDipoleFlux>(*this, boost::ref(schema));
317 }
318 
319 
320 
325 public:
326 
328  DipoleFluxAlgorithm(ctrl, schema, "jointly fitted psf flux counts"),
329  _chi2dofKey(schema.addField<float>(ctrl.name+".chi2dof",
330  "chi2 per degree of freedom of fit")),
331  _avgCentroid(
332  addCentroidFields(schema, ctrl.name+".centroid",
333  "average of the postive and negative lobe positions")),
334  _negCentroid(
335  addCentroidFields(schema, ctrl.name+".neg.centroid",
336  "psf fitted center of negative lobe")),
337  _posCentroid(
338  addCentroidFields(schema, ctrl.name+".pos.centroid",
339  "psf fitted center of positive lobe")),
340  _flagMaxPixelsKey(schema.addField<afw::table::Flag>(ctrl.name+".flags.maxpix",
341  "set if too large a footprint was sent to the algorithm"))
342  {}
343  template <typename PixelT>
344  std::pair<double,int> chi2(afw::table::SourceRecord & source,
345  afw::image::Exposure<PixelT> const & exposure,
346  double negCenterX, double negCenterY, double negFlux,
347  double posCenterX, double poCenterY, double posFlux
348  ) const;
349 
350 
351 private:
352  template <typename PixelT>
353  void _apply(
354  afw::table::SourceRecord & source,
355  afw::image::Exposure<PixelT> const & exposure,
356  afw::geom::Point2D const & center
357  ) const;
358 
360 
365 
367 };
368 
372 template<typename PixelT>
373 class MinimizeDipoleChi2 : public ROOT::Minuit2::FCNBase {
374 public:
375  explicit MinimizeDipoleChi2(PsfDipoleFlux const& psfDipoleFlux,
376  afw::table::SourceRecord & source,
377  afw::image::Exposure<PixelT> const& exposure
378  ) : _errorDef(1.0),
379  _nPar(6),
380  _maxPix(1e4),
381  _bigChi2(1e10),
382  _psfDipoleFlux(psfDipoleFlux),
383  _source(source),
384  _exposure(exposure)
385  {}
386  double Up() const { return _errorDef; }
387  void setErrorDef(double def) { _errorDef = def; }
388  int getNpar() const { return _nPar; }
389  int getMaxPix() const { return _maxPix; }
390  void setMaxPix(int maxPix) { _maxPix = maxPix; }
391 
392  // Evaluate our cost function (in this case chi^2)
393  virtual double operator()(std::vector<double> const & params) const {
394  double negCenterX = params[NEGCENTXPAR];
395  double negCenterY = params[NEGCENTYPAR];
396  double negFlux = params[NEGFLUXPAR];
397  double posCenterX = params[POSCENTXPAR];
398  double posCenterY = params[POSCENTYPAR];
399  double posFlux = params[POSFLUXPAR];
400 
401  /* Restrict negative dipole to be negative; positive to be positive */
402  if ((negFlux > 0.0) || (posFlux < 0.0)) {
403  return _bigChi2;
404  }
405 
406  std::pair<double,int> fit = _psfDipoleFlux.chi2(_source, _exposure, negCenterX, negCenterY, negFlux, posCenterX, posCenterY, posFlux);
407  double chi2 = fit.first;
408  int nPix = fit.second;
409  if (nPix > _maxPix) {
410  return _bigChi2;
411  }
412 
413  return chi2;
414  }
415 
416 private:
417  double _errorDef; // how much cost function has changed at the +- 1 error points
418  int _nPar; // number of parameters in the fit; hard coded for MinimizeDipoleChi2
419  int _maxPix; // maximum number of pixels that shoud be in the footprint; prevents too much centroid wander
420  double _bigChi2; // large value to tell fitter when it has gone into bad region of parameter space
421 
425 };
426 
427 template<typename PixelT>
428 std::pair<double,int> PsfDipoleFlux::chi2(
429  afw::table::SourceRecord & source,
430  afw::image::Exposure<PixelT> const& exposure,
431  double negCenterX, double negCenterY, double negFlux,
432  double posCenterX, double posCenterY, double posFlux
433 ) const {
434 
435  afw::geom::Point2D negCenter(negCenterX, negCenterY);
436  afw::geom::Point2D posCenter(posCenterX, posCenterY);
437 
438  CONST_PTR(afw::detection::Footprint) footprint = source.getFootprint();
439 
440  /* Fit for the superposition of Psfs at the two centroids.
441  *
442  */
443  CONST_PTR(afwDet::Psf) psf = exposure.getPsf();
444  PTR(afwImage::Image<afwMath::Kernel::Pixel>) negPsf = psf->computeImage(negCenter);
445  PTR(afwImage::Image<afwMath::Kernel::Pixel>) posPsf = psf->computeImage(posCenter);
446 
447  afwImage::Image<double> negModel(footprint->getBBox());
448  afwImage::Image<double> posModel(footprint->getBBox());
449  afwImage::Image<PixelT> data(*(exposure.getMaskedImage().getImage()),
450  footprint->getBBox());
452  footprint->getBBox());
453 
454  afwGeom::Box2I negPsfBBox = negPsf->getBBox();
455  afwGeom::Box2I posPsfBBox = posPsf->getBBox();
456  afwGeom::Box2I negModelBBox = negModel.getBBox();
457  afwGeom::Box2I posModelBBox = posModel.getBBox();
458 
459  // Portion of the negative Psf that overlaps the model
460  int negXmin = std::max(negPsfBBox.getMinX(), negModelBBox.getMinX());
461  int negYmin = std::max(negPsfBBox.getMinY(), negModelBBox.getMinY());
462  int negXmax = std::min(negPsfBBox.getMaxX(), negModelBBox.getMaxX());
463  int negYmax = std::min(negPsfBBox.getMaxY(), negModelBBox.getMaxY());
464  afwGeom::Box2I negBBox = afwGeom::Box2I(afwGeom::Point2I(negXmin, negYmin),
465  afwGeom::Point2I(negXmax, negYmax));
466  afwImage::Image<afwMath::Kernel::Pixel> negSubim(*negPsf, negBBox);
467  afwImage::Image<double> negModelSubim(negModel, negBBox);
468  negModelSubim += negSubim;
469 
470  // Portion of the positive Psf that overlaps the model
471  int posXmin = std::max(posPsfBBox.getMinX(), posModelBBox.getMinX());
472  int posYmin = std::max(posPsfBBox.getMinY(), posModelBBox.getMinY());
473  int posXmax = std::min(posPsfBBox.getMaxX(), posModelBBox.getMaxX());
474  int posYmax = std::min(posPsfBBox.getMaxY(), posModelBBox.getMaxY());
475  afwGeom::Box2I posBBox = afwGeom::Box2I(afwGeom::Point2I(posXmin, posYmin),
476  afwGeom::Point2I(posXmax, posYmax));
477  afwImage::Image<afwMath::Kernel::Pixel> posSubim(*posPsf, posBBox);
478  afwImage::Image<double> posModelSubim(posModel, posBBox);
479  posModelSubim += posSubim;
480 
481  negModel *= negFlux; // scale negative model to image
482  posModel *= posFlux; // scale positive model to image
483  afwImage::Image<double> residuals(negModel, true); // full model contains negative lobe...
484  residuals += posModel; // plus positive lobe...
485  residuals -= data; // minus the data...
486  residuals *= residuals;// squared...
487  residuals /= var; // divided by the variance : [(model-data)/sigma]**2
489  double chi2 = stats.getValue(afwMath::SUM);
490  int nPix = stats.getValue(afwMath::NPOINT);
491  return std::pair<double,int>(chi2, nPix);
492 }
493 
494 template<typename PixelT>
496  afw::table::SourceRecord & source,
497  afw::image::Exposure<PixelT> const& exposure,
498  afw::geom::Point2D const & center // Not used; source required to have footprint&peaks
499 ) const {
500 
501  source.set(getPositiveKeys().flag, true); // say we've failed so that's the result if we throw
502  source.set(getNegativeKeys().flag, true); // say we've failed so that's the result if we throw
503  source.set(_flagMaxPixelsKey, true);
504 
505  typedef typename afw::image::Exposure<PixelT>::MaskedImageT MaskedImageT;
506 
507  CONST_PTR(afw::detection::Footprint) footprint = source.getFootprint();
508  if (!footprint) {
509  throw LSST_EXCEPT(pex::exceptions::RuntimeError,
510  (boost::format("No footprint for source %d") % source.getId()).str());
511  }
512 
513  PsfDipoleFluxControl const & ctrl = static_cast<PsfDipoleFluxControl const &>(getControl());
514  if (footprint->getArea() > ctrl.maxPixels) {
515  // Too big
516  return;
517  }
518  source.set(_flagMaxPixelsKey, false);
519 
521  afw::detection::Footprint::PeakList(footprint->getPeaks());
522 
523  if (peakList.size() == 0) {
524  throw LSST_EXCEPT(pex::exceptions::RuntimeError,
525  (boost::format("No peak for source %d") % source.getId()).str());
526  }
527  else if (peakList.size() == 1) {
528  // No deblending to do
529  return;
530  }
531 
532  // For N>=2, just measure the brightest-positive and brightest-negative
533  // peaks. peakList is automatically ordered by peak flux, with the most
534  // positive one (brightest) being first
535  PTR(afw::detection::Peak) positivePeak = peakList.front();
536  PTR(afw::detection::Peak) negativePeak = peakList.back();
537 
538  // Set up fit parameters and param names
539  ROOT::Minuit2::MnUserParameters fitPar;
540 
541  fitPar.Add((boost::format("P%d")%NEGCENTXPAR).str(), negativePeak->getFx(), ctrl.stepSizeCoord);
542  fitPar.Add((boost::format("P%d")%NEGCENTYPAR).str(), negativePeak->getFy(), ctrl.stepSizeCoord);
543  fitPar.Add((boost::format("P%d")%NEGFLUXPAR).str(), negativePeak->getPeakValue(), ctrl.stepSizeFlux);
544  fitPar.Add((boost::format("P%d")%POSCENTXPAR).str(), positivePeak->getFx(), ctrl.stepSizeCoord);
545  fitPar.Add((boost::format("P%d")%POSCENTYPAR).str(), positivePeak->getFy(), ctrl.stepSizeCoord);
546  fitPar.Add((boost::format("P%d")%POSFLUXPAR).str(), positivePeak->getPeakValue(), ctrl.stepSizeFlux);
547 
548  // Create the minuit object that knows how to minimise our functor
549  //
550  MinimizeDipoleChi2<PixelT> minimizerFunc(*this, source, exposure);
551  minimizerFunc.setErrorDef(ctrl.errorDef);
552 
553  //
554  // tell minuit about it
555  //
556  ROOT::Minuit2::MnMigrad migrad(minimizerFunc, fitPar);
557 
558  //
559  // And let it loose
560  //
561  ROOT::Minuit2::FunctionMinimum min = migrad(ctrl.maxFnCalls);
562 
563  float minChi2 = min.Fval();
564  bool const isValid = min.IsValid() && std::isfinite(minChi2);
565 
566  if (true || isValid) { // calculate coeffs even in minuit is unhappy
567 
568  /* I need to call chi2 one more time to grab nPix to calculate chi2/dof.
569  Turns out that the Minuit operator method has to be const, and the
570  measurement _apply method has to be const, so I can't store nPix as a
571  private member variable anywhere. Consted into a corner.
572  */
573  std::pair<double,int> fit = chi2(source, exposure,
574  min.UserState().Value(NEGCENTXPAR), min.UserState().Value(NEGCENTYPAR),
575  min.UserState().Value(NEGFLUXPAR), min.UserState().Value(POSCENTXPAR),
576  min.UserState().Value(POSCENTYPAR), min.UserState().Value(POSFLUXPAR));
577  double evalChi2 = fit.first;
578  int nPix = fit.second;
579 
580  PTR(afw::geom::Point2D) minNegCentroid(new afw::geom::Point2D(min.UserState().Value(NEGCENTXPAR),
581  min.UserState().Value(NEGCENTYPAR)));
582  source.set(getNegativeKeys().meas, min.UserState().Value(NEGFLUXPAR));
583  source.set(getNegativeKeys().err, min.UserState().Error(NEGFLUXPAR));
584  source.set(getNegativeKeys().flag, false);
585 
586  PTR(afw::geom::Point2D) minPosCentroid(new afw::geom::Point2D(min.UserState().Value(POSCENTXPAR),
587  min.UserState().Value(POSCENTYPAR)));
588  source.set(getPositiveKeys().meas, min.UserState().Value(POSFLUXPAR));
589  source.set(getPositiveKeys().err, min.UserState().Error(POSFLUXPAR));
590  source.set(getPositiveKeys().flag, false);
591 
592  source.set(_chi2dofKey, evalChi2 / (nPix - minimizerFunc.getNpar()));
593  source.set(_negCentroid.meas, *minNegCentroid);
594  source.set(_posCentroid.meas, *minPosCentroid);
595  source.set(_avgCentroid.meas,
596  afw::geom::Point2D(0.5*(minNegCentroid->getX() + minPosCentroid->getX()),
597  0.5*(minNegCentroid->getY() + minPosCentroid->getY())));
598 
599  }
600 
601 }
602 
604 
606  return boost::make_shared<PsfDipoleFluxControl>(*this);
607 }
608 
610  afw::table::Schema & schema,
611  PTR(daf::base::PropertyList) const &
612 ) const {
613  return boost::make_shared<PsfDipoleFlux>(*this, boost::ref(schema));
614 }
615 
616 
617 
618 }}} // namespace lsst::ip::diffim
An include file to include the public header files for lsst::afw::math.
Defines the fields and offsets for a table.
Definition: Schema.h:46
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.
int const NEGFLUXPAR(2)
#define PTR(...)
Definition: base.h:41
double indexToPosition(double ind)
Convert image index to image position.
Definition: ImageUtils.h:54
Eigen matrix objects that present a view into an ndarray::Array.
int y
afw::table::Key< int > _numNegativeKey
Class for storing ordered metadata with comments.
Definition: PropertyList.h:81
KeyTuple const & getNegativeKeys() const
C++ control object for naive dipole centroid.
NaiveDipoleCentroid(NaiveDipoleCentroidControl const &ctrl, afw::table::Schema &schema)
definition of the Trace messaging facilities
KeyTuple const & getPositiveKeys() const
Return the standard centroid keys registered by this algorithm.
int const NEGCENTXPAR(0)
double _varNegative
double _varPositive
boost::shared_ptr< Footprint > getFootprint() const
Definition: Source.h:89
ImagePtr getImage(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage&#39;s image.
Definition: MaskedImage.h:869
LSST_MEAS_ALGORITHM_PRIVATE_INTERFACE(NaiveDipoleCentroid)
std::vector< Peak::Ptr > PeakList
Definition: Footprint.h:83
Key< Flag > flag
Failure bit; set if the measurement did not fully succeed.
Definition: slots.h:258
void _apply(afw::table::SourceRecord &source, afw::image::Exposure< PixelT > const &exposure, afw::geom::Point2D const &center) const
C++ control object for PSF dipole fluxes.
afw::image::Exposure< PixelT > const & _exposure
void _apply(afw::table::SourceRecord &source, afw::image::Exposure< PixelT > const &exposure, afw::geom::Point2D const &center) const
LSST_MEAS_ALGORITHM_PRIVATE_IMPLEMENTATION(NaiveDipoleCentroid)
An integer coordinate rectangle.
Definition: Box.h:53
double min
Definition: attributes.cc:216
LSST_MEAS_ALGORITHM_PRIVATE_INTERFACE(NaiveDipoleFlux)
int const POSCENTXPAR(3)
VariancePtr getVariance(bool const noThrow=false) const
Return a (Ptr to) the MaskedImage&#39;s variance.
Definition: MaskedImage.h:890
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
MeasurementT::MeasKey meas
Key used for the measured value.
Definition: slots.h:256
int maxPixels
&quot;Maximum number of pixels to apply the measurement to&quot; ;
double _sumNegative
double getValue(Property const prop=NOTHING) const
Return the value of the desired property (if specified in the constructor)
Definition: Statistics.cc:950
An include file to include the header files for lsst::afw::image.
afw::table::KeyTuple< afw::table::Centroid > _posCentroid
Base class for source measurement algorithms.
Definition: Algorithm.h:106
PsfDipoleFlux(PsfDipoleFluxControl const &ctrl, afw::table::Schema &schema)
Base class for measurement algorithm control objects.
Definition: Algorithm.h:168
double max
Definition: attributes.cc:218
A peak in an image.
Definition: Peak.h:51
DipoleFluxControl const & getControl() const
Return a clone of the control object used to construct the algorithm.
Include files required for standard LSST Exception handling.
MaskedImageT getMaskedImage()
Return the MaskedImage.
Definition: Exposure.h:150
tbl::Schema schema
Definition: CoaddPsf.cc:324
virtual double operator()(std::vector< double > const &params) const
int x
An include file to include the header files for lsst::afw::detection.
int getMinY() const
Definition: Box.h:125
KeyTuple const & getNegativeKeys() const
number of sample points
Definition: Statistics.h:66
LSST_MEAS_ALGORITHM_PRIVATE_INTERFACE(PsfDipoleFlux)
int getMinX() const
Definition: Box.h:124
RecordId getId() const
Convenience accessors for the keys in the minimal reference schema.
Definition: Simple.h:203
int const POSCENTYPAR(4)
double errorDef
&quot;How many sigma the error bars of the non-linear fitter represent&quot; ;
afw::table::SourceRecord & _source
Intermediate base class for algorithms that compute a flux.
double sum
Definition: NaiveFlux.cc:137
#define CONST_PTR(...)
Definition: base.h:47
A set of pixels in an Image.
Definition: Footprint.h:73
Intermediate base class for algorithms that compute a centroid.
int maxFnCalls
&quot;Maximum function calls for non-linear fitter; 0 = unlimited&quot; ;
int isfinite(T t)
Definition: ieee.h:100
std::pair< double, int > chi2(afw::table::SourceRecord &source, afw::image::Exposure< PixelT > const &exposure, double negCenterX, double negCenterY, double negFlux, double posCenterX, double poCenterY, double posFlux) const
NaiveDipoleFlux(NaiveDipoleFluxControl const &ctrl, afw::table::Schema &schema)
boost::shared_ptr< lsst::afw::detection::Psf > getPsf()
Return the Exposure&#39;s Psf object.
Definition: Exposure.h:224
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
int const POSFLUXPAR(5)
int _numNegative
afw::table::KeyTuple< afw::table::Centroid > _avgCentroid
int const NEGCENTYPAR(1)
float stepSizeCoord
&quot;Default initial step size for coordinates in non-linear fitter&quot; ;
Statistics makeStatistics(afwImage::Mask< afwImage::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl)
Specialization to handle Masks.
Definition: Statistics.cc:1023
void set(Key< T > const &key, U const &value)
Set value of a field for the given key.
Definition: BaseRecord.h:136
KeyTuple< Centroid > addCentroidFields(Schema &schema, std::string const &name, std::string const &doc)
Convenience function to setup fields for centroid measurement algorithms.
Record class that contains measurements made on a single exposure.
Definition: Source.h:81
void _apply(afw::table::SourceRecord &source, afw::image::Exposure< PixelT > const &exposure, afw::geom::Point2D const &center) const
int getMaxX() const
Definition: Box.h:128
afw::table::Key< int > _numPositiveKey
find sum of pixels in the image
Definition: Statistics.h:78
KeyTuple const & getPositiveKeys() const
Return the standard flux keys registered by this algorithm.
afw::table::KeyTuple< afw::table::Centroid > _negCentroid
C++ control object for naive dipole fluxes.
A polymorphic base class for representing an image&#39;s Point Spread Function.
Definition: Psf.h:68
afw::table::Key< afw::table::Flag > _flagMaxPixelsKey
A functor class to allow users to process all the pixels in a Footprint.
MinimizeDipoleChi2(PsfDipoleFlux const &psfDipoleFlux, afw::table::SourceRecord &source, afw::image::Exposure< PixelT > const &exposure)
A class to represent a 2-dimensional array of pixels.
Definition: Image.h:415
double _sumPositive
int _numPositive