lsst.meas.base  14.0-21-gb9e430a+5
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 
28 #include "lsst/afw/geom/SkyWcs.h"
29 #include "lsst/afw/image/Calib.h"
32 
33 namespace lsst { namespace meas { namespace base {
34 
44 
47 
49  explicit CentroidResult(CentroidElement x_, CentroidElement y_, CentroidCov const & matrix):
50  x(x_),
51  y(y_),
52  xSigma(std::sqrt(matrix(0, 0))),
53  ySigma(std::sqrt(matrix(1, 1))),
54  x_y_Cov(matrix(0,1))
55  {}
56 
59  ErrElement xSigma_, ErrElement ySigma_) :
60  x(x_),
61  y(y_),
62  xSigma(xSigma_),
63  ySigma(ySigma_),
64  x_y_Cov(0.0)
65  {}
66 
68  Centroid const getCentroid() const;
69 
71  void setCentroid(Centroid const & centroid);
72 
75  {
77  }
78 
80  CentroidCov const getCentroidErr() const;
81 
83  void setCentroidErr(CentroidCov const & matrix);
84 
86  void setCentroidErr(ErrElement _xSigma, ErrElement _ySigma);
87 
88 };
89 
96 class CentroidResultKey : public afw::table::FunctorKey<CentroidResult> {
97 public:
98 
110  static CentroidResultKey addFields(
112  std::string const & name,
113  std::string const & doc,
114  UncertaintyEnum uncertainty
115  );
116 
118  CentroidResultKey() : _centroid(), _centroidErr() {}
119 
122  afw::table::PointKey<CentroidElement> const & centroid,
124  ) :
125  _centroid(centroid), _centroidErr(centroidErr)
126  {}
127 
138 
140  virtual CentroidResult get(afw::table::BaseRecord const & record) const;
141 
143  virtual void set(afw::table::BaseRecord & record, CentroidResult const & value) const;
144 
146  bool operator==(CentroidResultKey const & other) const {
148  return _centroid == other._centroid && _centroidErr == other._centroidErr;
149  }
150  bool operator!=(CentroidResultKey const & other) const { return !(*this == other); }
152 
154  bool isValid() const { return _centroid.isValid() && _centroidErr.isValid(); }
155 
158 
161 
163  afw::table::Key<CentroidElement> getX() const { return _centroid.getX(); }
164 
166  afw::table::Key<CentroidElement> getY() const { return _centroid.getY(); }
167 
168 private:
171 };
172 
185 public:
187 
188  /*
189  * @brief Perform transformation from inputCatalog to outputCatalog.
190  *
191  * @param[in] inputCatalog Source of data to be transformed
192  * @param[in,out] outputCatalog Container for transformed results
193  * @param[in] wcs World coordinate system under which transformation will take place
194  * @param[in] calib Photometric calibration under which transformation will take place
195  * @throws LengthError Catalog sizes do not match
196  */
197  virtual void operator()(afw::table::SourceCatalog const & inputCatalog,
198  afw::table::BaseCatalog & outputCatalog,
199  afw::geom::SkyWcs const & wcs,
200  afw::image::Calib const & calib) const;
201 private:
202  afw::table::CoordKey _coordKey;
204 };
205 
207 public:
208 
225  CentroidChecker(afw::table::Schema & schema, std::string const & name, bool inside=true, double maxDistFromPeak=-1.0);
226 
231  bool operator()(
232  afw::table::SourceRecord & record
233  ) const;
234 
235 private:
236  bool _doFootprintCheck;
237  double _maxDistFromPeak;
242 };
243 }}} // lsst::meas::base
244 
245 #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:83
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...