cng_approx module
Contains functions relating to the connected non-Gaussian covariance approximation.
- cng_approx.apply_bin_weights(input_dir, output_dir, filemask, weights_path)
Apply binning weights to each block of the connected non-Gaussian covariance matrix.
- Parameters
input_dir (str) – Path to input blocks, evaluated only at one element per bandpower pair.
output_dir (str) – Path to save output blocks to.
filemask (str) – Glob filemask for input files within input directory.
weights_path (str) – Path to binning weights as obtained using get_bin_weights.
- cng_approx.apply_mix_weights(input_dir, output_dir, filemask, weights_path)
Apply mixing weights to each block of the connected non-Gaussian covariance matrix.
- Parameters
input_dir (str) – Path to input blocks, as output by apply_bin_weights.
output_dir (str) – Path to save output blocks to.
filemask (str) – Glob filemask for input files within input directory.
weights_path (str) – Path to mixing weights as obtained using get_mix_weights.
- cng_approx.get_avg_l(lmin, lmax, n_bandpower)
Determine the weighted average l per bandpower.
- Parameters
lmin (int) – Minimum l.
lmax (int) – Maximum l.
n_bandpower (int) – Number of bandpowers.
- cng_approx.get_bin_weights(full_cov_path, binmat_path, lmax, lmin, ells, save_path)
Obtain the binning weights used in the connected non-Gaussian approximation.
- Parameters
full_cov_path (str) – Path to full connected non-Gaussian covariance block.
binmat_path (str) – Path to binning matrix.
lmax (int) – Maximum l.
lmin (int) – Minimum l.
ells (list) – List of ells to evaluate the weights for, as given by get_avg_l.
save_path (str) – Path to save output .npz file to.
- cng_approx.get_mix_weights(full_cov_path, binmat_path, bin_weights_path, mixmat_path, lmin, save_path, fsky=None)
Obtain the mixing weights used in the connected non-Gaussian approximation.
- Parameters
full_cov_path (str) – Path to full connected non-Gaussian covariance block.
binmat_path (str) – Path to binning matrix.
bin_weights_path (str) – Path to binning weights obtained with get_bin_weights.
mixmat_path (str) – Path to mixing matrix.
lmin (int) – Minimum l.
save_path (str) – Path to save output .npz file to.
fsky (float, optional) – Sky fraction - if supplied, will multiply input covariance block by 1/fsky. This is only necessary if the full_cov_path is the path to the full-sky connected non-Gaussian covariance and hasn’t already received the 1/fsky factor.
- cng_approx.test_bin_weights(ss_block_filemask, binmat_path, lmax, lmin, ells, n_spec, save_path)
Test the approach of binning weights by applying them to super-sample covariance blocks and measuring the ratio of approximate to exact (full treatment) covariance.
- Parameters
ss_block_filemask (str) – Path to input (unmixed, unbinned) super-sample covariance blocks, with {spec1_idx} and {spec2_idx} placeholders.
binmat_path (str) – Path to binning matrix.
lmax (int) – Maximum l.
lmin (int) – Minimum l.
ells (list) – List of ells to evaluate the weights for, as given by get_avg_l.
n_spec (int) – Number of power spectra.
save_path (str) – Path to save covariance ratios to, for later plotting using plotting.cng_approx.
- cng_approx.test_mix_weights(unmixed_unbinned_ss_dir, mixed_binned_ss_dir, input_filemask, binmat_path, n_spec, save_path)
Test the approach of mixing weights by applying them to super-sample covariance blocks and measuring the ratio of approximate to exact (full treatment) covariance.
- Parameters
unmixed_unbinned_ss_dir (str) – Path to directory containing unmixed unbinned super-sample covariance blocks.
mixed_binned_ss_dir (str) – Path to directory containing mixed binned super-sample covariance blocks.
input_filemask (str) – Filename of blocks within input directories, with {spec1_idx} and {spec2_idx} placeholders.
binmat_path (str) – Path to binning matrix.
n_spec (int) – Number of power spectra.
save_path (str) – Path to save covariance ratios to, for later plotting using plotting.cng_approx.