covariance module
Functions to calculate 3x2pt Gaussian covariance.
- class covariance.Field(field_type, zbin)
Bases:
tuple- property field_type
Alias for field number 0
- property zbin
Alias for field number 1
- class covariance.FieldType(value)
Bases:
enum.EnumThe three types of fields: position, shear E and shear B.
- POSITION = 1
- SHEAR_B = 3
- SHEAR_E = 2
- class covariance.PowerSpectrum(field_1, field_2)
Bases:
tuple- property field_1
Alias for field number 0
- property field_2
Alias for field number 1
- covariance.bin_combine_cov(n_zbin, lmin_in, lmin_out, lmax, n_bp_min, n_bp_max, input_filemask, save_filemask)
Loop over numbers of bandpowers, and for each one, bin all blocks of unbinned covariance matrix and combine into a single matrix, saved to disk.
- Parameters
n_zbin (int) – Number of redshift bins, assuming 1 position field and 1 shear field per redshift bin.
lmin_in (int) – Minimum l in the unbinned covariance.
lmin_out (int) – Minimum l to include in the binned covariance.
lmax (int) – Maximum l in the unbinned and binned covariance.
n_bp_min (int) – Minimum number of bandpowers to loop over (inclusive).
n_bp_max (int) – Maximum number of bandpowers to loop over (inclusive).
input_filemask (str) – Path to unbinned covariance blocks output by
get_3x2pt_cov, with{spec1_idx}and{spec2_idx}placeholders.save_filemask (str) – Path to save each binned covariance matrix, with
{n_bp}placeholder.
- covariance.get_3x2pt_cov(n_zbin, pos_pos_filemask, pos_she_filemask, she_she_filemask, lmax_in, lmin_in, lmax_out, lmin_out, pos_nl_path, she_nl_path, noise_lmin, mask_path, nside, save_filemask)
Calculate 3x2pt Gaussian covariance using NaMaster, saving each block separately to disk.
- Parameters
n_zbin (int) – Number of redshift bins, assuming 1 position field and 1 shear field per redshift bin.
pos_pos_filemask (str) – Path to text file containing a position-position power spectrum with
{hi_zbin}and{lo_zbin}placeholders.pos_she_filemask (str) – Path to text file containing a position-shear power spectrum with
{pos_zbin}and{she_zbin}placeholders.she_she_filemask (str) – Path to text file containing a shear-shear power spectrum with
{hi_zbin}and{lo_zbin}placeholders.lmax_in (int) – Maximum l to including in mixing.
lmin_in (int) – Minimum l in input power spectra.
lmax_out (int) – Maximum l to include in covariance.
lmin_out (int) – Minimum l to include in covariance.
pos_nl_path (str) – Path to position noise power spectrum.
she_nl_path (str) – Path to shear noise power spectrum.
noise_lmin (int) – Minimum l in noise power spectra.
mask_path (str) – Path to mask FITS file. If None, full sky is assumed, in which case the covariance will be diagonal.
nside (int) – HEALPix resolution nside parameter.
save_filemask (str) – Path to save each covariance block to disk, with
{spec1_idx}and{spec2_idx}placeholders.
- covariance.load_cls(signal_paths, noise_paths, lmax_in, lmax_out, signal_lmin, noise_lmin)
Load a list of Cls with appropriate noise, given lists of path to signal and noise Cls. If any entry in either list is None, then zeros are used. Signal and noise are padded with zeros below
signal_lminandnoise_lminand abovelmax_in(if less thanlmax_out).- Parameters
signal_paths (list) – List of paths to signal Cls. If any entry is None, it is taken to be zero.
noise_paths (list) – List of paths to noise Cls. If any entry is None, it is taken to be zero.
lmax_in (int) – Maximum l to load. If this is less than
lmax_outthen padded with zeros above this l.lmax_out (int) – Maximum l to return.
signal_lmin (int) – First l of signal power spectra. Signal Cls will be padded with zeros below this.
noise_lmin (int) – First l of noise power spectra. Noise Cls will be padded with zeros below this.
- Returns
List of numpy arrays, each of which is a signal + noise power spectrum in the supplied order.
- Return type
list
- covariance.spectrum_from_fields(field_a, field_b)
Returns a PowerSpectrum object corresponding to the supplied fields, in a consistent order, which is lower redshift bin first, and if the bins are equal then position first.
(Note that this is not the same convention as used when loading from CosmoSIS output.)
- Parameters
- Returns
Power spectrum corresponding to the two fields.
- Return type
- covariance.spin_from_field(field)
Returns the spin of a field.
- Parameters
field (Field) – Field to get the spin of.
- Returns
The spin of the field.
- Return type
int
- covariance.spins_from_spectrum(spec)
Returns the two spins corresponding to the two fields of the supplied power spectrum.
- Parameters
spec (PowerSpectrum) – Power spectrum to get the spins of.
- Returns
The spins of the two fields of the power spectrum.
- Return type
(int, int)
- covariance.workspace_from_spins(spin_a, spin_b, workspace_spin00, workspace_spin02, workspace_spin22)
Returns the appropriate NmtWorkspace object for the two supplied spins.
- Parameters
spin_a (int) – Spin of one field.
spin_2 (int) – Spin of the other field.
workspace_spin00 (NmtWorkspace) – Workspace for two spin-0 fields.
workspace_spin02 (NmtWorkspace) – Workspace for one spin-0 and one spin-2 field (in either order).
workspace_spin22 (NmtWorkspace) – Workspace for two spin-2 fields.
- Returns
The workspace object corresponding to the two supplied spins.
- Return type
NmtWorkspace