LSSTApplications  8.0.0.0+107,8.0.0.1+13,9.1+18,9.2,master-g084aeec0a4,master-g0aced2eed8+6,master-g15627eb03c,master-g28afc54ef9,master-g3391ba5ea0,master-g3d0fb8ae5f,master-g4432ae2e89+36,master-g5c3c32f3ec+17,master-g60f1e072bb+1,master-g6a3ac32d1b,master-g76a88a4307+1,master-g7bce1f4e06+57,master-g8ff4092549+31,master-g98e65bf68e,master-ga6b77976b1+53,master-gae20e2b580+3,master-gb584cd3397+53,master-gc5448b162b+1,master-gc54cf9771d,master-gc69578ece6+1,master-gcbf758c456+22,master-gcec1da163f+63,master-gcf15f11bcc,master-gd167108223,master-gf44c96c709
LSSTDataManagementBasePackage
ShapeUtilities.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_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 
60  Shape const getShape() const;
61 
63  void setShape(Shape const & shape);
64 
66  ShapeCov const getShapeErr() const;
67 
69  void setShapeErr(ShapeCov const & matrix);
70 
71 };
72 
79 class ShapeResultKey : public afw::table::FunctorKey<ShapeResult> {
80 public:
81 
95  std::string const & name,
96  std::string const & doc,
97  UncertaintyEnum uncertainty
98  );
99 
102 
105  afw::table::QuadrupoleKey const & shape,
107  ) :
108  _shape(shape), _shapeErr(shapeErr)
109  {}
110 
121 
123  virtual ShapeResult get(afw::table::BaseRecord const & record) const;
124 
126  virtual void set(afw::table::BaseRecord & record, ShapeResult const & value) const;
127 
129  bool operator==(ShapeResultKey const & other) const {
131  return _shape == other._shape && _shapeErr == other._shapeErr;
132  }
133  bool operator!=(ShapeResultKey const & other) const { return !(*this == other); }
135 
137  bool isValid() const { return _shape.isValid() && _shapeErr.isValid(); }
138 
141 
144 
147 
150 
153 
154 private:
157 };
158 
159 }}} // lsst::meas::base
160 
161 #endif // !LSST_MEAS_BASE_ShapeUtilities_h_INCLUDED
Key< double > getIxy() const
Return a constituent Key.
Definition: aggregates.h:194
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.
A proxy type for name lookups in a Schema.
Definition: Schema.h:370
ShapeResultKey(afw::table::QuadrupoleKey const &shape, afw::table::CovarianceMatrixKey< ErrElement, 3 > const &shapeErr)
Construct from a pair of Keys.
ErrElement yy_xy_Cov
yy,xy term in the uncertainty convariance matrix
Eigen::Matrix< ErrElement, 3, 3, Eigen::DontAlign > ShapeCov
Definition: constants.h:57
afw::table::CovarianceMatrixKey< ErrElement, 3 > getShapeErr() const
Return a FunctorKey to just the uncertainty matrix.
Key< double > getIyy() const
Return a constituent Key.
Definition: aggregates.h:193
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.
bool isValid() const
Return True if all the constituent Keys are valid.
Definition: aggregates.h:188
Key< double > getIxx() const
Return a constituent Key.
Definition: aggregates.h:192
ErrElement xySigma
1-Sigma uncertainty on xy (sqrt of variance)
float ErrElement
Definition: constants.h:51
Shape const getShape() const
Return an afw::geom::ellipses object corresponding to xx, yy, xy.
A FunctorKey for ShapeResult.
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.
tbl::Schema schema
Definition: CoaddPsf.cc:324
afw::table::QuadrupoleKey _shape
ShapeResult()
Constructor; initializes everything to NaN.
bool isValid() const
Return True if the shape key is valid.
afw::table::QuadrupoleKey getShape() const
Return a FunctorKey to just the shape value.
Base class for all records.
Definition: BaseRecord.h:27
ErrElement yySigma
1-Sigma uncertainty on yy (sqrt of variance)
double ShapeElement
Definition: constants.h:53
bool isValid() const
Return True if all the constituent sigma Keys are valid.
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)
static ShapeResultKey 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 ShapeResultKey that manages them.
void setShape(Shape const &shape)
Set struct elements from the given Quadrupole object.
A FunctorKey used to get or set a geom::ellipses::Quadrupole from an (xx,yy,xy) tuple of Keys...
Definition: aggregates.h:125
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::SourceRecord * record
afw::table::Key< ShapeElement > getIxy() const
Return a Key for the xy moment.