so_spectra
- a module for power spectra estimation and debiasing#
Routines for power spectra estimation and debiasing.
- pspy.so_spectra.bin_spectra(l, cl, binning_file, lmax, type, spectra=None, mbb_inv=None, binned_mcm=True)#
Bin the power spectra according to a binning file and optionnaly deconvolve the (binned) mode coupling matrix
- Parameters:
l (1d array) – the multipoles
cl (1d array or dict of 1d array) – the power spectra to bin, can be a 1d array (spin0) or a dictionnary (spin0 and spin2)
binning_file (data file) – a binning file with format bin low, bin high, bin mean
lmax (int) – the maximum multipole to consider
type (string) – the type of binning, either bin Cl or bin Dl
spectra (list of string) – needed for spin0 and spin2 cross correlation, the arrangement of the spectra
mbb_inv (2d array) – optionnaly apply the inverse of the mode coupling matrix to debiais the spectra
binned_mcm (boolean) – if mbb_inv is not None, specify if it’s binned or not
- Returns:
The function return the binned multipole array bin_c and a 1d power spectrum
array (or dictionnary of 1d power spectra if spectra is not None).
- pspy.so_spectra.deconvolve_mode_coupling_matrix(l, ps, inv_mode_coupling_matrix, spectra=None)#
deconvolve the mode coupling matrix :param l: the multipoles or the location of the center of the bins :type l: 1d array :param cl: the power spectra, can be a 1d array (spin0) or a dictionnary (spin0 and spin2) :type cl: 1d array or dict of 1d array :param inv_mode_coupling_matrix: the inverse of the mode coupling matrix can be binned or not :type inv_mode_coupling_matrix: 2d array (or dict of 2d arrays) :param spectra: needed for spin0 and spin2 cross correlation, the arrangement of the spectra :type spectra: list of string
- pspy.so_spectra.get_spectra(alm1, alm2=None, spectra=None)#
Get the power spectrum of alm1 and alm2, we use healpy.alm2cl for doing this. for the spin0 and spin2 case it is a bit ugly as we have to deal with healpix convention. Our convention for spectra is: [‘TT’,’TE’,’TB’,’ET’,’BT’,’EE’,’EB’,’BE’,’BB’] while healpix convention is to take alm1,alm2 and return [‘TT’,’EE’,’BB’,’TE’,’EB’,’TB’]
- Parameters:
alm1 (1d array) – the spherical harmonic transform of map1
alm2 (1d array) – the spherical harmonic transform of map2
spectra (list of strings) – needed for spin0 and spin2 cross correlation, the arrangement of the spectra
- Returns:
The function returns the multipole array l and cl a 1d power spectrum array or
cl_dict (for spin0 and spin2) a dictionnary of cl with entry spectra
- pspy.so_spectra.get_spectra_pixell(alm1, alm2=None, spectra=None)#
Get the power spectrum of alm1 and alm2, we use pixell.alm2cl (this is faster) :param alm1: the spherical harmonic transform of map1 :type alm1: 1d array :param alm2: the spherical harmonic transform of map2 :type alm2: 1d array :param spectra: :type spectra: list of strings :param needed for spin0 and spin2 cross correlation: :param the arrangement of the spectra:
- Returns:
The function returns the multipole array l and cl a 1d power spectrum array or
cl_dict (for spin0 and spin2) a dictionnary of cl with entry spectra
- pspy.so_spectra.read_ps(file_name, spectra=None)#
Read the power spectra.
- Parameters:
file_name (str) – the name of the file to read the spectra
spectra (list of strings) – needed for spin0 and spin2 cross correlation, the arrangement of the spectra
- Returns:
The function return the multipole l (or binned multipoles) and a 1d power spectrum
array or a dictionnary of power spectra (if spectra is not None).
- pspy.so_spectra.read_ps_hdf5(file, spec_name, spectra=None)#
Read the power spectra in a hdf5 file.
- Parameters:
file (hdf5) – the name of the hdf5 file
spec_name (string) – the name of the group in the hdf5 file
spectra (list of strings) – needed for spin0 and spin2 cross correlation, the arrangement of the spectra
- Returns:
The function returns the multipole l (or binned multipoles) and a 1d power spectrum
array (or a dictionnary of power spectra if spectra is not None).
- pspy.so_spectra.vec2spec_dict(n_bins, vec, spectra)#
Take a vector of power spectra and return a power spectra dictionnary. vec should be of the form [spectra[0], spectra[1], … ]. For example [cl_TT,cl_TE,cl_ET, …., cl_BB]
- Parameters:
n_bins (int) – the number of bins per spectrum
vec (1d array) – an array containing a vector of spectra
spectra (list of strings) – the arrangement of the spectra for example: [‘TT’,’TE’,’TB’,’ET’,’BT’,’EE’,’EB’,’BE’,’BB’]
- pspy.so_spectra.write_ps(file_name, l, ps, type, spectra=None)#
Write down the power spectra to disk.
- Parameters:
file_name (str) – the name of the file to write the spectra
l (1d array) – the multipoles (or binned multipoles)
ps (1d array or dict of 1d array) – the power spectrum, if spectra is not None, expect a dictionary with entry spectra
type (string) – ‘Cl’ or ‘Dl’
spectra (list of strings) – needed for spin0 and spin2 cross correlation, the arrangement of the spectra
- pspy.so_spectra.write_ps_hdf5(file, spec_name, l, ps, spectra=None)#
Write down the power spectra in a hdf5 file.
- Parameters:
file (hdf5) – the name of the hdf5 file
spec_name (string) – the name of the group in the hdf5 file
l (1d array) – the multipoles (or binned multipoles)
ps (1d array or dict of 1d array) – the power spectrum, if spectra is not None, expect a dictionary with entry spectra
spectra (list of strings) – needed for spin0 and spin2 cross correlation, the arrangement of the spectra