50 record.
set(_x, value.getX());
51 record.
set(_y, value.getY());
75 record.
set(_x, value.getX());
76 record.
set(_y, value.getY());
77 record.
set(_z, value.getZ());
85template <
typename Box>
93template <
typename Box>
95 return Box(record.
get(_min), record.
get(_max),
false);
98template <
typename Box>
100 _min.set(record, value.getMin());
101 _max.set(record, value.getMax());
120 record.
set(_ra, value.getLongitude());
121 record.
set(_dec, value.getLatitude());
141 record.
set(_ixx, value.getIxx());
142 record.
set(_iyy, value.getIyy());
143 record.
set(_ixy, value.getIxy());
160 _qKey.
set(record, value.getCore());
161 _pKey.
set(record, value.getCenter());
166template <
typename T,
int N>
171 return addFields(
schema,
prefix, names, units, diagonalOnly);
174template <
typename T,
int N>
178 if (N != Eigen::Dynamic) {
180 "Size of names array (%d) does not match template argument (%d)");
182 "Size of units array (%d) does not match template argument (%d)");
189 "1-sigma uncertainty on " + names[i], units[i]));
192 cov.
reserve((names.size() * (names.size() - 1)) / 2);
202 "uncertainty covariance between " + names[j] +
" and " + names[i],
203 units[j] + (units[j].
empty() || units[i].
empty() ?
"" :
" ") + units[i]));
210template <
typename T,
int N>
213template <
typename T,
int N>
215 : _err(err), _cov(cov) {
216 if (N != Eigen::Dynamic) {
218 "Size of err array (%d) does not match template argument (%d)");
222 "Size of cov array (%d) is does not match with size inferred from err array (%d)");
223 bool haveCov =
false;
224 for (
typename CovarianceKeyArray::const_iterator i = _cov.
begin(); i != _cov.
end(); ++i) {
225 if (i->isValid()) haveCov =
true;
227 if (!haveCov) _cov.
resize(0);
231template <
typename T,
int N>
233 : _err(names.size()), _cov(names.size() * (names.size() - 1) / 2) {
234 int const n = names.size();
236 bool haveCov =
false;
237 for (
int i = 0; i < n; ++i) {
238 _err[i] = s[names[i] +
"Err"];
239 for (
int j = 0; j < i; ++j, ++k) {
241 _cov[k] = s[names[i] +
"_" + names[j] +
"_Cov"];
245 _cov[k] = s[names[j] +
"_" + names[i] +
"_Cov"];
252 if (!haveCov) _cov.
resize(0);
255template <
typename T,
int N>
257template <
typename T,
int N>
259template <
typename T,
int N>
261template <
typename T,
int N>
263template <
typename T,
int N>
271template <
typename T,
int N>
273 return Eigen::Matrix<T, N, N>::Zero();
277Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> makeZeroMatrix(
279 return Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>::Zero(n, n);
284template <
typename T,
int N>
286 Eigen::Matrix<T, N, N> value = makeZeroMatrix(_err.size(),
this);
287 int const n = _err.size();
289 for (
int i = 0; i < n; ++i) {
290 T err = record.
get(_err[i]);
291 value(i, i) = err * err;
293 for (
int j = 0; j < i; ++j, ++k) {
295 value(i, j) = value(j, i) = record.
get(_cov[k]);
303template <
typename T,
int N>
305 int const n = _err.size();
307 for (
int i = 0; i < n; ++i) {
310 for (
int j = 0; j < i; ++j, ++k) {
312 record.
set(_cov[k], value(i, j));
319template <
typename T,
int N>
321 int const n = _err.size();
322 if (n < 1)
return false;
323 for (
int i = 0; i < n; ++i) {
324 if (!_err[i].
isValid())
return false;
329template <
typename T,
int N>
331 if (_err.size() != other._err.size()) {
334 if (_cov.size() != other._cov.size()) {
337 int const n = _err.size();
339 for (
int i = 0; i < n; ++i) {
340 if (_err[i] != other._err[i]) {
344 for (
int j = 0; j < i; ++j, ++k) {
345 if (_cov[k] != other._cov[k]) {
354template <
typename T,
int N>
361template <
typename T,
int N>
364 T err = record.
get(_err[i]);
370 Key<T> key = (i < j) ? _cov[j * (j - 1) / 2 + i] : _cov[i * (i - 1) / 2 + j];
374template <
typename T,
int N>
382 (boost::format(
"Cannot set covariance element %d,%d; no fields for covariance") % i % j)
385 Key<T> key = (i < j) ? _cov[j * (j - 1) / 2 + i] : _cov[i * (i - 1) / 2 + j];
389 (boost::format(
"Cannot set covariance element %d,%d; no field for this element") % i % j)
392 record.
set(key, value);
table::Key< std::string > name
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
#define LSST_THROW_IF_NE(N1, N2, EXC_CLASS, MSG)
Check whether the given values are equal, and throw an LSST Exception if they are not.
An ellipse defined by an arbitrary BaseCore and a center point.
An ellipse core with quadrupole moments as parameters.
Base class for all records.
Field< T >::Value get(Key< T > const &key) const
Return the value of a field for the given key.
void set(Key< T > const &key, U const &value)
Set value of a field for the given key.
A FunctorKey used to get or set a lsst::geom::Box2I or Box2D from a (min, max) pair of Point3Keys.
Box get(BaseRecord const &record) const override
Get a Box from the given record.
static BoxKey addFields(Schema &schema, std::string const &name, std::string const &doc, std::string const &unit)
Add _min_x, _min_y, _max_x, _max_y fields to a Schema, and return a BoxKey that points to them.
void set(BaseRecord &record, Box const &value) const override
Set a Box in the given record.
A FunctorKey used to get or set celestial coordinates from a pair of lsst::geom::Angle keys.
static CoordKey addFields(afw::table::Schema &schema, std::string const &name, std::string const &doc)
Add a pair of _ra, _dec fields to a Schema, and return a CoordKey that points to them.
CoordKey() noexcept
Default constructor; instance will not be usable unless subsequently assigned to.
void set(BaseRecord &record, lsst::geom::SpherePoint const &value) const override
Set an lsst::geom::SpherePoint in the given record.
lsst::geom::SpherePoint get(BaseRecord const &record) const override
Get an lsst::geom::SpherePoint from the given record.
bool operator==(CovarianceMatrixKey const &other) const noexcept
Compare the FunctorKey for equality with another, using its constituent Keys.
CovarianceMatrixKey()
Construct an invalid instance; must assign before subsequent use.
Eigen::Matrix< T, N, N > get(BaseRecord const &record) const override
Get a covariance matrix from the given record.
void setElement(BaseRecord &record, int i, int j, T value) const
Set the element in row i and column j.
T getElement(BaseRecord const &record, int i, int j) const
Return the element in row i and column j.
void set(BaseRecord &record, Eigen::Matrix< T, N, N > const &value) const override
Set a covariance matrix in the given record (uses only the lower triangle of the given matrix)
~CovarianceMatrixKey() noexcept override
static CovarianceMatrixKey addFields(Schema &schema, std::string const &prefix, NameArray const &names, std::string const &unit, bool diagonalOnly=false)
Add covariance matrix fields to a Schema, and return a CovarianceMatrixKey to manage them.
std::size_t hash_value() const noexcept
Return a hash of this object.
bool isValid() const noexcept
Return True if all the constituent error Keys are valid.
CovarianceMatrixKey & operator=(CovarianceMatrixKey const &)
A FunctorKey used to get or set a geom::ellipses::Ellipse from an (xx,yy,xy,x,y) tuple of Keys.
void set(BaseRecord &record, geom::ellipses::Ellipse const &value) const override
Set an Ellipse in the given record.
static EllipseKey addFields(Schema &schema, std::string const &name, std::string const &doc, std::string const &unit)
Add a set of _xx, _yy, _xy, _x, _y fields to a Schema, and return an EllipseKey that points to them.
geom::ellipses::Ellipse get(BaseRecord const &record) const override
Get an Ellipse from the given record.
EllipseKey() noexcept
Default constructor; instance will not be usable unless subsequently assigned to.
A class used as a handle to a particular field in a table.
bool isValid() const noexcept
Return true if the key was initialized to valid offset.
A FunctorKey used to get or set a lsst::geom::Point3 from an (x,y,z) tuple of int or double Keys.
void set(BaseRecord &record, lsst::geom::Point< T, 3 > const &value) const override
Set a Point in the given record.
static Point3Key addFields(Schema &schema, std::string const &name, std::string const &doc, std::string const &unit)
Add a pair of _x, _y, _z fields to a Schema, and return a Point3Key that points to them.
lsst::geom::Point< T, 3 > get(BaseRecord const &record) const override
Get a Point from the given record.
A FunctorKey used to get or set a lsst::geom::Point from an (x,y) pair of int or double Keys.
void set(BaseRecord &record, lsst::geom::Point< T, 2 > const &value) const override
Set a Point in the given record.
static PointKey addFields(Schema &schema, std::string const &name, std::string const &doc, std::string const &unit)
Add a pair of _x, _y fields to a Schema, and return a PointKey that points to them.
lsst::geom::Point< T, 2 > get(BaseRecord const &record) const override
Get a Point from the given record.
A FunctorKey used to get or set a geom::ellipses::Quadrupole from a tuple of constituent Keys.
geom::ellipses::Quadrupole get(BaseRecord const &record) const override
Get a Quadrupole from the given record.
QuadrupoleKey() noexcept
Default constructor; instance will not be usable unless subsequently assigned to.
void set(BaseRecord &record, geom::ellipses::Quadrupole const &value) const override
Set a Quadrupole in the given record.
static QuadrupoleKey addFields(Schema &schema, std::string const &name, std::string const &doc, CoordinateType coordType=CoordinateType::PIXEL)
Add a set of quadrupole subfields to a schema and return a QuadrupoleKey that points to them.
Defines the fields and offsets for a table.
A proxy type for name lookups in a Schema.
A class representing an angle.
A coordinate class intended to represent absolute positions.
Point in an unspecified spherical coordinate system.
Reports attempts to exceed implementation-defined length limits for some classes.
Reports errors in the logical structure of the program.
Reports attempts to access elements using an invalid key.
CoordinateType
Enum used to set units for geometric FunctorKeys.
std::size_t hashCombine(std::size_t seed) noexcept
Combine hashes.
std::size_t hashIterable(std::size_t seed, InputIterator begin, InputIterator end) noexcept
Combine hashes in an iterable.