lsst.meas.base  14.0-12-g233aa8e+3
GaussianCentroid.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 /*
3  * LSST Data Management System
4  * Copyright 2008-2013 LSST Corporation.
5  *
6  * This product includes software developed by the
7  * LSST Project (http://www.lsst.org/).
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the LSST License Statement and
20  * the GNU General Public License along with this program. If not,
21  * see <http://www.lsstcorp.org/LegalNotices/>.
22  */
23 
24 #ifndef LSST_MEAS_BASE_GaussianCentroid_h_INCLUDED
25 #define LSST_MEAS_BASE_GaussianCentroid_h_INCLUDED
26 
27 #include "lsst/afw/geom/Point.h"
28 #include "lsst/pex/config.h"
33 
34 namespace lsst { namespace meas { namespace base {
35 
36 struct FittedModel {
37  enum { PEAK = 0, SKY, X0, Y0, SIGMA, NPARAM };
38 
39  enum {
40  BAD_GUESS = -11,
41  TOO_FEW = -12,
42  CHI_SQUARED = -13,
43  RANGE = -14,
44  BAD_WIDTH = -15,
45  LOST = -16,
46  DIAGONAL = -17,
47  BAD_A = -18,
48  CONVERGE = 1,
49  ITERATE = 2,
50  ALMOST = 3,
51  POOR = 4
52  };
53 
54  FittedModel(int status_, std::vector<double> params_, int iter_=0, double flamd_=0, double chnew_=0) :
55  status(status_), params(params_), iter(iter_), flamd(flamd_), chnew(chnew_) { }
56  int status;
58  int iter;
59  double flamd;
60  double chnew;
61 };
62 
70 public:
76  LSST_CONTROL_FIELD(doFootprintCheck, bool,
77  "Do check that the centroid is contained in footprint.");
78  LSST_CONTROL_FIELD(maxDistToPeak, double,
79  "If set > 0, Centroid Check also checks distance from footprint peak.");
80  GaussianCentroidControl() : doFootprintCheck(true), maxDistToPeak(-1.0) {}
81 };
82 
87 public:
88 
89  // Structures and routines to manage flaghandler
90  static FlagDefinitionList const & getFlagDefinitions();
91  static FlagDefinition const FAILURE;
92  static FlagDefinition const NO_PEAK;
93 
97 
98  GaussianCentroidAlgorithm(Control const & ctrl, std::string const & name, afw::table::Schema & schema);
99 
103  template<typename PixelT>
105  static afw::geom::Point2D fitCentroid(afw::image::Image<PixelT> const& im,
106  double x0,
107  double y0
108  );
109 
110  virtual void measure(
111  afw::table::SourceRecord & measRecord,
112  afw::image::Exposure<float> const & exposure
113  ) const;
114 
115  virtual void fail(
116  afw::table::SourceRecord & measRecord,
117  MeasurementError * error=nullptr
118  ) const;
119 
120 private:
121 
122  Control _ctrl;
123  CentroidResultKey _centroidKey;
124  FlagHandler _flagHandler;
125  SafeCentroidExtractor _centroidExtractor;
126  CentroidChecker _centroidChecker;
127 };
128 
130 public:
132 
133  GaussianCentroidTransform(Control const & ctrl, std::string const & name, afw::table::SchemaMapper & mapper);
134 };
135 
136 }}} // namespace lsst::meas::base
137 
138 #endif // !LSST_MEAS_BASE_GaussianCentroid_h_INCLUDED
Simple class used to define and document flags The name and doc constitute the identity of the FlagDe...
Definition: FlagHandler.h:38
Utility class for measurement algorithms that extracts a position from the Centroid slot and handles ...
Exception to be thrown when a measurement algorithm experiences a known failure mode.
Definition: exceptions.h:48
#define LSST_CONTROL_FIELD(NAME, TYPE, DOC)
A class that calculates a centroid by fitting a circular Gaussian to the image.
STL class.
Utility class for handling flag fields that indicate the failure modes of an algorithm.
Definition: FlagHandler.h:156
std::vector< double > params
A C++ control class to handle GaussianCentroidAlgorithm&#39;s configuration.
FittedModel(int status_, std::vector< double > params_, int iter_=0, double flamd_=0, double chnew_=0)
GaussianCentroidControl Control
A typedef to the Control object for this algorithm, defined above.
An abstract base classes for which the same implementation can be used for both SingleFrameAlgorithm ...
Definition: Algorithm.h:184
A FunctorKey for CentroidResult.
vector-type utility class to build a collection of FlagDefinitions
Definition: FlagHandler.h:63
Base for centroid measurement transformations.