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 as a numpy.ndarray.

data

Covariance data as a 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([figsize])

Plot correlation matrix.

set_subcovariance(covar)

Set sub-covariance matrix.

Attributes Documentation

correlation#

Correlation matrix as a numpy.ndarray.

Correlation \(C\) is related to covariance \(\Sigma\) via:

\[C_{ij} = \frac{ \Sigma_{ij} }{ \sqrt{\Sigma_{ii} \Sigma_{jj}} }\]
data#

Covariance data as a 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(figsize=None, **kwargs)[source]#

Plot correlation matrix.

Parameters:
figsizetuple, optional

Figure size. Default is None, which takes (number_params*0.9, number_params*0.7).

**kwargsdict

Keyword arguments passed to plot_heatmap.

Returns:
axAxes, optional

Matplotlib axes.

set_subcovariance(covar)[source]#

Set sub-covariance matrix.

Parameters:
covarCovariance

Sub-covariance.