like_bp_gauss module

Likelihood module to evaluate the joint likelihood of a set of tomographic 3x2pt power spectra, binned into bandpowers, on the full sky using a multivariate Gaussian likelihood.

The main functions are setup, which should be called once per analysis, and execute, which is called for every new point in parameter space.

class like_bp_gauss.FieldType(value)

Bases: enum.Enum

Simple class to represent the three types of fields: position, shear E and shear B.

POS = 1
SHE_B = 3
SHE_E = 2
like_bp_gauss.execute(theory_ell, theory_cl, config)

Perform some consistency checks then evaluate the likelihood for a given set of theory Cls.

Parameters
  • theory_ell (1D numpy array) – Ell range for all of the theory spectra (must be consistent between spectra).

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

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

Returns

Log-likelihood value.

Return type

float

like_bp_gauss.idx_to_type(idx)

Returns the field type corresponding to a row or column index in the matrix of power spectra. Shear B-mode is not taken into account.

Parameters

idx (int) – Row or column index.

Returns

The corresponding field type.

Return type

FieldType

like_bp_gauss.idx_to_zbin(idx)

Returns the redshift bin corresponding to a row or column index in the matrix of power spectra. Redshift bins are numbered from 1, and shear B-mode is not taken into account.

Parameters

idx (int) – Row or column index.

Returns

The corresponding redshift bin number.

Return type

int

like_bp_gauss.joint_log_likelihood(obs_bp, theory_cl, noise_cl, pbl, inv_cov)

Returns the joint log-likelihood of all bandpowers for all spectra.

Parameters
  • obs_bp (1D numpy array) – Observed bandpowers, flattened into a 1D array ordered by spectrum then bandpower.

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

  • noise_cl (2D numpy array) – Noise power spectra in the same shape as theory_cl.

  • pbl (2D numpy array) – Bandpower binning matrix, with shape (n_bandpowers, n_ell).

  • inv_cov (2D numpy array) – Inverted covariance matrix, with shape (n_spectra * n_bandpowers, n_spectra * n_bandpowers).

Returns

Joint log-likelihood value.

Return type

float

like_bp_gauss.load_spectra(n_zbin, pos_pos_dir, she_she_dir, pos_she_dir, lmax=None, lmin=0)

Given the number of redshift bins and relevant directories, load (band)power spectra (position, shear, cross) in the correct order (diagonal / healpy new=True ordering). If lmin is supplied, the output will be padded to begin at l=0.

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

  • pos_pos_dir (str) – Path to directory containing position-position power spectra.

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

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

  • lmax (int, optional) – Maximum l to load - if not supplied, will load all lines, which requires the individual lmax of each file to be consistent.

  • lmin (int, optional) – Minimum l supplied. Output will be padded with zeros below this point.

Returns

All Cls, with different spectra along the first axis and increasing l along the second.

Return type

2D numpy array

like_bp_gauss.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

like_bp_gauss.setup(n_zbin, obs_pos_pos_dir, obs_she_she_dir, obs_pos_she_dir, pos_nl_path, she_nl_path, noise_ell_path, pbl_path, inv_cov_path, lmax, lmin)

Load and precompute everything that is fixed throughout parameter space. This should be called once per analysis, prior to any calls to execute.

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

  • obs_pos_pos_dir (str) – Path to the directory containing the observed position-position band power spectra.

  • obs_she_she_dir (str) – Path to the directory containing the observed shear-shear band power spectra.

  • obs_pos_she_dir (str) – Path to the directory containing the observed position-shear band power spectra.

  • pos_nl_path (str) – Path to the unbinned position noise power spectrum, in text file.

  • she_nl_path (str) – Path to the unbinned shear noise power spectrum, in text file.

  • noise_ell_path (str) – Path to the text file containing the ells for the noise power spectra.

  • pbl_path (str) – Path to binning matrix, in text file with shape (n_bandpowers, lmax - lmin + 1).

  • inv_cov_path (str) – Path to precomputed binned inverse covariance, in numpy .npz file with array name inv_cov, and shape (n_spectra * n_bandpowers, n_spectra * n_bandpowers).

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

  • lmin (int) – Minimum l.

Returns

Config dictionary to pass to execute.

Return type

dict