LSSTApplications  11.0-13-gbb96280,12.1.rc1,12.1.rc1+1,12.1.rc1+2,12.1.rc1+5,12.1.rc1+8,12.1.rc1-1-g06d7636+1,12.1.rc1-1-g253890b+5,12.1.rc1-1-g3d31b68+7,12.1.rc1-1-g3db6b75+1,12.1.rc1-1-g5c1385a+3,12.1.rc1-1-g83b2247,12.1.rc1-1-g90cb4cf+6,12.1.rc1-1-g91da24b+3,12.1.rc1-2-g3521f8a,12.1.rc1-2-g39433dd+4,12.1.rc1-2-g486411b+2,12.1.rc1-2-g4c2be76,12.1.rc1-2-gc9c0491,12.1.rc1-2-gda2cd4f+6,12.1.rc1-3-g3391c73+2,12.1.rc1-3-g8c1bd6c+1,12.1.rc1-3-gcf4b6cb+2,12.1.rc1-4-g057223e+1,12.1.rc1-4-g19ed13b+2,12.1.rc1-4-g30492a7
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 
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:
240 };
241 }}} // lsst::meas::base
242 
243 #endif // !LSST_MEAS_BASE_CentroidUtilities_h_INCLUDED
Defines the fields and offsets for a table.
Definition: Schema.h:44
afw::table::Key< CentroidElement > _yKey
CentroidResult(CentroidElement _x, CentroidElement _y, CentroidCov const &matrix)
Constructor; initializes everything from values.
CentroidElement y
y (row) coordinate of the measured position
A proxy type for name lookups in a Schema.
Definition: Schema.h:326
CentroidResultKey()
Default constructor; instance will not be usuable unless subsequently assigned to.
Key< T > getY() const
Return the underlying y Key.
Definition: aggregates.h:103
afw::table::CovarianceMatrixKey< ErrElement, 2 > _centroidErr
table::Key< std::string > name
Definition: ApCorrMap.cc:71
ErrElement ySigma
1-Sigma uncertainty on y (sqrt of variance)
afw::table::Key< afw::table::Flag > _resetKey
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:95
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
Eigen::Matrix< ErrElement, 2, 2, Eigen::DontAlign > CentroidCov
Definition: constants.h:57
A reusable struct for centroid measurements.
afw::table::PointKey< CentroidElement > _centroid
virtual void operator()(afw::table::SourceCatalog const &inputCatalog, afw::table::BaseCatalog &outputCatalog, afw::image::Wcs const &wcs, afw::image::Calib const &calib) const
tbl::Key< int > wcs
void setCentroid(Centroid const &centroid)
Set the struct fields from the given Point object.
virtual void set(afw::table::BaseRecord &record, CentroidResult const &value) const
Set a CentroidResult in the given record.
CentroidChecker(afw::table::Schema &schema, std::string const &name, bool inside=true, double maxDistFromPeak=-1.0)
Implementation of the WCS standard for a any projection.
Definition: Wcs.h:107
ErrElement x_y_Cov
x,y term in the uncertainty convariance matrix
afw::table::CovarianceMatrixKey< ErrElement, 2 > _coordErrKey
Key< T > getX() const
Return the underlying x Key.
Definition: aggregates.h:100
A coordinate class intended to represent absolute positions.
Definition: PSF.h:39
bool isValid() const
Return True if both the x and y Keys are valid.
Definition: aggregates.h:97
afw::geom::Point< CentroidElement > getPoint()
Return the 2D point type corresponding to this result.
float ErrElement
Definition: constants.h:53
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
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...
Centroid const getCentroid() const
Return a Point object containing the measured x and y.
afw::table::Key< CentroidElement > getX() const
Return a Key for the x coordinate.
void setCentroidErr(CentroidCov const &matrix)
Set the struct uncertainty fields from the given matrix, with rows and columns ordered (x...
afw::table::Key< CentroidElement > getY() const
Return a Key for the y coordinate.
CentroidTransform(std::string const &name, afw::table::SchemaMapper &mapper)
double CentroidElement
Definition: constants.h:54
ErrElement xSigma
1-Sigma uncertainty on x (sqrt of variance)
bool operator()(afw::table::SourceRecord &record) const
CentroidResult()
Constructor; initializes everything to NaN.
CentroidResultKey(afw::table::PointKey< CentroidElement > const &centroid, afw::table::CovarianceMatrixKey< ErrElement, 2 > const &centroidErr)
Construct from a pair of Keys.
afw::table::CovarianceMatrixKey< ErrElement, 2 > getCentroidErr() const
Return a FunctorKey to just the uncertainty matrix.
Base class for all records.
Definition: BaseRecord.h:27
bool operator==(CentroidResultKey const &other) const
Compare the FunctorKey for equality with another, using the underlying Keys.
CentroidElement x
x (column) coordinate of the measured position
A FunctorKey for CentroidResult.
CentroidResult(CentroidElement _x, CentroidElement _y, ErrElement _xSigma, ErrElement _ySigma)
Constructor; initializes everything from values.
bool isValid() const
Return True if all the constituent sigma Keys are valid.
afw::table::PointKey< CentroidElement > getCentroid() const
Return a FunctorKey to just the centroid value.
Record class that contains measurements made on a single exposure.
Definition: Source.h:80
afw::table::Key< CentroidElement > _xKey
CentroidCov const getCentroidErr() const
Return the 2x2 symmetric covariance matrix, with rows and columns ordered (x, y)
afw::table::Key< afw::table::Flag > _failureKey
bool operator!=(CentroidResultKey const &other) const
Compare the FunctorKey for equality with another, using the underlying Keys.
A FunctorKey used to get or set celestial coordinates from a pair of Angle keys.
Definition: aggregates.h:119
bool isValid() const
Return True if the centroid key is valid.