lsst.meas.base  14.0-16-g7a4f44b
CentroidUtilities.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 /*
3  * LSST Data Management System
4  * Copyright 2008-2014 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_CentroidUtilities_h_INCLUDED
25 #define LSST_MEAS_BASE_CentroidUtilities_h_INCLUDED
26 
30 
31 namespace lsst { namespace meas { namespace base {
32 
42 
45 
47  explicit CentroidResult(CentroidElement x_, CentroidElement y_, CentroidCov const & matrix):
48  x(x_),
49  y(y_),
50  xSigma(std::sqrt(matrix(0, 0))),
51  ySigma(std::sqrt(matrix(1, 1))),
52  x_y_Cov(matrix(0,1))
53  {}
54 
57  ErrElement xSigma_, ErrElement ySigma_) :
58  x(x_),
59  y(y_),
60  xSigma(xSigma_),
61  ySigma(ySigma_),
62  x_y_Cov(0.0)
63  {}
64 
66  Centroid const getCentroid() const;
67 
69  void setCentroid(Centroid const & centroid);
70 
73  {
75  }
76 
78  CentroidCov const getCentroidErr() const;
79 
81  void setCentroidErr(CentroidCov const & matrix);
82 
84  void setCentroidErr(ErrElement _xSigma, ErrElement _ySigma);
85 
86 };
87 
94 class CentroidResultKey : public afw::table::FunctorKey<CentroidResult> {
95 public:
96 
108  static CentroidResultKey addFields(
110  std::string const & name,
111  std::string const & doc,
112  UncertaintyEnum uncertainty
113  );
114 
116  CentroidResultKey() : _centroid(), _centroidErr() {}
117 
120  afw::table::PointKey<CentroidElement> const & centroid,
122  ) :
123  _centroid(centroid), _centroidErr(centroidErr)
124  {}
125 
136 
138  virtual CentroidResult get(afw::table::BaseRecord const & record) const;
139 
141  virtual void set(afw::table::BaseRecord & record, CentroidResult const & value) const;
142 
144  bool operator==(CentroidResultKey const & other) const {
146  return _centroid == other._centroid && _centroidErr == other._centroidErr;
147  }
148  bool operator!=(CentroidResultKey const & other) const { return !(*this == other); }
150 
152  bool isValid() const { return _centroid.isValid() && _centroidErr.isValid(); }
153 
156 
159 
161  afw::table::Key<CentroidElement> getX() const { return _centroid.getX(); }
162 
164  afw::table::Key<CentroidElement> getY() const { return _centroid.getY(); }
165 
166 private:
169 };
170 
183 public:
185 
186  /*
187  * @brief Perform transformation from inputCatalog to outputCatalog.
188  *
189  * @param[in] inputCatalog Source of data to be transformed
190  * @param[in,out] outputCatalog Container for transformed results
191  * @param[in] wcs World coordinate system under which transformation will take place
192  * @param[in] calib Photometric calibration under which transformation will take place
193  * @throws LengthError Catalog sizes do not match
194  */
195  virtual void operator()(afw::table::SourceCatalog const & inputCatalog,
196  afw::table::BaseCatalog & outputCatalog,
197  afw::image::Wcs const & wcs,
198  afw::image::Calib const & calib) const;
199 private:
200  afw::table::CoordKey _coordKey;
202 };
203 
205 public:
206 
223  CentroidChecker(afw::table::Schema & schema, std::string const & name, bool inside=true, double maxDistFromPeak=-1.0);
224 
229  bool operator()(
230  afw::table::SourceRecord & record
231  ) const;
232 
233 private:
234  bool _doFootprintCheck;
235  double _maxDistFromPeak;
240 };
241 }}} // lsst::meas::base
242 
243 #endif // !LSST_MEAS_BASE_CentroidUtilities_h_INCLUDED
Centroid const getCentroid() const
Return a Point object containing the measured x and y.
ErrElement ySigma
1-Sigma uncertainty on y (sqrt of variance)
afw::table::CovarianceMatrixKey< ErrElement, 2 > getCentroidErr() const
Return a FunctorKey to just the uncertainty matrix.
UncertaintyEnum
An enum used to specify how much uncertainty information measurement algorithms provide.
Definition: constants.h:41
afw::table::Schema schema
afw::table::PointKey< CentroidElement > getCentroid() const
Return a FunctorKey to just the centroid value.
A reusable struct for centroid measurements.
ErrElement xSigma
1-Sigma uncertainty on x (sqrt of variance)
bool isValid() const
Return True if the centroid key is valid.
This defines the base of measurement transformations.
CentroidResult(CentroidElement x_, CentroidElement y_, CentroidCov const &matrix)
Constructor; initializes everything from values.
STL namespace.
bool operator==(CoordKey const &lhs, CoordKey const &rhs)
CentroidElement x
x (column) coordinate of the measured position
afw::table::Key< CentroidElement > getY() const
Return a Key for the y coordinate.
void setCentroid(Centroid const &centroid)
Set the struct fields from the given Point object.
bool operator!=(CentroidResultKey const &other) const
Compare the FunctorKey for equality with another, using the underlying Keys.
CentroidResultKey(afw::table::PointKey< CentroidElement > const &centroid, afw::table::CovarianceMatrixKey< ErrElement, 2 > const &centroidErr)
Construct from a pair of Keys.
string name
float ErrElement
Definition: constants.h:53
CentroidResult(CentroidElement x_, CentroidElement y_, ErrElement xSigma_, ErrElement ySigma_)
Constructor; initializes everything from values.
STL class.
CentroidResult()
Constructor; initializes everything to NaN.
afw::geom::Point< CentroidElement > getPoint()
Return the 2D point type corresponding to this result.
ErrElement x_y_Cov
x,y term in the uncertainty convariance matrix
afw::table::Key< CentroidElement > getX() const
Return a Key for the x coordinate.
Abstract base class for all C++ measurement transformations.
Definition: Transform.h:82
A FunctorKey for CentroidResult.
CentroidElement y
y (row) coordinate of the measured position
Eigen::Matrix< ErrElement, 2, 2, Eigen::DontAlign > CentroidCov
Definition: constants.h:57
CentroidResultKey()
Default constructor; instance will not be usuable unless subsequently assigned to.
double CentroidElement
Definition: constants.h:54
CentroidCov const getCentroidErr() const
Return the 2x2 symmetric covariance matrix, with rows and columns ordered (x, y)
Base for centroid measurement transformations.
void setCentroidErr(CentroidCov const &matrix)
Set the struct uncertainty fields from the given matrix, with rows and columns ordered (x...