Template Class CovarianceMatrixKey

Inheritance Relationships

Base Type

Class Documentation

template<typename T, int N>
class CovarianceMatrixKey : public lsst::afw::table::FunctorKey<Eigen::Matrix<T, N, N>>

Unnamed Group

bool operator==(CovarianceMatrixKey const &other) const

Compare the FunctorKey for equality with another, using its constituent Keys.

bool operator!=(CovarianceMatrixKey const &other) const

Public Types

typedef std::vector<Key<T>> ErrKeyArray
typedef std::vector<Key<T>> CovarianceKeyArray
typedef std::vector<std::string> NameArray

Public Functions

CovarianceMatrixKey()

Construct an invalid instance; must assign before subsequent use.

CovarianceMatrixKey(ErrKeyArray const &err, CovarianceKeyArray const &cov = CovarianceKeyArray())

Construct a from arrays of per-element Keys

The err array Keys should point to the square root of the diagonal of the covariance matrix. The cov array Keys should point to the off-diagonal elements of the lower-triangle, packed first in rows, then in columns (or equivalently, in the upper-triangle, packed first in columns, then in rows). For a 4x4 matrix, the order is is:

err[0]^2   cov[0]     cov[1]     cov[3]
cov[0]     err[1]^2   cov[2]     cov[4]
cov[1]     cov[2]     err[2]^2   cov[5]
cov[3]     cov[4]     cov[5]     err[3]^2

The cov array may also be empty, to indicate that no off-diagonal elements are stored, and should be set to zero. If not empty, the size of the cov matrix must be exactly n*(n-1)/2, where n is the size of the err matrix.

CovarianceMatrixKey(SubSchema const &s, NameArray const &names)

Construct from a subschema and an array of names for each parameter of the matrix.

The field names should match the following convention:

  • diagonal elements should have names like “p1Err”, where “p1” is the name of the parameter, and should contain the square root of the variance in that parameter.

  • off-diagonal elements hould have names like “p1_p2_Cov”, where “p1” and “p2” are names of parameters. For example, for the covariance matrix of a position, we’d look for “xErr”, “yErr”, and “x_y_Cov”.

CovarianceMatrixKey(CovarianceMatrixKey const&)
CovarianceMatrixKey(CovarianceMatrixKey&&)
CovarianceMatrixKey &operator=(CovarianceMatrixKey const&)
CovarianceMatrixKey &operator=(CovarianceMatrixKey&&)
~CovarianceMatrixKey()
Eigen::Matrix<T, N, N> get(BaseRecord const &record) const

Get a covariance matrix from the given record.

void set(BaseRecord &record, Eigen::Matrix<T, N, N> const &value) const

Set a covariance matrix in the given record (uses only the lower triangle of the given matrix)

T getElement(BaseRecord const &record, int i, int j) const

Return the element in row i and column j.

void setElement(BaseRecord &record, int i, int j, T value) const

Set the element in row i and column j.

bool isValid() const

Return True if all the constituent error Keys are valid

Note that if the only one or more off-diagonal keys are invalid, we assume that means those terms are zero, not that the whole FunctorKey is invalid.

std::size_t hash_value() const

Return a hash of this object.

Public Static Functions

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.

Parameters
  • [out] schema: Schema to add fields to.

  • [in] prefix: String used to form the first part of all field names. Suffixes of the form ‘_xErr’ and ‘_x_y_Cov’ will be added to form the full field names (using names={‘x’, ‘y’} as an example).

  • [in] unit: Unit for for error (standard deviation) values; covariance matrix elements will be unit^2.

  • [in] names: Vector of strings containing the names of the quantities the covariance matrix represents the uncertainty of.

  • [in] diagonalOnly: If true, only create fields for the error values.

static CovarianceMatrixKey addFields(Schema &schema, std::string const &prefix, NameArray const &names, NameArray const &units, bool diagonalOnly = false)

Add covariance matrix fields to a Schema, and return a CovarianceMatrixKey to manage them.

Parameters
  • [out] schema: Schema to add fields to.

  • [in] prefix: String used to form the first part of all field names. Suffixes of the form ‘_xErr’ and ‘_x_y_Cov’ will be added to form the full field names (using names={‘x’, ‘y’} as an example).

  • [in] units: Vector of units for for error (standard deviation) values; covariance matrix elements will have “{units[i]} {units[j]}” or “{units[i]}^2”, depending on whether units[i] == units[j].

  • [in] names: Vector of strings containing the names of the quantities the covariance matrix represents the uncertainty of.

  • [in] diagonalOnly: If true, only create fields for the error values.