From fb40fa7362145b335782db318107ac0b875f5c36 Mon Sep 17 00:00:00 2001 From: Sacha Guerrini Date: Mon, 20 Jul 2026 14:00:37 +0200 Subject: [PATCH 1/4] Fix bug related to noise bias decoupling --- src/sp_validation/cosmo_val/pseudo_cl.py | 64 +++++++++++++++--------- 1 file changed, 41 insertions(+), 23 deletions(-) diff --git a/src/sp_validation/cosmo_val/pseudo_cl.py b/src/sp_validation/cosmo_val/pseudo_cl.py index 13f747ad..3bb22c2f 100644 --- a/src/sp_validation/cosmo_val/pseudo_cl.py +++ b/src/sp_validation/cosmo_val/pseudo_cl.py @@ -145,35 +145,14 @@ def calculate_pseudo_cl_inka_cov( params = get_params_rho_tau(self.cc[ver]) cat_gal = fits.getdata(self.cc[ver]["shear"]["path"]) - for bin_key1, bin_key2 in tomo_bin_pairs: - if bin_key1 == bin_key2: - cat_gal_ = self._get_tomographic_bin(params, cat_gal, bin_key1) - - noise_bias_cl = self.get_noise_bias(params, nside, cat_gal_) - - else: - noise_bias_cl = np.zeros((4, 2 * nside)) - - # Update the fiducial_cl dictionnary - fiducial_cl[f"W{bin_key1}xW{bin_key2}"] = ( - np.array( - [ - fiducial_cl[f"W{bin_key1}xW{bin_key2}"], - 0.0 * fiducial_cl[f"W{bin_key1}xW{bin_key2}"], - 0.0 * fiducial_cl[f"W{bin_key1}xW{bin_key2}"], - 0.0 * fiducial_cl[f"W{bin_key1}xW{bin_key2}"], - ] - ) - + noise_bias_cl - ) + lmin, lmax, b_lmax = spv_pseudo_cl.pseudo_cl_geometry(self.nside) + b = self.get_namaster_bin(lmin, lmax, b_lmax) # Compute the fields and workspaces for bin_key1, bin_key2 in tomo_bin_pairs: self.print_cyan( f"Computing fields and workspaces for {bin_key1}, {bin_key2}" ) - lmin, lmax, b_lmax = spv_pseudo_cl.pseudo_cl_geometry(self.nside) - b = self.get_namaster_bin(lmin, lmax, b_lmax) # Get the tomographic bins cat_gal_a = self._get_tomographic_bin(params, cat_gal, bin_key1) @@ -234,6 +213,45 @@ def calculate_pseudo_cl_inka_cov( if bin_key1 <= bin_key2 and f"W{bin_key1}xW{bin_key2}" not in wsp_dict: wsp_dict[f"W{bin_key1}xW{bin_key2}"] = wsp + for bin_key1, bin_key2 in tomo_bin_pairs: + if bin_key1 == bin_key2: + self.print_cyan( + f"Adding the noise bias for tomographic bins {bin_key1}, {bin_key2}" + ) + + cat_gal_ = self._get_tomographic_bin(params, cat_gal, bin_key1) + + noise_bias_cl = self.get_noise_bias(params, nside, cat_gal_) + + # If using the analytical noise bias, we need to decouple it + if self.noise_bias_method == "analytical": + wsp = wsp_dict[f"W{bin_key1}xW{bin_key2}"] + noise_bias_cl = wsp.decouple_cell(noise_bias_cl) + + # And then unbin it + noise_bias_cl = b.unbin_cell(noise_bias_cl) + + # Force the bins not part of the mask to be zero + lowest_ell = b.get_ell_list(0)[0] + for i in range(4): + noise_bias_cl[i, :lowest_ell] = 0 + + else: + noise_bias_cl = np.zeros((4, 2 * nside)) + + # Update the fiducial_cl dictionnary + fiducial_cl[f"W{bin_key1}xW{bin_key2}"] = ( + np.array( + [ + fiducial_cl[f"W{bin_key1}xW{bin_key2}"], + 0.0 * fiducial_cl[f"W{bin_key1}xW{bin_key2}"], + 0.0 * fiducial_cl[f"W{bin_key1}xW{bin_key2}"], + 0.0 * fiducial_cl[f"W{bin_key1}xW{bin_key2}"], + ] + ) + + noise_bias_cl + ) + if self.fiducial_input_inka == "coupled": # Couple the cell if required self.print_cyan("Coupling the fiducial Cls.") From 6ec19cf246f20cb7a397ff0c0b72c797558af0c3 Mon Sep 17 00:00:00 2001 From: Sacha Guerrini Date: Mon, 20 Jul 2026 17:25:23 +0200 Subject: [PATCH 2/4] Fix typo in the value of --- src/sp_validation/cosmo_val/pseudo_cl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sp_validation/cosmo_val/pseudo_cl.py b/src/sp_validation/cosmo_val/pseudo_cl.py index 3bb22c2f..0eb17da4 100644 --- a/src/sp_validation/cosmo_val/pseudo_cl.py +++ b/src/sp_validation/cosmo_val/pseudo_cl.py @@ -224,7 +224,7 @@ def calculate_pseudo_cl_inka_cov( noise_bias_cl = self.get_noise_bias(params, nside, cat_gal_) # If using the analytical noise bias, we need to decouple it - if self.noise_bias_method == "analytical": + if self.noise_bias_method == "analytic": wsp = wsp_dict[f"W{bin_key1}xW{bin_key2}"] noise_bias_cl = wsp.decouple_cell(noise_bias_cl) From 59d6098a57996d6c127e605080c9e00bc50440df Mon Sep 17 00:00:00 2001 From: Sacha Guerrini Date: Tue, 21 Jul 2026 09:44:56 +0200 Subject: [PATCH 3/4] Add print of the decoupling of the noise bias --- src/sp_validation/cosmo_val/pseudo_cl.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sp_validation/cosmo_val/pseudo_cl.py b/src/sp_validation/cosmo_val/pseudo_cl.py index 0eb17da4..f2311914 100644 --- a/src/sp_validation/cosmo_val/pseudo_cl.py +++ b/src/sp_validation/cosmo_val/pseudo_cl.py @@ -225,6 +225,9 @@ def calculate_pseudo_cl_inka_cov( # If using the analytical noise bias, we need to decouple it if self.noise_bias_method == "analytic": + self.print_cyan( + "Decoupling the noise bias for the analytic method..." + ) wsp = wsp_dict[f"W{bin_key1}xW{bin_key2}"] noise_bias_cl = wsp.decouple_cell(noise_bias_cl) From 89435712db51de8f12d515cbb13470986098dcc0 Mon Sep 17 00:00:00 2001 From: Sacha Guerrini Date: Tue, 21 Jul 2026 15:23:56 +0200 Subject: [PATCH 4/4] Align namaster and fiducial binning for the covariance --- src/sp_validation/cosmo_val/pseudo_cl.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/sp_validation/cosmo_val/pseudo_cl.py b/src/sp_validation/cosmo_val/pseudo_cl.py index f2311914..b0351d07 100644 --- a/src/sp_validation/cosmo_val/pseudo_cl.py +++ b/src/sp_validation/cosmo_val/pseudo_cl.py @@ -137,6 +137,13 @@ def calculate_pseudo_cl_inka_cov( fiducial_cl = self.get_fiducial_cl(ver, compute_tomography) + # Add a zero multipole and drop the last value to align + # Namaster and fiducial binning + fiducial_cl = { + key: np.concatenate(([0.0], np.asarray(value[:-1], dtype=float))) + for key, value in fiducial_cl.items() + } + self.print_cyan( "Estimating and adding the noise bias to the fiducial power spectra" )