like_cl_wishart module
Likelihood module to evaluate the joint likelihood of a set of tomographic 3x2pt power spectra on the full sky using the exact Wishart 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_cl_wishart.cl_matrix(cls_, n_fields)
Convert a sequence of power spectra into a sequence of Cl matrices.
- Parameters
cls (2D numpy array) – Cls to reshape, with input shape (n_spectra, n_ell).
n_fields (int) – Number of fields, such that n_spectra = n_fields * (n_fields + 1) / 2.
- Returns
Cls with shape (n_ell, n_fields, n_fields).
- Return type
3D numpy array
- like_cl_wishart.cl_vector(cl_matrices)
The inverse of cl_matrix: takes a sequence of Cl matrices and returns a vector of power spectra.
- Parameters
cl_matrices (3D numpy array) – Cls to reshape into a vector, with input shape (n_ell, n_fields, n_fields).
- Returns
Cls with shape (n_spectra, n_ell), with n_spectra = n_fields * (n_fields + 1) / 2.
- Return type
2D numpy array
- like_cl_wishart.execute(theory_ells, theory_cls, config)
Perform some consistency checks then evaluate the likelihood for particular 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_cl_wishart.is_even(x)
True if x is even, false otherwise.
- Parameters
x (float) – Number to test.
- Returns
True if even.
- Return type
bool
- like_cl_wishart.is_odd(x)
True if x is odd, false otherwise.
- Parameters
x (float) – Number to test.
- Returns
True if odd.
- Return type
bool
- like_cl_wishart.joint_log_likelihood(ells, theory_cl_matrices, noise_cl_matrices, obs_cl_matrices, lmax)
Return the joint log-likelihood of a whole observed 3x2pt data vector.
- Parameters
ells (1D numpy array) – All l values.
theory_cl_matrices (3D numpy array) – Theory Cl matrices, shape (n_ell, n_spectra, n_spectra).
noise_cl_matrices (3D numpy array) – Noise Cl matrices, shape (n_ell, n_spectra, n_spectra).
obs_cl_matrices (3D numpy array) – Observed Cl matrices, shape (n_ell, n_spectra, n_spectra).
lmax (int) – Maximum l to include in the likelihood.
- Returns
Log-likelihood value.
- Return type
float
- like_cl_wishart.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_cl_wishart.log_likelihood_single_l(l, theory_cl_matrix, noise_cl_matrix, obs_cl_matrix)
Returns the log-likelihood of a set of Cls for a single l according to the Wishart distribution.
- Parameters
l (int) – Single l value.
theory_cl_matrix (2D numpy array) – Matrix of theory Cls for this l.
noise_cl_matrix (2D numpy array) – Matrix of noise Cls for this l.
obs_cl_matrix (2D numpy array) – Matrix of observed Cls for this l.
- Returns
Log-likelihood value.
- Return type
float
- like_cl_wishart.setup(n_zbin, obs_pos_pos_dir, obs_she_she_dir, obs_pos_she_dir, pos_nl_path, she_nl_path, noise_ell_path, lmax, leff_path=None)
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 power spectra.
obs_she_she_dir (str) – Path to the directory containing the observed shear-shear power spectra.
obs_pos_she_dir (str) – Path to the directory containing the observed position-shear power spectra.
pos_nl_path (str) – Path to the position noise power spectrum.
she_nl_path (str) – Path to the shear noise power spectrum.
noise_ell_path (str) – Path to the file containing the ells for the noise power spectra.
lmax (int) – Maximum l to use in the likelihood.
leff_path (str, optional) – Path to ell-ell_effective mapping, to replace each l with its corresponding l_eff when calculating the covariance.
- Returns
Config dictionary to pass to execute.
- Return type
dict