Likelihoods¶
base¶
- class desilike.likelihoods.base.BaseGaussianLikelihood(*args, **kwargs)[source]¶
Bases:
BaseLikelihoodBase class for Gaussian likelihood, which allows parameters the theory is linear with to be analytically marginalized over.
- Parameters:
data (array) – Data.
covariance (array, default=None) – Covariance matrix (or its diagonal).
precision (array, default=None) – If
covarianceis not provided, precision matrix (or its diagonal).
- class desilike.likelihoods.base.BaseLikelihood(*args, **kwargs)[source]¶
Bases:
BaseCalculatorBase class for likelihood.
- get()[source]¶
Return quantity of main interest, e.g. loglikelihood + logprior if
selfis a likelihood.
- classmethod sum(*others)[source]¶
Sum likelihoods: return
SumLikelihoodinstance.
- class desilike.likelihoods.base.ObservablesGaussianLikelihood(*args, **kwargs)[source]¶
Bases:
BaseGaussianLikelihoodGaussian likelihood of observables.
- Parameters:
observables (list, BaseCalculator) – List of (or single) observable, e.g.
TracerPowerSpectrumMultipolesObservableorTracerCorrelationFunctionMultipolesObservable.covariance (array, default=None) – Covariance matrix (or its diagonal) for input
observables. IfNone, covariance matrix is computed on-the-fly using observables’ mocks.scale_covariance (float, default=1.) – Scale precision by the inverse of this value.
correct_covariance (str, default='hartlap-percival2014') – Only applies if mocks are provided to input observables. ‘hartlap’ to apply Hartlap 2007 factor (https://arxiv.org/abs/astro-ph/0608064). ‘percival2014’ to apply Percival 2014 factor (https://arxiv.org/abs/1312.4841). Can be a dictionary to specify the number of observations,
{'nobs': nobs, 'correction': 'hartlap-percival2014'}.precision (array, default=None) – Precision matrix to be used instead of the inverse covariance.
- plot_covariance_matrix(corrcoef=True, **kwargs)[source]¶
Plot covariance matrix.
- Parameters:
corrcoef (bool, default=True) – If
True, plot the correlation matrix; else the covariance.barlabel (str, default=None) – Optionally, label for the color bar.
label1 (str, list of str, default=None) – Optionally, label(s) for the observable(s).
figsize (int, tuple, default=None) – Optionally, figure size.
norm (matplotlib.colors.Normalize, default=None) – Scales the covariance / correlation to the canonical colormap range [0, 1] for mapping to colors. By default, the covariance / correlation range is mapped to the color bar range using linear scaling.
labelsize (int, default=None) – Optionally, size for labels.
fig (matplotlib.figure.Figure, default=None) – Optionally, a figure with at least
len(self.observables) * len(self.observables)axes.
- Returns:
fig
- Return type:
matplotlib.figure.Figure
- class desilike.likelihoods.base.SumLikelihood(*args, **kwargs)[source]¶
Bases:
BaseLikelihood
cmb¶
- class desilike.likelihoods.cmb.planck2018_clik.BasePlanck2018ClikLikelihood(*args, **kwargs)[source]¶
Bases:
BaseLikelihoodBase class for clik likelihood of Planck’s 2018 data release.
Reference¶
https://arxiv.org/abs/1807.06209
https://wiki.cosmos.esa.int/planck-legacy-archive/index.php/CMB_spectrum_%26_Likelihood_Code
- param theory:
Theory calculator for CMB \(C_{\ell}^{xy}\). If
None, instantiated usingcosmo.- type theory:
ClTheory, default=None
- param cosmo:
Optionally, cosmology calculator. Defaults to
Cosmoprimo().- type cosmo:
BasePrimordialCosmology, default=None
- param data_dir:
Data directory. Defaults to path saved in desilike’s configuration, as provided by
Installerif likelihood has been installed.- type data_dir:
str, Path, default=None
- class desilike.likelihoods.cmb.planck2018_clik.EELowlPlanck2018ClikLikelihood(*args, **kwargs)[source]¶
Bases:
BasePlanck2018ClikLikelihoodLow-\(\ell\) polarization plik likelihood of Planck’s 2018 data release.
Reference¶
https://arxiv.org/abs/1807.06209
https://wiki.cosmos.esa.int/planck-legacy-archive/index.php/CMB_spectrum_%26_Likelihood_Code
- param theory:
Theory calculator for CMB \(C_{\ell}^{xy}\). If
None, instantiated usingcosmo.- type theory:
ClTheory, default=None
- param cosmo:
Optionally, cosmology calculator. Defaults to
Cosmoprimo().- type cosmo:
BasePrimordialCosmology, default=None
- param data_dir:
Data directory. Defaults to path saved in desilike’s configuration, as provided by
Installerif likelihood has been installed.- type data_dir:
str, Path, default=None
- class desilike.likelihoods.cmb.planck2018_clik.LensingPlanck2018ClikLikelihood(*args, **kwargs)[source]¶
Bases:
BasePlanck2018ClikLikelihoodLensing likelihood of Planck’s 2018 data release based on temperature+polarization map-based lensing reconstruction.
Reference¶
https://arxiv.org/abs/1807.06209
https://wiki.cosmos.esa.int/planck-legacy-archive/index.php/CMB_spectrum_%26_Likelihood_Code
- param theory:
Theory calculator for CMB \(C_{\ell}^{xy}\). If
None, instantiated usingcosmo.- type theory:
ClTheory, default=None
- param cosmo:
Optionally, cosmology calculator. Defaults to
Cosmoprimo().- type cosmo:
BasePrimordialCosmology, default=None
- param data_dir:
Data directory. Defaults to path saved in desilike’s configuration, as provided by
Installerif likelihood has been installed.- type data_dir:
str, Path, default=None
- class desilike.likelihoods.cmb.planck2018_clik.TTHighlPlanck2018PlikLikelihood(*args, **kwargs)[source]¶
Bases:
BasePlanck2018ClikLikelihoodHigh-\(\ell\) temperature-only plik likelihood of Planck’s 2018 data release.
Reference¶
https://arxiv.org/abs/1807.06209
https://wiki.cosmos.esa.int/planck-legacy-archive/index.php/CMB_spectrum_%26_Likelihood_Code
- param theory:
Theory calculator for CMB \(C_{\ell}^{xy}\). If
None, instantiated usingcosmo.- type theory:
ClTheory, default=None
- param cosmo:
Optionally, cosmology calculator. Defaults to
Cosmoprimo().- type cosmo:
BasePrimordialCosmology, default=None
- param data_dir:
Data directory. Defaults to path saved in desilike’s configuration, as provided by
Installerif likelihood has been installed.- type data_dir:
str, Path, default=None
- class desilike.likelihoods.cmb.planck2018_clik.TTHighlPlanck2018PlikLiteLikelihood(*args, **kwargs)[source]¶
Bases:
BasePlanck2018ClikLikelihoodHigh-\(\ell\) temperature-only plik likelihood of Planck’s 2018 data release, marginalized over the foreground model.
Reference¶
https://arxiv.org/abs/1807.06209
https://wiki.cosmos.esa.int/planck-legacy-archive/index.php/CMB_spectrum_%26_Likelihood_Code
- param theory:
Theory calculator for CMB \(C_{\ell}^{xy}\). If
None, instantiated usingcosmo.- type theory:
ClTheory, default=None
- param cosmo:
Optionally, cosmology calculator. Defaults to
Cosmoprimo().- type cosmo:
BasePrimordialCosmology, default=None
- param data_dir:
Data directory. Defaults to path saved in desilike’s configuration, as provided by
Installerif likelihood has been installed.- type data_dir:
str, Path, default=None
- class desilike.likelihoods.cmb.planck2018_clik.TTHighlPlanck2018PlikUnbinnedLikelihood(*args, **kwargs)[source]¶
Bases:
BasePlanck2018ClikLikelihoodHigh-\(\ell\) temperature-only plik likelihood of Planck’s 2018 data release.
Reference¶
https://arxiv.org/abs/1807.06209
https://wiki.cosmos.esa.int/planck-legacy-archive/index.php/CMB_spectrum_%26_Likelihood_Code
- param theory:
Theory calculator for CMB \(C_{\ell}^{xy}\). If
None, instantiated usingcosmo.- type theory:
ClTheory, default=None
- param cosmo:
Optionally, cosmology calculator. Defaults to
Cosmoprimo().- type cosmo:
BasePrimordialCosmology, default=None
- param data_dir:
Data directory. Defaults to path saved in desilike’s configuration, as provided by
Installerif likelihood has been installed.- type data_dir:
str, Path, default=None
- class desilike.likelihoods.cmb.planck2018_clik.TTLowlPlanck2018ClikLikelihood(*args, **kwargs)[source]¶
Bases:
BasePlanck2018ClikLikelihoodLow-\(\ell\) temperature-only plik likelihood of Planck’s 2018 data release.
Reference¶
https://arxiv.org/abs/1807.06209
https://wiki.cosmos.esa.int/planck-legacy-archive/index.php/CMB_spectrum_%26_Likelihood_Code
- param theory:
Theory calculator for CMB \(C_{\ell}^{xy}\). If
None, instantiated usingcosmo.- type theory:
ClTheory, default=None
- param cosmo:
Optionally, cosmology calculator. Defaults to
Cosmoprimo().- type cosmo:
BasePrimordialCosmology, default=None
- param data_dir:
Data directory. Defaults to path saved in desilike’s configuration, as provided by
Installerif likelihood has been installed.- type data_dir:
str, Path, default=None
- class desilike.likelihoods.cmb.planck2018_clik.TTTEEEHighlPlanck2018PlikLikelihood(*args, **kwargs)[source]¶
Bases:
BasePlanck2018ClikLikelihoodHigh-\(\ell\) temperature and polarization plik likelihood of Planck’s 2018 data release.
Reference¶
https://arxiv.org/abs/1807.06209
https://wiki.cosmos.esa.int/planck-legacy-archive/index.php/CMB_spectrum_%26_Likelihood_Code
- param theory:
Theory calculator for CMB \(C_{\ell}^{xy}\). If
None, instantiated usingcosmo.- type theory:
ClTheory, default=None
- param cosmo:
Optionally, cosmology calculator. Defaults to
Cosmoprimo().- type cosmo:
BasePrimordialCosmology, default=None
- param data_dir:
Data directory. Defaults to path saved in desilike’s configuration, as provided by
Installerif likelihood has been installed.- type data_dir:
str, Path, default=None
- class desilike.likelihoods.cmb.planck2018_clik.TTTEEEHighlPlanck2018PlikLiteLikelihood(*args, **kwargs)[source]¶
Bases:
BasePlanck2018ClikLikelihoodHigh-\(\ell\) temperature and polarization plik likelihood of Planck’s 2018 data release, marginalized over the foreground model.
Reference¶
https://arxiv.org/abs/1807.06209
https://wiki.cosmos.esa.int/planck-legacy-archive/index.php/CMB_spectrum_%26_Likelihood_Code
- param theory:
Theory calculator for CMB \(C_{\ell}^{xy}\). If
None, instantiated usingcosmo.- type theory:
ClTheory, default=None
- param cosmo:
Optionally, cosmology calculator. Defaults to
Cosmoprimo().- type cosmo:
BasePrimordialCosmology, default=None
- param data_dir:
Data directory. Defaults to path saved in desilike’s configuration, as provided by
Installerif likelihood has been installed.- type data_dir:
str, Path, default=None
- class desilike.likelihoods.cmb.planck2018_clik.TTTEEEHighlPlanck2018PlikUnbinnedLikelihood(*args, **kwargs)[source]¶
Bases:
BasePlanck2018ClikLikelihoodHigh-\(\ell\) temperature and polarization plik likelihood of Planck’s 2018 data release.
Reference¶
https://arxiv.org/abs/1807.06209
https://wiki.cosmos.esa.int/planck-legacy-archive/index.php/CMB_spectrum_%26_Likelihood_Code
- param theory:
Theory calculator for CMB \(C_{\ell}^{xy}\). If
None, instantiated usingcosmo.- type theory:
ClTheory, default=None
- param cosmo:
Optionally, cosmology calculator. Defaults to
Cosmoprimo().- type cosmo:
BasePrimordialCosmology, default=None
- param data_dir:
Data directory. Defaults to path saved in desilike’s configuration, as provided by
Installerif likelihood has been installed.- type data_dir:
str, Path, default=None
- class desilike.likelihoods.cmb.planck2018_gaussian.BasePlanck2018GaussianLikelihood(*args, **kwargs)[source]¶
Bases:
BaseGaussianLikelihoodGaussian approximation of “base” likelihoods of Planck’s 2018 data release.
Reference¶
https://arxiv.org/abs/1807.06209
https://wiki.cosmos.esa.int/planck-legacy-archive/index.php/CMB_spectrum_%26_Likelihood_Code
- param cosmo:
Cosmology calculator. Defaults to
Cosmoprimo().- type cosmo:
BasePrimordialCosmology, default=None
- param data_dir:
Data directory. Defaults to path saved in desilike’s configuration, as provided by
Installerif likelihood has been installed.- type data_dir:
str, Path, default=None
- param basename:
Likelihood base name, e.g. ‘base_plikHM_TT’, ‘base_plikHM_TTTEEE’, ‘base_plikHM_TTTEEE_lowl_lowE_lensing’.
- type basename:
str, default=’base_plikHM_TTTEEE_lowl_lowE_lensing’
- param source:
Source, either:
‘covmat’: use ‘.margestats’ for mean and ‘.covmat’ file as covariance.
‘chains’: compute mean and covariance from chains
Both options are very close (within precision in provided file). Defaults to ‘chains’ if
weightsis notNone, else ‘covmat’.- type source:
str, default=None
- param weights:
Callable that takes a
Chainas input and returns weights (float), e.g.weights = lambda chain: 1. / np.exp(chain['logposterior'] + 0.5 * chain['chi2_prior'] + 0.5 * chain['chi2_CMB']). Ifweightsis ‘cmb_only’, the lambda function above is used to “importance unweight” the non-CMB datasets (useful e.g. to get an approximation of the CMB-only posterior for \(w_{0}\) and \(w_{a}\) extensions). Only available ifsourceis ‘chains’.- type weights:
str, callable, default=None
- class desilike.likelihoods.cmb.planck2018_gaussian.FullGridPlanck2018GaussianLikelihood(*args, **kwargs)[source]¶
Bases:
BasePlanck2018GaussianLikelihoodGaussian approximation of the full grid of likelihoods of Planck’s 2018 data release.
Reference¶
https://arxiv.org/abs/1807.06209
https://wiki.cosmos.esa.int/planck-legacy-archive/index.php/CMB_spectrum_%26_Likelihood_Code
- param cosmo:
Cosmology calculator. Defaults to
Cosmoprimo().- type cosmo:
BasePrimordialCosmology, default=None
- param data_dir:
Data directory. Defaults to path saved in desilike’s configuration, as provided by
Installerif likelihood has been installed.- type data_dir:
str, Path, default=None
- param basename:
Likelihood base name, e.g. ‘base_plikHM_TT’, ‘base_plikHM_TTTEEE’, ‘base_plikHM_TTTEEE_lowl_lowE_lensing’, ‘base_mnu_plikHM_TTTEEE_lowl_lowE_lensing’.
- type basename:
str, default=’base_plikHM_TTTEEE_lowl_lowE_lensing’
- param source:
Source, either:
‘covmat’: use ‘.margestats’ for mean and ‘.covmat’ file as covariance.
‘chains’: compute mean and covariance from chains
Both options are very close (within precision in provided file).
- type source:
str, default=’covmat’
- desilike.likelihoods.cmb.planck2018_gaussian.planck2018_base_fn(basename, data_dir=None)[source]¶
Return paths to chains and corresponding summary statistics given input base chain name, and data directory
data_dir. Ifdata_dirisNone, defaults to path saved in desilike’s configuration, as provided byInstallerifBasePlanck2018GaussianLikelihoodorFullGridPlanck2018GaussianLikelihoodhave been installed.
- desilike.likelihoods.cmb.planck2018_gaussian.read_planck2018_chain(basename='base_plikHM_TTTEEE_lowl_lowE_lensing', data_dir=None, weights=None, params=None)[source]¶
Read Planck chains, operating basic conversion in parameters.
- Parameters:
basename (str, default='base_plikHM_TTTEEE_lowl_lowE_lensing') –
Likelihood base name, e.g. ‘base_plikHM_TT’, ‘base_plikHM_TTTEEE’, ‘base_plikHM_TTTEEE_lowl_lowE_lensing’.
- data_dirstr, Path, default=None
Data directory. Defaults to path saved in desilike’s configuration, as provided by
InstallerifBasePlanck2018GaussianLikelihoodorFullGridPlanck2018GaussianLikelihoodhave been installed.- weightsstr, callable, default=None
Callable that takes a
Chainas input and returns weights (float), e.g.weights = lambda chain: 1. / np.exp(chain['logposterior'] + 0.5 * chain['chi2_prior'] + 0.5 * chain['chi2_CMB']). Ifweightsis ‘cmb_only’, the lambda function above is used to “importance unweight” the non-CMB datasets (useful e.g. to get an approximation of the CMB-only posterior for \(w_{0}\) and \(w_{a}\) extensions).
params (list, ParameterCollection) – List of parameters to convert the chain to; e.g. [‘h’, ‘Omega_m’, ‘A_s’].
- Returns:
chain
- Return type:
Chain
hubble¶
Hubble parameter likelihoods from Riess et al. (2020).
- class desilike.likelihoods.hubble.riess2020.Riess2020H0Likelihood(*args, **kwargs)[source]¶
Bases:
H0LikelihoodLocal \(H_0\) measurement from Riess et al. (2020).
Reference¶
- class desilike.likelihoods.hubble.riess2020.Riess2020MbLikelihood(*args, **kwargs)[source]¶
Bases:
MbLikelihoodMagnitude measurement from Riess et al. (2020).
Reference¶
https://arxiv.org/abs/2012.08534
https://github.com/CobayaSampler/cobaya/blob/master/cobaya/likelihoods/H0/riess2020Mb.yaml
supernovae¶
- class desilike.likelihoods.supernovae.pantheon.PantheonSNLikelihood(*args, **kwargs)[source]¶
Bases:
BaseSNLikelihoodLikelihood for Pantheon type Ia supernovae sample. TODO: organize as SNObservable / ObservablesGaussianLikelihood?
Reference¶
https://arxiv.org/abs/1710.00845
- param data_dir:
Data directory. Defaults to path saved in desilike’s configuration, as provided by
Installerif likelihood has been installed.- type data_dir:
str, Path, default=None
- plot(fig=None)[source]¶
Plot Hubble diagram: Hubble residuals as a function of distance.
- Parameters:
fig (matplotlib.figure.Figure, default=None) – Optionally, a figure with at least 2 axes.
fn (str, Path, default=None) – Optionally, path where to save figure. If not provided, figure is not saved.
kw_save (dict, default=None) – Optionally, arguments for
matplotlib.figure.Figure.savefig().show (bool, default=False) – If
True, show figure.