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 sigma.push_back(schema.
addField<T>(schema.
join(prefix, names[i] +
"Sigma"),
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 : _sigma(sigma), _cov(cov) {
190 if (N != Eigen::Dynamic) {
192 "Size of sigma array (%d) does not match template argument (%d)");
196 "Size of cov array (%d) is does not match with size inferred from sigma 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 : _sigma(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 _sigma[i] = s[names[i] +
"Sigma"];
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>
246 template <
typename T,
int N>
248 return Eigen::Matrix<T, N, N>::Zero();
251 template <
typename T>
252 Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> makeZeroMatrix(
254 return Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>::Zero(n, n);
259 template <
typename T,
int N>
261 Eigen::Matrix<T, N, N> value = makeZeroMatrix(_sigma.size(),
this);
262 int const n = _sigma.size();
264 for (
int i = 0; i < n; ++i) {
266 value(i, i) = sigma *
sigma;
268 for (
int j = 0; j < i; ++j, ++k) {
270 value(i, j) = value(j, i) = record.
get(_cov[k]);
278 template <
typename T,
int N>
280 int const n = _sigma.size();
282 for (
int i = 0; i < n; ++i) {
285 for (
int j = 0; j < i; ++j, ++k) {
287 record.
set(_cov[k], value(i, j));
294 template <
typename T,
int N>
296 int const n = _sigma.size();
297 if (n < 1)
return false;
298 for (
int i = 0; i < n; ++i) {
299 if (!_sigma[i].
isValid())
return false;
304 template <
typename T,
int N>
306 if (_sigma.size() != other._sigma.
size()) {
309 if (_cov.size() != other._cov.
size()) {
312 int const n = _sigma.size();
314 for (
int i = 0; i < n; ++i) {
315 if (_sigma[i] != other._sigma[i]) {
319 for (
int j = 0; j < i; ++j, ++k) {
320 if (_cov[k] != other._cov[k]) {
329 template <
typename T,
int N>
333 return sigma *
sigma;
338 Key<T> key = (i < j) ? _cov[j * (j - 1) / 2 + i] : _cov[i * (i - 1) / 2 + j];
342 template <
typename T,
int N>
350 (boost::format(
"Cannot set covariance element %d,%d; no fields for covariance") % i %
353 Key<T> key = (i < j) ? _cov[j * (j - 1) / 2 + i] : _cov[i * (i - 1) / 2 + j];
357 (boost::format(
"Cannot set covariance element %d,%d; no field for this element") % i %
360 record.
set(key, value);
CoordKey()
Default constructor; instance will not be usable unless subsequently assigned to. ...
An ellipse core with quadrupole moments as parameters.
Defines the fields and offsets for a table.
A coordinate class intended to represent absolute positions (2-d specialization). ...
Point in an unspecified spherical coordinate system.
A proxy type for name lookups in a Schema.
#define LSST_THROW_IF_NE(N1, N2, EXC_CLASS, MSG)
afw::table::Schema schema
std::string join(std::string const &a, std::string const &b) const
Join strings using the field delimiter appropriate for this Schema.
Angle getLongitude() const noexcept
The longitude of this point.
virtual void set(BaseRecord &record, geom::ellipses::Ellipse const &value) const
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.
bool operator==(CoordKey const &lhs, CoordKey const &rhs)
Compare CoordKeys for equality using the constituent Keys.
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
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 geom::Box2I or Box2D from a (min, max) pair of PointKeys.
bool isValid() const
Return true if the key was initialized to valid offset.
afw::table::Key< double > sigma
lsst::afw::geom::SpherePoint SpherePoint
virtual Box get(BaseRecord const &record) const
Get a Point from the given record.
double const getIxy() const
double const getIyy() const
virtual void set(BaseRecord &record, geom::ellipses::Quadrupole const &value) const
Set a Quadrupole in the given record.
A class representing an angle.
A base class for image defects.
A FunctorKey used to get or set a geom::Point from an (x,y) pair of int or double Keys...
virtual void set(BaseRecord &record, Box const &value) const
Set a Point in the given record.
virtual SpherePoint get(BaseRecord const &record) const
Get an SpherePoint from 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...
An ellipse defined by an arbitrary BaseCore and a center point.
virtual geom::ellipses::Ellipse get(BaseRecord const &record) const
Get an Ellipse from the given record.
virtual geom::ellipses::Quadrupole get(BaseRecord const &record) const
Get a Quadrupole from the given record.
virtual void set(BaseRecord &record, SpherePoint const &value) const
Set an SpherePoint in the given record.
CoordinateType
Enum used to set units for geometric FunctorKeys.
Angle getLatitude() const noexcept
The latitude of this point.
#define LSST_EXCEPT(type,...)
Base class for all records.
Point2D const & getCenter() const
Return the center point.
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.
virtual void set(BaseRecord &record, geom::Point< T, 2 > const &value) const
Set a Point 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...
virtual geom::Point< T, 2 > get(BaseRecord const &record) const
Get a Point from the given record.
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...
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...
double const getIxx() const
CovarianceMatrixKey()
Construct an invalid instance; must assign before subsequent use.
A FunctorKey used to get or set celestial coordinates from a pair of Angle keys.
daf::base::PropertySet * set