def get_and_format_inv_Nl(manager: DataManager, config: Config):
"""
Loads noise Cl estimated from noise map simulations.
Makes sure that there is a value for each ell by adding concatenating 0 up to ell_min
Naively inverts the noise spectra (1/N_ell) to get inverse noise covariance needed for componenet separation.
"""
# Importing noise Cl computer in pixel_noisecov_estimater.py
# Here we use the cl_unbinned from namaster wich is C_ell instead of C_bin
# Each C_ell in a bin is equal to C_bin
# Cl_from_maps is a 3D array with shape (n_freq, n_auto_spectra, n_ell)
# Where auto spectra are TT, EE, BB and TT is left null
# TODO: use full auto-cross spectra?
Cl_from_maps = np.load(manager.path_to_nl_noisecov_unbinned)
# add 0 for first bins in the last dimension (ell)
Cl_from_maps = np.pad(
Cl_from_maps,
((0, 0), (0, 0), (config.parametric_sep_pars.harmonic_lmin, 0)),
mode="constant",
constant_values=0,
)
inv_Cl_from_maps = np.zeros_like(Cl_from_maps)
inv_Cl_from_maps[:, 1:, config.parametric_sep_pars.harmonic_lmin + 1 :] = (
1 / Cl_from_maps[:, 1:, config.parametric_sep_pars.harmonic_lmin + 1 :]
)
inv_Cl_from_maps_diag = np.zeros(
(
Cl_from_maps.shape[0],
Cl_from_maps.shape[0],
Cl_from_maps.shape[1],
Cl_from_maps.shape[2],
)
)
for i in range(inv_Cl_from_maps_diag.shape[0]):
inv_Cl_from_maps_diag[i, i] = inv_Cl_from_maps[i]
return inv_Cl_from_maps_diag.T