LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
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 
110  std::string const & name,
111  std::string const & doc,
112  UncertaintyEnum uncertainty
113  );
114 
117 
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 
162 
165 
166 private:
169 };
170 
183 public:
184  CentroidTransform(std::string const & name, afw::table::SchemaMapper & mapper);
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:
202 };
203 
204 }}} // lsst::meas::base
205 
206 #endif // !LSST_MEAS_BASE_CentroidUtilities_h_INCLUDED
Defines the fields and offsets for a table.
Definition: Schema.h:46
bool operator!=(CentroidResultKey const &other) const
Compare the FunctorKey for equality with another, using the underlying Keys.
A proxy type for name lookups in a Schema.
Definition: Schema.h:330
ErrElement ySigma
1-Sigma uncertainty on y (sqrt of variance)
Key< T > getY() const
Return the underlying y Key.
Definition: aggregates.h:103
table::Key< std::string > name
Definition: ApCorrMap.cc:71
UncertaintyEnum
An enum used to specify how much uncertainty information measurement algorithms provide.
Definition: constants.h:41
A custom container class for records, based on std::vector.
Definition: Catalog.h:94
afw::table::Key< CentroidElement > getY() const
Return a Key for the y coordinate.
afw::table::Schema schema
Definition: GaussianPsf.cc:41
A mapping between the keys of two Schemas, used to copy data between them.
Definition: SchemaMapper.h:19
A reusable struct for centroid measurements.
Centroid const getCentroid() const
Return a Point object containing the measured x and y.
ErrElement xSigma
1-Sigma uncertainty on x (sqrt of variance)
CentroidElement x
x (column) coordinate of the measured position
tbl::Key< int > wcs
Implementation of the WCS standard for a any projection.
Definition: Wcs.h:107
bool isValid() const
Return True if the centroid key is valid.
void setCentroid(Centroid const &centroid)
Set the struct fields from the given Point object.
afw::table::CovarianceMatrixKey< ErrElement, 2 > getCentroidErr() const
Return a FunctorKey to just the uncertainty matrix.
CentroidResultKey(afw::table::PointKey< CentroidElement > const &centroid, afw::table::CovarianceMatrixKey< ErrElement, 2 > const &centroidErr)
Construct from a pair of Keys.
float ErrElement
Definition: constants.h:53
Key< T > getX() const
Return the underlying x Key.
Definition: aggregates.h:100
A coordinate class intended to represent absolute positions.
bool isValid() const
Return True if both the x and y Keys are valid.
Definition: aggregates.h:97
CentroidResult()
Constructor; initializes everything to NaN.
afw::geom::Point< CentroidElement > getPoint()
Return the 2D point type corresponding to this result.
Custom catalog class for record/table subclasses that are guaranteed to have an ID, and should generally be sorted by that ID.
Definition: fwd.h:55
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.
static CentroidResultKey addFields(afw::table::Schema &schema, std::string const &name, std::string const &doc, UncertaintyEnum uncertainty)
Add the appropriate fields to a Schema, and return a CentroidResultKey that manages them...
virtual void operator()(afw::table::SourceCatalog const &inputCatalog, afw::table::BaseCatalog &outputCatalog, afw::image::Wcs const &wcs, afw::image::Calib const &calib) const
afw::table::CovarianceMatrixKey< ErrElement, 2 > _coordErrKey
CentroidTransform(std::string const &name, afw::table::SchemaMapper &mapper)
virtual void set(afw::table::BaseRecord &record, CentroidResult const &value) const
Set a CentroidResult in the given record.
Base class for all records.
Definition: BaseRecord.h:27
afw::table::PointKey< CentroidElement > getCentroid() const
Return a FunctorKey to just the centroid value.
CentroidResult(CentroidElement _x, CentroidElement _y, CentroidCov const &matrix)
Constructor; initializes everything from values.
CentroidCov const getCentroidErr() const
Return the 2x2 symmetric covariance matrix, with rows and columns ordered (x, y)
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
bool isValid() const
Return True if all the constituent sigma Keys are valid.
afw::table::PointKey< CentroidElement > _centroid
CentroidResultKey()
Default constructor; instance will not be usuable unless subsequently assigned to.
double CentroidElement
Definition: constants.h:54
CentroidResult(CentroidElement _x, CentroidElement _y, ErrElement _xSigma, ErrElement _ySigma)
Constructor; initializes everything from values.
afw::table::CovarianceMatrixKey< ErrElement, 2 > _centroidErr
bool operator==(CentroidResultKey const &other) const
Compare the FunctorKey for equality with another, using the underlying Keys.
void setCentroidErr(CentroidCov const &matrix)
Set the struct uncertainty fields from the given matrix, with rows and columns ordered (x...
A FunctorKey used to get or set celestial coordiantes from a pair of Angle keys.
Definition: aggregates.h:119