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());
134 _qKey.set(record, value.
getCore());
140 template <
typename T,
int N>
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)");
162 err.push_back(schema.
addField<
T>(schema.
join(prefix, names[i] +
"Err"),
163 "1-sigma uncertainty on " + names[i], units[i]));
175 schema.
join(prefix, names[j], names[i],
"Cov"),
176 "uncertainty covariance between " + names[j] +
" and " + names[i],
177 units[j] + (units[j].
empty() || units[i].
empty() ?
"" :
" ") + units[i]));
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(
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);
An ellipse core with quadrupole moments as parameters.
Defines the fields and offsets for a table.
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
lsst::geom::Point2D const & getCenter() const
Return the center point.
A proxy type for name lookups in a Schema.
A coordinate class intended to represent absolute positions (2-d specialization). ...
lsst::geom::SpherePoint get(BaseRecord const &record) const override
Get an lsst::geom::SpherePoint from the given record.
CoordKey() noexcept
Default constructor; instance will not be usable unless subsequently assigned to. ...
#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...
std::string join(std::string const &a, std::string const &b) const
Join strings using the field delimiter appropriate for this Schema.
Reports attempts to exceed implementation-defined length limits for some classes. ...
void set(BaseRecord &record, geom::ellipses::Ellipse const &value) const override
Set an Ellipse 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.
Angle getLongitude() const noexcept
The longitude of this point.
BaseCore const & getCore() const
Return the ellipse core.
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...
ItemVariant const * other
daf::base::PropertySet * set
std::size_t hash_value(Extent< T, N > const &extent) noexcept
Field< T >::Value get(Key< T > const &key) const
Return the value of a field for the given key.
bool isValid() const noexcept
Return true if the key was initialized to valid offset.
A class representing an angle.
A FunctorKey used to get or set a lsst::geom::Box2I or Box2D from a (min, max) pair of PointKeys...
Reports attempts to access elements using an invalid key.
double const getIxy() const
double const getIyy() const
A base class for image defects.
A FunctorKey used to get or set a lsst::geom::Point from an (x,y) pair of int or double Keys...
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...
An ellipse defined by an arbitrary BaseCore and a center point.
Angle getLatitude() const noexcept
The latitude of this point.
Reports errors in the logical structure of the program.
CoordinateType
Enum used to set units for geometric FunctorKeys.
std::size_t hashIterable(std::size_t seed, InputIterator begin, InputIterator end) noexcept
Combine hashes in an iterable.
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Base class for all records.
Point in an unspecified spherical coordinate system.
A class used as a handle to a particular field in a table.
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.
void set(Key< T > const &key, U const &value)
Set value of a field for the given key.
lsst::geom::SpherePoint SpherePoint
void set(BaseRecord &record, geom::ellipses::Quadrupole const &value) const override
Set a Quadrupole in the given record.
void set(BaseRecord &record, Box const &value) const override
Set a Box 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...
void set(BaseRecord &record, lsst::geom::SpherePoint const &value) const override
Set an lsst::geom::SpherePoint in the given record.
std::size_t hashCombine(std::size_t seed) noexcept
Combine hashes.
A FunctorKey used to get or set a geom::ellipses::Ellipse from an (xx,yy,xy,x,y) tuple of Keys...
A FunctorKey used to get or set a geom::ellipses::Quadrupole from a tuple of constituent Keys...
lsst::geom::Point< T, 2 > get(BaseRecord const &record) const override
Get a Point from the given record.
Key< T > addField(Field< T > const &field, bool doReplace=false)
Add a new field to the Schema, and return the associated Key.
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...
geom::ellipses::Quadrupole get(BaseRecord const &record) const override
Get a Quadrupole from the given record.
double const getIxx() const
geom::ellipses::Ellipse get(BaseRecord const &record) const override
Get an Ellipse from the given record.
CovarianceMatrixKey()
Construct an invalid instance; must assign before subsequent use.
A FunctorKey used to get or set celestial coordinates from a pair of lsst::geom::Angle keys...
void set(BaseRecord &record, lsst::geom::Point< T, 2 > const &value) const override
Set a Point in the given record.
Box get(BaseRecord const &record) const override
Get a Box from the given record.