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
aggregates.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 #ifndef AFW_TABLE_aggregates_h_INCLUDED
24 #define AFW_TABLE_aggregates_h_INCLUDED
25 
27 #include "lsst/afw/table/Schema.h"
28 
29 namespace lsst { namespace afw {
30 
31 namespace geom {
32 
33 template <typename T, int N> class Point;
34 
35 namespace ellipses {
36 
37 class Quadrupole;
38 
39 } // namespace ellipses
40 } // namespace geom
41 
42 namespace table {
43 
47 template <typename T>
48 class PointKey : public FunctorKey< lsst::afw::geom::Point<T,2> > {
49 public:
50 
60  static PointKey addFields(
61  Schema & schema,
62  std::string const & name,
63  std::string const & doc,
64  std::string const & unit
65  );
66 
68  PointKey() : _x(), _y() {}
69 
71  PointKey(Key<T> const & x, Key<T> const & y) : _x(x), _y(y) {}
72 
79  explicit PointKey(Key< Point<T> > const & other) : _x(other.getX()), _y(other.getY()) {}
80 
90  PointKey(SubSchema const & s) : _x(s["x"]), _y(s["y"]) {}
91 
93  virtual geom::Point<T,2> get(BaseRecord const & record) const;
94 
96  virtual void set(BaseRecord & record, geom::Point<T,2> const & value) const;
97 
99  bool operator==(PointKey<T> const & other) const { return _x == other._x && _y == other._y; }
101  bool operator!=(PointKey<T> const & other) const { return !(*this == other); }
103 
105  bool isValid() const { return _x.isValid() && _y.isValid(); }
106 
108  Key<T> getX() const { return _x; }
109 
111  Key<T> getY() const { return _y; }
112 
113 private:
116 };
117 
120 
121 
125 class QuadrupoleKey : public FunctorKey< lsst::afw::geom::ellipses::Quadrupole > {
126 public:
127 
137  static QuadrupoleKey addFields(
138  Schema & schema,
139  std::string const & name,
140  std::string const & doc,
141  std::string const & unit
142  );
143 
145  QuadrupoleKey() : _ixx(), _iyy(), _ixy() {}
146 
148  QuadrupoleKey(Key<double> const & ixx, Key<double> const & iyy, Key<double> const & ixy) :
149  _ixx(ixx), _iyy(iyy), _ixy(ixy)
150  {}
151 
158  explicit QuadrupoleKey(Key< Moments<double> > const & other) :
159  _ixx(other.getIxx()), _iyy(other.getIyy()), _ixy(other.getIxy())
160  {}
161 
171  QuadrupoleKey(SubSchema const & s) : _ixx(s["xx"]), _iyy(s["yy"]), _ixy(s["xy"]) {}
172 
174  virtual geom::ellipses::Quadrupole get(BaseRecord const & record) const;
175 
177  virtual void set(BaseRecord & record, geom::ellipses::Quadrupole const & value) const;
178 
180  bool operator==(QuadrupoleKey const & other) const {
182  return _ixx == other._ixx && _iyy == other._iyy && _ixy == other._ixy;
183  }
184  bool operator!=(QuadrupoleKey const & other) const { return !(*this == other); }
186 
188  bool isValid() const { return _ixx.isValid() && _iyy.isValid() && _ixy.isValid(); }
189 
191  Key<double> getIxx() const { return _ixx; }
193  Key<double> getIyy() const { return _iyy; }
194  Key<double> getIxy() const { return _ixy; }
196 
197 private:
201 };
202 
203 
207 class EllipseKey : public FunctorKey< lsst::afw::geom::ellipses::Ellipse > {
208 public:
209 
220  static EllipseKey addFields(
221  Schema & schema,
222  std::string const & name,
223  std::string const & doc,
224  std::string const & unit
225  );
226 
228  EllipseKey() : _qKey(), _pKey() {}
229 
231  EllipseKey(QuadrupoleKey const & qKey, PointKey<double> const & pKey) :
232  _qKey(qKey), _pKey(pKey)
233  {}
234 
244  EllipseKey(SubSchema const & s) : _qKey(s), _pKey(s) {}
245 
247  virtual geom::ellipses::Ellipse get(BaseRecord const & record) const;
248 
250  virtual void set(BaseRecord & record, geom::ellipses::Ellipse const & value) const;
251 
253  bool operator==(EllipseKey const & other) const {
255  return _qKey == other._qKey && _pKey == other._pKey;
256  }
257  bool operator!=(EllipseKey const & other) const { return !(*this == other); }
259 
261  bool isValid() const { return _qKey.isValid() && _pKey.isValid(); }
262 
264  QuadrupoleKey getCore() const { return _qKey; }
266  PointKey<double> getCenter() const { return _pKey; }
268 
269 private:
272 };
273 
274 
275 template <typename T, int N>
276 class CovarianceMatrixKey : public FunctorKey< Eigen::Matrix<T,N,N> > {
277 public:
278 
279  typedef std::vector< Key<T> > SigmaKeyArray;
280  typedef std::vector< Key<T> > CovarianceKeyArray;
281  typedef std::vector<std::string> NameArray;
282 
285 
305  explicit CovarianceMatrixKey(
306  SigmaKeyArray const & sigma,
308  );
309 
322  template <typename U>
323  explicit CovarianceMatrixKey(Key< Covariance<U> > const & other);
324 
336  CovarianceMatrixKey(SubSchema const & s, NameArray const & names);
337 
339  virtual Eigen::Matrix<T,N,N> get(BaseRecord const & record) const;
340 
342  virtual void set(BaseRecord & record, Eigen::Matrix<T,N,N> const & value) const;
343 
350  bool isValid() const;
351 
353  bool operator==(CovarianceMatrixKey const & other) const;
355  bool operator!=(CovarianceMatrixKey const & other) const { return !(*this == other); }
357 
358 private:
362 };
363 
367 }
368 
369 inline CovarianceMatrixKey<float,2>
371  return CovarianceMatrixKey<float,2>(other);
372 }
373 
374 inline CovarianceMatrixKey<float,3>
376  return CovarianceMatrixKey<float,3>(other);
377 }
378 
379 }}} // namespace lsst::afw::table
380 
381 #endif // !AFW_TABLE_aggregates_h_INCLUDED
bool isValid() const
Return true if the key was initialized to valid offset.
Definition: Key.h:83
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
PointKey< double > getCenter() const
Return constituent FunctorKeys.
Definition: aggregates.h:266
A coordinate class intended to represent absolute positions (2-d specialization). ...
Definition: Point.h:176
EllipseKey(QuadrupoleKey const &qKey, PointKey< double > const &pKey)
Construct from individual Keys.
Definition: aggregates.h:231
A proxy type for name lookups in a Schema.
Definition: Schema.h:370
QuadrupoleKey(SubSchema const &s)
Construct from a subschema, assuming xx, yy, and xy subfields.
Definition: aggregates.h:171
Key< T > getY() const
Return the underlying y Key.
Definition: aggregates.h:111
static PointKey addFields(Schema &schema, std::string const &name, std::string const &doc, std::string const &unit)
std::vector< std::string > NameArray
Definition: aggregates.h:281
QuadrupoleKey getCore() const
Return constituent FunctorKeys.
Definition: aggregates.h:265
EllipseKey()
Default constructor; instance will not be usuable unless subsequently assigned to.
Definition: aggregates.h:228
int y
Key< double > getIyy() const
Return a constituent Key.
Definition: aggregates.h:193
QuadrupoleKey()
Default constructor; instance will not be usuable unless subsequently assigned to.
Definition: aggregates.h:145
virtual void set(BaseRecord &record, geom::Point< T, 2 > const &value) const
Set a Point in the given record.
static QuadrupoleKey addFields(Schema &schema, std::string const &name, std::string const &doc, std::string const &unit)
EllipseKey(SubSchema const &s)
Construct from a subschema, assuming (xx, yy, xy, x, y) subfields.
Definition: aggregates.h:244
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
PointKey< int > Point2IKey
Definition: aggregates.h:118
bool operator!=(PointKey< T > const &other) const
Compare the FunctorKey for equality with another, using the underlying x and y Keys.
Definition: aggregates.h:101
PointKey< double > Point2DKey
Definition: aggregates.h:119
PointKey< double > _pKey
Definition: aggregates.h:271
PointKey(Key< Point< T > > const &other)
Definition: aggregates.h:79
Key< T > getX() const
Return the underlying x Key.
Definition: aggregates.h:108
bool isValid() const
Return True if both the x and y Keys are valid.
Definition: aggregates.h:105
afw::table::Key< double > sigma
Definition: GaussianPsf.cc:42
A FunctorKey used to get or set a geom::Point from an (x,y) pair of int or double Keys...
Definition: aggregates.h:48
tbl::Schema schema
Definition: CoaddPsf.cc:324
std::vector< Key< T > > SigmaKeyArray
Definition: aggregates.h:279
int x
bool operator==(PointKey< T > const &other) const
Compare the FunctorKey for equality with another, using the underlying x and y Keys.
Definition: aggregates.h:100
bool isValid() const
Return True if all the constituent Keys are valid.
Definition: aggregates.h:261
An ellipse defined by an arbitrary BaseCore and a center point.
Definition: Ellipse.h:50
bool operator!=(QuadrupoleKey const &other) const
Compare the FunctorKey for equality with another, using the underlying Ixx, Iyy, Ixy Keys...
Definition: aggregates.h:184
std::vector< Key< T > > CovarianceKeyArray
Definition: aggregates.h:280
bool operator==(CovarianceMatrixKey const &other) const
Compare the FunctorKey for equality with another, using its constituent Keys.
virtual void set(BaseRecord &record, geom::ellipses::Quadrupole const &value) const
Set a Quadrupole in the given record.
bool operator!=(EllipseKey const &other) const
Compare the FunctorKey for equality with another, using the underlying Ixx, Iyy, Ixy Keys...
Definition: aggregates.h:257
Base class for all records.
Definition: BaseRecord.h:27
bool operator!=(CovarianceMatrixKey const &other) const
Compare the FunctorKey for equality with another, using its constituent Keys.
Definition: aggregates.h:355
CovarianceMatrixKey< float, Eigen::Dynamic > makeCovarianceMatrixKey(Key< Covariance< float > > const &other)
Definition: aggregates.h:365
A class used as a handle to a particular field in a table.
Definition: fwd.h:44
PointKey()
Default constructor; instance will not be usuable unless subsequently assigned to.
Definition: aggregates.h:68
bool operator==(EllipseKey const &other) const
Compare the FunctorKey for equality with another, using the underlying Ixx, Iyy, Ixy Keys...
Definition: aggregates.h:254
QuadrupoleKey(Key< Moments< double > > const &other)
Definition: aggregates.h:158
virtual void set(BaseRecord &record, Eigen::Matrix< T, N, N > const &value) const
Set a covariance matrix in the given record (uses only the lower triangle of the given matrix) ...
PointKey(SubSchema const &s)
Construct from a subschema, assuming x and y subfields.
Definition: aggregates.h:90
PointKey(Key< T > const &x, Key< T > const &y)
Construct from a pair of Keys.
Definition: aggregates.h:71
virtual void set(BaseRecord &record, geom::ellipses::Ellipse const &value) const
Set an Ellipse in the given record.
bool isValid() const
Return True if all the constituent sigma Keys are valid.
A FunctorKey used to get or set a geom::ellipses::Ellipse from an (xx,yy,xy,x,y) tuple of Keys...
Definition: aggregates.h:207
QuadrupoleKey(Key< double > const &ixx, Key< double > const &iyy, Key< double > const &ixy)
Construct from individual Keys.
Definition: aggregates.h:148
Tag types used to declare specialized field types.
Definition: misc.h:30
A FunctorKey used to get or set a geom::ellipses::Quadrupole from an (xx,yy,xy) tuple of Keys...
Definition: aggregates.h:125
dictionary Point
Definition: __init__.py:38
static EllipseKey addFields(Schema &schema, std::string const &name, std::string const &doc, std::string const &unit)
bool operator==(QuadrupoleKey const &other) const
Compare the FunctorKey for equality with another, using the underlying Ixx, Iyy, Ixy Keys...
Definition: aggregates.h:181
afw::table::SourceRecord * record
CovarianceMatrixKey()
Construct an invalid instance; must assign before subsequent use.