CovarianceMatrix

class pyarts3.arts.CovarianceMatrix(*args, **kwargs)

A covariance matrix is a square matrix that describes the covariance of some property.

Please see the different workspace variables of this type for more information.

In ARTS, this square matrix is represented by two lists of Block. These are used to give both the covariance matrix and the inverse covariance matrix. The block-structure allows for efficient storage and computation of the covariance matrix.

Sizes

A variable x of this group may name 2 dimensions, read as x.nrows() and x.ncols().

Overview

Method

readxml()

Read variable from file.

Method

savexml()

Saves variable to file.

Method

validate()

Check covariance storage and mathematical validity without changing it.

Static Method

fromxml()

Create variable from file.

list[Block]

blocks

The blocks. Replacing these invalidates stored inverses.

Operator

__eq__()

Return self==value.

Operator

__format__()

__format__(self, arg: str, /) -> str

Operator

__ge__()

Return self>=value.

Operator

__gt__()

Return self>value.

Operator

__hash__()

Return hash(self).

Operator

__init__()

__init__(self, arg: pyarts3.arts.CovarianceMatrix) -> None

Operator

__le__()

Return self<=value.

Operator

__lt__()

Return self<value.

Operator

__ne__()

Return self!=value.

Operator

__repr__()

__repr__(self) -> str

Operator

__str__()

__str__(self) -> str

Constructors

__init__(self) → None
__init__(self, arg: CovarianceMatrix) → None

Methods

readxml(self, file: str) → str

Read variable from file.

Parameters:

file (str) – A file that can be read.

Raises:

RuntimeError – For any failure to read.

Returns:

file – The file path found (may differ from input due to environment variables).

Return type:

str

savexml(self, file: str, type: str = 'ascii', clobber: bool = True) → str

Saves variable to file.

Parameters:
  • file (str) – The path to which the file is written. Note that several of the options might modify the name or write more files.

  • type (str, optional) – Type of file to save. See FileType for options. Defaults is “ascii”.

  • clobber (bool, optional) – Overwrite existing files or add new file with modified name? Defaults is True.

Raises:

RuntimeError – For any failure to write.

Returns:

file – The file saved. May differ from input.

Return type:

str

validate(self, expected_size: int = -1, relative_tolerance: float = 1e-10, max_dense_elements: int = 10000000) → None

Check covariance storage and mathematical validity without changing it.

Checks full diagonal coverage, block ranges and shapes, finite entries, positive variances, symmetry, and positive definiteness after variance scaling. Independent components may have no stored inverse. If an inverse is stored for a component, it must cover that whole component, including correlations, and agree with its covariance. Validation does not fill missing inverse caches. The symmetry tolerance is relative to the geometric mean of the variances; the maximum normalized inverse identity residual is bounded by the tolerance times the component size. No absolute variance threshold is imposed.

Independent diagonal sparse blocks are checked without dense allocation. Other connected components require dense Cholesky factorization. Each dense component matrix is limited to max_dense_elements entries; several such matrices can be needed when an inverse is stored.

Raises an error identifying the invalid block or coordinate. An inverse-only operator does not provide the physical covariance required by this check.

Static Methods

fromxml(file: str) → CovarianceMatrix

Create variable from file.

Parameters:

file (str) – A file that can be read

Raises:

RuntimeError – For any failure to read.

Returns:

artstype – The variable created from the file.

Return type:

CovarianceMatrix

Attributes

blocks: list[Block]

The blocks. Replacing these invalidates stored inverses.

Operators

__eq__(value, /)

Return self==value.

__format__(self, arg: str, /) → str
__ge__(value, /)

Return self>=value.

__gt__(value, /)

Return self>value.

__hash__()

Return hash(self).

__init__(self) → None
__init__(self, arg: CovarianceMatrix) → None
__le__(value, /)

Return self<=value.

__lt__(value, /)

Return self<value.

__ne__(value, /)

Return self!=value.

__repr__(self) → str
__str__(self) → str