LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
ShapeUtilities.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 /*
3  * LSST Data Management System
4  * Copyright 2008-2015 AURA/LSST.
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_ShapeUtilities_h_INCLUDED
25 #define LSST_MEAS_BASE_ShapeUtilities_h_INCLUDED
26 
29 
30 namespace lsst { namespace meas { namespace base {
31 
40 struct ShapeResult {
41  ShapeElement xx; // image or model second moment for x^2
42  ShapeElement yy; // image or model second moment for y^2
43  ShapeElement xy; // image or model second moment for xy^2
50 
52  ShapeResult();
53 
55  explicit ShapeResult(ShapeElement _xx, ShapeElement _yy, ShapeElement _xy, ShapeCov const & matrix):
56  xx(_xx),
57  yy(_yy),
58  xy(_xy),
59  xxSigma(std::sqrt(matrix(0, 0))),
60  yySigma(std::sqrt(matrix(1, 1))),
61  xySigma(std::sqrt(matrix(2, 2))),
62  xx_yy_Cov(matrix(0, 1)),
63  xx_xy_Cov(matrix(0, 2)),
64  yy_xy_Cov(matrix(1, 2))
65  {}
66 
69  ErrElement _xxSigma, ErrElement _yySigma, ErrElement _xySigma) :
70  xx(_xx),
71  yy(_yy),
72  xy(_xy),
73  xxSigma(_xxSigma),
74  yySigma(_yySigma),
75  xySigma(_xySigma),
76  xx_yy_Cov(0.0),
77  xx_xy_Cov(0.0),
78  yy_xy_Cov(0.0)
79  {}
80 
87  Shape const getShape() const;
88 
89  // get the Quadrupole corresponding to this ShapeResult
91  {
93  }
94 
96  void setShape(Shape const & shape);
97 
99  ShapeCov const getShapeErr() const;
100 
102  void setShapeErr(ShapeCov const & matrix);
103 
105  void setShapeErr(ErrElement _xxSigma, ErrElement _yySigma, ErrElement _xySigma);
106 
107 };
108 
115 class ShapeResultKey : public afw::table::FunctorKey<ShapeResult> {
116 public:
117 
129  static ShapeResultKey addFields(
131  std::string const & name,
132  std::string const & doc,
133  UncertaintyEnum uncertainty,
135  );
136 
139 
142  afw::table::QuadrupoleKey const & shape,
144  ) :
145  _shape(shape), _shapeErr(shapeErr)
146  {}
147 
158 
160  virtual ShapeResult get(afw::table::BaseRecord const & record) const;
161 
163  virtual void set(afw::table::BaseRecord & record, ShapeResult const & value) const;
164 
166  bool operator==(ShapeResultKey const & other) const {
168  return _shape == other._shape && _shapeErr == other._shapeErr;
169  }
170  bool operator!=(ShapeResultKey const & other) const { return !(*this == other); }
172 
174  bool isValid() const { return _shape.isValid() && _shapeErr.isValid(); }
175 
178 
181 
184 
187 
190 
191 private:
194 };
195 
217 
218 }}} // lsst::meas::base
219 
220 #endif // !LSST_MEAS_BASE_ShapeUtilities_h_INCLUDED
An ellipse core with quadrupole moments as parameters.
Definition: Quadrupole.h:45
Defines the fields and offsets for a table.
Definition: Schema.h:46
afw::table::Key< ShapeElement > getIxx() const
Return a Key for the xx moment.
bool isValid() const
Return True if all the constituent Keys are valid.
Definition: aggregates.h:244
A proxy type for name lookups in a Schema.
Definition: Schema.h:330
ShapeResultKey(afw::table::QuadrupoleKey const &shape, afw::table::CovarianceMatrixKey< ErrElement, 3 > const &shapeErr)
Construct from a pair of Keys.
ShapeTrMatrix makeShapeTransformMatrix(afw::geom::LinearTransform const &xform)
Construct a matrix suitable for transforming second moments.
ErrElement yy_xy_Cov
yy,xy term in the uncertainty convariance matrix
table::Key< std::string > name
Definition: ApCorrMap.cc:71
ShapeResult(ShapeElement _xx, ShapeElement _yy, ShapeElement _xy, ErrElement _xxSigma, ErrElement _yySigma, ErrElement _xySigma)
Constructor; initializes everything from values.
Eigen::Matrix< ErrElement, 3, 3, Eigen::DontAlign > ShapeCov
Definition: constants.h:59
afw::table::CovarianceMatrixKey< ErrElement, 3 > getShapeErr() 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::Key< ShapeElement > getIyy() const
Return a Key for the yy moment.
ShapeResultKey()
Default constructor; instance will not be usuable unless subsequently assigned to.
afw::geom::ellipses::Quadrupole getQuadrupole()
ErrElement xySigma
1-Sigma uncertainty on xy (sqrt of variance)
Key< double > getIxy() const
Return a constituent Key.
Definition: aggregates.h:250
float ErrElement
Definition: constants.h:53
Shape const getShape() const
Return an afw::geom::ellipses object corresponding to xx, yy, xy.
A FunctorKey for ShapeResult.
A 2D linear coordinate transformation.
ErrElement xx_xy_Cov
xx,xy term in the uncertainty convariance matrix
void setShapeErr(ShapeCov const &matrix)
Set the struct uncertainty elements from the given matrix, with rows and columns ordered (xx...
ErrElement xx_yy_Cov
xx,yy term in the uncertainty convariance matrix
A reusable struct for moments-based shape measurements.
virtual void set(afw::table::BaseRecord &record, ShapeResult const &value) const
Set a ShapeResult in the given record.
bool operator!=(ShapeResultKey const &other) const
Compare the FunctorKey for equality with another, using the underlying Keys.
bool isValid() const
Return True if all the constituent sigma Keys are valid.
afw::table::QuadrupoleKey _shape
ShapeResult()
Constructor; initializes everything to NaN.
bool isValid() const
Return True if the shape key is valid.
tbl::Schema schema
ShapeResult(ShapeElement _xx, ShapeElement _yy, ShapeElement _xy, ShapeCov const &matrix)
Constructor; initializes everything from values.
afw::table::QuadrupoleKey getShape() const
Return a FunctorKey to just the shape value.
CoordinateType
Definition: misc.h:23
Base class for all records.
Definition: BaseRecord.h:27
A class used as a handle to a particular field in a table.
Definition: fwd.h:44
ErrElement yySigma
1-Sigma uncertainty on yy (sqrt of variance)
double ShapeElement
Definition: constants.h:55
bool operator==(ShapeResultKey const &other) const
Compare the FunctorKey for equality with another, using the underlying Keys.
ErrElement xxSigma
1-Sigma uncertainty on xx (sqrt of variance)
void setShape(Shape const &shape)
Set struct elements from the given Quadrupole object.
Key< double > getIxx() const
Return a constituent Key.
Definition: aggregates.h:248
Eigen::Matrix< ShapeElement, 3, 3, Eigen::DontAlign > ShapeTrMatrix
Definition: constants.h:60
A FunctorKey used to get or set a geom::ellipses::Quadrupole from a tuple of constituent Keys...
Definition: aggregates.h:188
ShapeCov const getShapeErr() const
Return the 3x3 symmetric covariance matrix, with rows and columns ordered (xx, yy, xy)
afw::table::CovarianceMatrixKey< ErrElement, 3 > _shapeErr
afw::table::Key< ShapeElement > getIxy() const
Return a Key for the xy moment.
static ShapeResultKey addFields(afw::table::Schema &schema, std::string const &name, std::string const &doc, UncertaintyEnum uncertainty, afw::table::CoordinateType coordType=afw::table::CoordinateType::PIXEL)
Add the appropriate fields to a Schema, and return a ShapeResultKey that manages them.
Key< double > getIyy() const
Return a constituent Key.
Definition: aggregates.h:249