like_bp_gauss_mix module
Likelihood module to evaluate the joint likelihood of a set of tomographic 3x2pt power spectra, binned into bandpowers, on the cut 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.
- like_bp_gauss_mix.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) – Minimum l used in theory_cl.
config (dict) – Config dictionary returned by setup.
- Returns
Log-likelihood value.
- Return type
float
- like_bp_gauss_mix.is_even(x)
True if x is even, false otherwise.
- Parameters
x (float) – Number to test.
- Returns
True if even.
- Return type
bool
- like_bp_gauss_mix.is_odd(x)
True if x is odd, false otherwise.
- Parameters
x (float) – Number to test.
- Returns
True if odd.
- Return type
bool
- like_bp_gauss_mix.load_cls(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 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_mix.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_mix.setup(obs_bp_path, binmixmat_path, mix_lmin, cov_path, pos_nl_path, she_nl_path, noise_lmin, input_lmax, n_zbin)
Load and precompute everything that is fixed throughout parameter space. This should be called once per analysis, prior to any calls to execute.
- Parameters
obs_bp_path (str) – Path to the observed bandpowers, in a numpy .npz file with array name obs_bp and shape (n_spectra, n_bandpowers), with spectra in diagonal-major order.
binmixmat_path (str) – Path to combined mixing and binning matrices, in numpy .npz file with array names (binmix_tt_to_tt, binmix_te_to_te, binmix_ee_to_ee, binmix_bb_to_ee), each with shape (n_bandpower, input_lmax - mix_lmin + 1).
mix_lmin (int) – Minimum l for the theory power in the mixing matrices.
cov_path (str) – Path to precomputed covariance, in numpy .npz file with array name cov, with shape (n_data, n_data) where n_data = n_spectra * n_bandpowers.
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_lmin (int) – Minimum l in noise power spectra.
input_lmax (int) – Maximum l to include in mixing. Theory and noise power will be truncated above this.
n_zbin (int) – Number of redshift bins. It will be assumed that there is one position field and one shear field per redshift bin.
- Returns
Config dictionary to pass to execute.
- Return type
dict