Note

You are not reading the most up to date version of Gammapy documentation.
Access the latest stable version v1.3 or the list of Gammapy releases.

Covariance

class gammapy.modeling.Covariance(parameters, data=None)[source]

Bases: object

Parameter covariance class

Parameters
parametersParameters

Parameter list

datandarray

Covariance data array

Attributes Summary

correlation

Correlation matrix (numpy.ndarray).

data

Covariance data (ndarray)

scipy_mvn

shape

Covariance shape

Methods Summary

from_factor_matrix(parameters, matrix)

Set covariance from factor covariance matrix.

from_stack(covar_list)

Stack sub-covariance matrices from list

get_subcovariance(parameters)

Get sub-covariance matrix

plot_correlation([ax])

Plot correlation matrix.

set_subcovariance(covar)

Set sub-covariance matrix

Attributes Documentation

correlation

Correlation matrix (numpy.ndarray).

Correlation C is related to covariance Σ via:

Cij=ΣijΣiiΣjj
data

Covariance data (ndarray)

scipy_mvn
shape

Covariance shape

Methods Documentation

classmethod from_factor_matrix(parameters, matrix)[source]

Set covariance from factor covariance matrix.

Used in the optimizer interface.

classmethod from_stack(covar_list)[source]

Stack sub-covariance matrices from list

Parameters
covar_listlist of Covariance

List of sub-covariances

Returns
covarCovariance

Stacked covariance

get_subcovariance(parameters)[source]

Get sub-covariance matrix

Parameters
parametersParameters

Sub list of parameters.

Returns
covariancendarray

Sub-covariance.

plot_correlation(ax=None, **kwargs)[source]

Plot correlation matrix.

Parameters
axAxes, optional

Axis to plot on.

**kwargsdict

Keyword arguments passed to plot_heatmap

Returns
axAxes, optional

Axis

set_subcovariance(covar)[source]

Set sub-covariance matrix

Parameters
parametersParameters

Sub list of parameters.