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());
149 record.
set(_ixx, value.getIxx());
150 record.
set(_iyy, value.getIyy());
151 record.
set(_ixy, value.getIxy());
168 _qKey.
set(record, value.getCore());
169 _pKey.
set(record, value.getCenter());
174template <
typename T,
int N>
182template <
typename T,
int N>
186 if (
N != Eigen::Dynamic) {
188 "Size of names array (%d) does not match template argument (%d)");
190 "Size of units array (%d) does not match template argument (%d)");
197 "1-sigma uncertainty on " + names[i], units[i]));
200 cov.reserve((names.
size() * (names.
size() - 1)) / 2);
210 "uncertainty covariance between " + names[
j] +
" and " + names[i],
211 units[
j] + (units[
j].empty() || units[i].empty() ?
"" :
" ") + units[i]));
218template <
typename T,
int N>
221template <
typename T,
int N>
224 if (
N != Eigen::Dynamic) {
226 "Size of err array (%d) does not match template argument (%d)");
230 "Size of cov array (%d) is does not match with size inferred from err array (%d)");
232 for (
typename CovarianceKeyArray::const_iterator i = _cov.
begin(); i != _cov.
end(); ++i) {
233 if (i->isValid())
haveCov =
true;
235 if (!haveCov) _cov.
resize(0);
239template <
typename T,
int N>
241 : _err(names.size()), _cov(names.size() * (names.size() - 1) / 2) {
242 int const n = names.
size();
245 for (
int i = 0; i < n; ++i) {
246 _err[i] = s[names[i] +
"Err"];
247 for (
int j = 0;
j < i; ++
j, ++k) {
249 _cov[k] = s[names[i] +
"_" + names[
j] +
"_Cov"];
253 _cov[k] = s[names[
j] +
"_" + names[i] +
"_Cov"];
260 if (!haveCov) _cov.
resize(0);
263template <
typename T,
int N>
265template <
typename T,
int N>
267template <
typename T,
int N>
269template <
typename T,
int N>
271template <
typename T,
int N>
279template <
typename T,
int N>
281 return Eigen::Matrix<T, N, N>::Zero();
285Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> makeZeroMatrix(
286 int n, CovarianceMatrixKey<T, Eigen::Dynamic>
const *) {
287 return Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>::Zero(n, n);
292template <
typename T,
int N>
295 int const n = _err.size();
297 for (
int i = 0; i < n; ++i) {
298 T
err = record.
get(_err[i]);
301 for (
int j = 0;
j < i; ++
j, ++k) {
303 value(i,
j) = value(
j, i) = record.
get(_cov[k]);
311template <
typename T,
int N>
313 int const n = _err.size();
315 for (
int i = 0; i < n; ++i) {
318 for (
int j = 0;
j < i; ++
j, ++k) {
320 record.
set(_cov[k], value(i,
j));
327template <
typename T,
int N>
329 int const n = _err.size();
330 if (n < 1)
return false;
331 for (
int i = 0; i < n; ++i) {
332 if (!_err[i].
isValid())
return false;
337template <
typename T,
int N>
339 if (_err.size() != other._err.size()) {
342 if (_cov.size() != other._cov.size()) {
345 int const n = _err.size();
347 for (
int i = 0; i < n; ++i) {
348 if (_err[i] != other._err[i]) {
352 for (
int j = 0;
j < i; ++
j, ++k) {
353 if (_cov[k] != other._cov[k]) {
362template <
typename T,
int N>
369template <
typename T,
int N>
372 T
err = record.
get(_err[i]);
378 Key<T> key = (i <
j) ? _cov[
j * (
j - 1) / 2 + i] : _cov[i * (i - 1) / 2 +
j];
379 return key.isValid() ? record.
get(key) : 0.0;
382template <
typename T,
int N>
390 (boost::format(
"Cannot set covariance element %d,%d; no fields for covariance") % i %
j)
393 Key<T> key = (i <
j) ? _cov[
j * (
j - 1) / 2 + i] : _cov[i * (i - 1) / 2 +
j];
394 if (!key.isValid()) {
397 (boost::format(
"Cannot set covariance element %d,%d; no field for this element") % i %
j)
400 record.
set(key, value);
#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.
Tag types used to declare specialized field types.
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.
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.
CovarianceMatrixKey< float, 2 > ErrorKey
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.
static ErrorKey addErrorFields(Schema &schema)
static ErrorKey getErrorKey(Schema const &schema)
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.
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.
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.