likelihood module

Gaussian likelihood module for shear bandpowers.

likelihood.execute(theory_cl, theory_lmin, config)

Calculate the joint log likelihood at a particular point in parameter space.

Parameters
  • theory_cl (2D numpy array) – Theory power spectra, in diagonal ordering, with shape (n_spectra, n_ell).

  • theory_lmin (int) – l corresponding to the first Cl in each power spectrum (must be consistent between spectra).

  • config (dict) – Config dictionary returned by setup.

Returns

Log-likelihood value.

Return type

float

likelihood.load_cls(n_zbin, she_she_dir, lmax=None, lmin=0)

Load shear-shear power spectra in the correct order (diagonal / healpy new=True ordering).

Parameters
  • n_zbin (int) – Number of redshift bins.

  • she_she_dir (str) – Path to directory containing shear-shear power spectra.

  • lmax (int, optional) – If supplied, maximum l to be read in.

  • lmin (int, optional) – If > 0, output will be padded to start at l = 0.

Returns

All Cls, with different spectra along the first axis and increasing l along the second, with shape (n_spectra, lmax + 1), where n_spectra = n_zbin * (n_zbin + 1) / 2.

Return type

2D numpy array

likelihood.mvg_logpdf_fixedcov(x, mean, inv_cov)

Log-pdf of the multivariate Gaussian distribution where the determinant and inverse of the covariance matrix are precomputed and fixed.

Note that this neglects the additive constant: -0.5 * (len(x) * log(2 * pi) + log_det_cov), because it is irrelevant when comparing pdf values with a fixed covariance, but it means that this is not the normalised pdf.

Parameters
  • x (1D numpy array) – Vector value at which to evaluate the pdf.

  • mean (1D numpy array) – Mean vector of the multivariate Gaussian distribution.

  • inv_cov (2D numpy array) – Inverted covariance matrix.

Returns

Log-pdf value.

Return type

float

likelihood.run_likelihood(grid_dir, varied_params, save_path, obs_bp_path, n_zbin, cov_path, mixmat_path, binmat_path, she_nl_path, noise_lmin, lmax_in, lmin_in, lmax_like, lmin_like)

Evaluate the likelihood on a precomputed theory grid as produced using CosmoSIS, and save the result as a text file.

Parameters
  • grid_dir (str) – Path to CosmoSIS grid.

  • varied_params (list) – List of varied parameter names as they appear in the cosmological_parameters/values.txt file.

  • save_path (str) – Path to save output text file to.

  • obs_bp_path (str) – Path to observed bandpowers in .npz format as produced by simulation.get_obs.

  • n_zbin (int) – Number of redshift bins. It will be assumed that there is one shear field per redshift bin.

  • cov_path (str) – Path to covariance matrix, as produced by post_processing.get_composite_covs.

  • mixmat_path (str) – Path to mixing matrix, as produced by post_processing.get_mixmat.

  • binmat_path (str) – Path to bandpower binning matrix.

  • she_nl_path (str) – Path to shear noise power spectrum as a text file.

  • noise_lmin (int) – Minimum l in the input shear noise power spectrun.

  • lmax_in (int) – Maximum l pre-mixing.

  • lmin_in (int) – Minimum l pre-mixing.

  • lmax_like (int) – Maximum l to use in the likelihood.

  • lmin_like (int) – Minimum l to use in the likelihood.

likelihood.setup(obs_bp_path, n_zbin, cov_path, mixmat_path, binmat_path, she_nl_path, noise_lmin, lmax_in, lmin_in, lmax_like, lmin_like)

Load/precompute anything fixed across parameter space.

Parameters
  • obs_bp_path (str) – Path to observed bandpowers in .npz numpy array of shape (n_spectra, n_bandpowers).

  • n_zbin (int) – Number of redshift bins; it is assumed 1 shear field per z bin.

  • cov_path (str) – Path to precomputed covariance in .npz numpy array of shape (n_spectra * n_bandpowers, n_spectra * n_bandpowers).

  • mixmat_path (str) – Path to mixing matrix.

  • binmat_path (str) – Path to bandpower binning matrix.

  • she_nl_path (str) – Path to noise power spectrum for shear auto-spectra.

  • noise_lmin (int) – Input lmin for the noise power spectra.

  • lmax_in (int) – Maximum l pre-mixing.

  • lmin_in (int) – Minimum l pre-mixing.

  • lmax_like (int) – Maximum l used for the likelihood.

  • lmin_like (int) – Minimum l used for the likelihood.

Returns

Config dictionary to pass to execute.

Return type

dict