plot_utils module
Utility functions for plotting and preparing data for plots.
- plot_utils.cov_pool(arr, axis=None, threshold=0.6, **kwargs)
Pooling function for downsampling correlation matrices for plotting, which can be passed as the
funcargument to skimage.measure.block_reduce.The aim is to strike a balance between max pooling, which preserves important features (particularly the diagonal) but also artificially amplifies noise, and mean pooling which averages out noise but also washes out features. This function works by max pooling if the max is above some threshold value, and mean pooling otherwise.
- Parameters
arr (ND numpy array) – Array to downsample.
axis (int, optional) – Axis to downsample, which is passed to np.max and np.mean. Default is None, which will cause those functions to use the flattened input.
threshold (float, optional) – Threshold for the max value in a pool, above which to use max pooling and below which to use mean pooling (default 0.6).
**kwargs – Additional keyword arguments to be passed to both np.max and np.mean.
- plot_utils.get_3d_post(log_like_path, save_path)
Form 3D posterior grid from a log-likelihood file and save to disk, ready for plotting.
- Parameters
log_like_path (str) – Path to log-likelihood text file.
save_path (str) – Path to save 3D posterior grid as .npz file.
- plot_utils.get_cov_diags(cov_cng_fullsky_path, theory_cl_path, per_mask_data, lmin, lmax, lmax_mix, diags, save_path)
Extract diagonals of the covariance matrix for plotting with plotting.cov_diags.
Note that this is all for a single block, which in the paper is the auto-power in the lowest redshift bin.
- Parameters
cov_cng_fullsky_path (str) – Path to the full-sky connected non-Gaussian covariance matrix.
theory_cl_path (str) – Path to theory power spectrum.
per_mask_data (list) – List of dictionaries, one dictionary per mask, each containing fields:
mask_labelused for the column headers,fskysky fraction,mixmat_pathpath to mixing matrix or None for full sky,sim_cl_pathpath to simulated Cls as output by simulation.combine_sim_cl,cov_g_pathpath to Gaussian covariance,cov_ss_pathpath to super-sample covariance.lmin (int) – Minimum l.
lmax (int) – Maximum l post-mixing.
lmax_mix (int) – Maximum l pre-mixing.
diags (list) – List of diagonals to extract, e.g. [0, 2, 10, 100].
save_path (str) – Path to save output data to.
- plot_utils.get_cov_diags_gaussian(per_mask_data, diags, save_path)
Extract diagonals of the Gaussian covariance matrix for plotting with plotting.cov_gaussian.
Note that this is all for a single block, which in the paper is the auto-power in the lowest redshift bin.
- Parameters
per_mask_data (list) – List of dictionaries, one dictionary per mask, each containing fields:
mask_labelused for the column headers,sim_cl_pathpath to simulated Cls as output by simulation.gaussian_sim,cov_g_pathpath to Gaussian covariance.diags (list) – List of diagonals to extract, e.g. [0, 2, 10, 100].
save_path (str) – Path to save output data to.
- plot_utils.get_cov_diags_withnoise(cov_cng_fullsky_path, per_mask_data, lmin, lmax, lmax_mix, diags, save_path)
Extract diagonals of the covariance matrix with noise (no simulations), for plotting with plotting.cov_withnoise.
Note that this is all for a single block, which in the paper is the auto-power in the lowest redshift bin.
- Parameters
cov_cng_fullsky_path (str) – Path to the full-sky connected non-Gaussian covariance matrix.
per_mask_data (list) – List of dictionaries, one dictionary per mask, each containing fields:
mask_labelused for the column headers,fskysky fraction,mixmat_pathpath to mixing matrix or None for full sky,cov_g_pathpath to Gaussian covariance,cov_ss_pathpath to super-sample covariance.lmin (int) – Minimum l.
lmax (int) – Maximum l post-mixing.
lmax_mix (int) – Maximum l pre-mixing.
diags (list) – List of diagonals to extract, e.g. [0, 2, 10, 100].
save_path (str) – Path to save output data to.
- plot_utils.get_cov_mats(cov_cng_fullsky_path, theory_cl_path, per_mask_data, lmin, lmax, lmax_mix, save_path)
Form correlation matrices for plotting with plotting.cov_mats.
Note that this is all for a single block, which in the paper is the auto-power in the lowest redshift bin.
- Parameters
cov_cng_fullsky_path (str) – Path to the full-sky connected non-Gaussian covariance matrix.
theory_cl_path (str) – Path to theory power spectrum.
per_mask_data (list) – List of dictionaries, one dictionary per mask, each containing fields:
mask_labelused for the column headers,fskysky fraction,mixmat_pathpath to mixing matrix or None for full sky,sim_cl_pathpath to simulated Cls as output by simulation.combine_sim_cl,cov_g_pathpath to Gaussian covariance,cov_ss_pathpath to super-sample covariance.lmin (int) – Minimum l.
lmax (int) – Maximum l post-mixing.
lmax_mix (int) – Maximum l pre-mixing.
save_path (str) – Path to save output data to.