50 record.
set(_x, value.getX());
51 record.
set(_y, value.getY());
59 template <
typename Box>
67 template <
typename Box>
69 return Box(record.
get(_min), record.
get(_max),
false);
72 template <
typename Box>
74 _min.set(record, value.getMin());
75 _max.set(record, value.getMax());
140 template <
typename T,
int N>
144 NameArray units(names.
size(), unit);
145 return addFields(
schema,
prefix, names, units, diagonalOnly);
148 template <
typename T,
int N>
152 if (N != Eigen::Dynamic) {
154 "Size of names array (%d) does not match template argument (%d)");
156 "Size of units array (%d) does not match template argument (%d)");
163 "1-sigma uncertainty on " + names[i], units[i]));
176 "uncertainty covariance between " + names[j] +
" and " + names[i],
177 units[j] + (units[j].empty() || units[i].empty() ?
"" :
" ") + units[i]));
181 return CovarianceMatrixKey<T, N>(err, cov);
184 template <
typename T,
int N>
187 template <
typename T,
int N>
189 : _err(err), _cov(cov) {
190 if (N != Eigen::Dynamic) {
192 "Size of err array (%d) does not match template argument (%d)");
196 "Size of cov array (%d) is does not match with size inferred from err array (%d)");
197 bool haveCov =
false;
198 for (
typename CovarianceKeyArray::const_iterator i = _cov.
begin(); i != _cov.
end(); ++i) {
199 if (i->isValid()) haveCov =
true;
201 if (!haveCov) _cov.
resize(0);
205 template <
typename T,
int N>
207 : _err(names.size()), _cov(names.size() * (names.size() - 1) / 2) {
208 int const n = names.
size();
210 bool haveCov =
false;
211 for (
int i = 0; i < n; ++i) {
212 _err[i] = s[names[i] +
"Err"];
213 for (
int j = 0; j < i; ++j, ++k) {
215 _cov[k] = s[names[i] +
"_" + names[j] +
"_Cov"];
219 _cov[k] = s[names[j] +
"_" + names[i] +
"_Cov"];
226 if (!haveCov) _cov.
resize(0);
229 template <
typename T,
int N>
231 template <
typename T,
int N>
233 template <
typename T,
int N>
235 template <
typename T,
int N>
237 template <
typename T,
int N>
245 template <
typename T,
int N>
247 return Eigen::Matrix<T, N, N>::Zero();
250 template <
typename T>
251 Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> makeZeroMatrix(
252 int n, CovarianceMatrixKey<T, Eigen::Dynamic>
const *) {
253 return Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>::Zero(n, n);
258 template <
typename T,
int N>
260 Eigen::Matrix<T, N, N> value = makeZeroMatrix(_err.size(),
this);
261 int const n = _err.size();
263 for (
int i = 0; i < n; ++i) {
264 T err = record.
get(_err[i]);
265 value(i, i) = err * err;
267 for (
int j = 0; j < i; ++j, ++k) {
269 value(i, j) = value(j, i) = record.
get(_cov[k]);
277 template <
typename T,
int N>
279 int const n = _err.size();
281 for (
int i = 0; i < n; ++i) {
284 for (
int j = 0; j < i; ++j, ++k) {
286 record.
set(_cov[k], value(i, j));
293 template <
typename T,
int N>
295 int const n = _err.size();
296 if (n < 1)
return false;
297 for (
int i = 0; i < n; ++i) {
298 if (!_err[i].
isValid())
return false;
303 template <
typename T,
int N>
305 if (_err.size() != other._err.size()) {
308 if (_cov.size() != other._cov.size()) {
311 int const n = _err.size();
313 for (
int i = 0; i < n; ++i) {
314 if (_err[i] != other._err[i]) {
318 for (
int j = 0; j < i; ++j, ++k) {
319 if (_cov[k] != other._cov[k]) {
328 template <
typename T,
int N>
335 template <
typename T,
int N>
338 T err = record.
get(_err[i]);
344 Key<T> key = (i < j) ? _cov[j * (j - 1) / 2 + i] : _cov[i * (i - 1) / 2 + j];
348 template <
typename T,
int N>
356 (
boost::format(
"Cannot set covariance element %d,%d; no fields for covariance") % i % j)
359 Key<T> key = (i < j) ? _cov[j * (j - 1) / 2 + i] : _cov[i * (i - 1) / 2 + j];
363 (
boost::format(
"Cannot set covariance element %d,%d; no field for this element") % i % j)
366 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.
lsst::geom::Point2D const & getCenter() const
Return the center point.
BaseCore const & getCore() const
Return the ellipse core.
An ellipse core with quadrupole moments as parameters.
double const getIxy() const
double const getIxx() const
double const getIyy() const
Base class for all records.
void set(Key< T > const &key, U const &value)
Set value of a field for the given key.
Field< T >::Value get(Key< T > const &key) const
Return the 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 PointKeys.
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::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 (2-d specialization).
Point in an unspecified spherical coordinate system.
Angle getLatitude() const noexcept
The latitude of this point.
Angle getLongitude() const noexcept
The longitude of this point.
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.
lsst::geom::SpherePoint SpherePoint
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.
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
A base class for image defects.