LSSTDESC / CCL

DESC Core Cosmology Library: cosmology routines with validated numerical accuracy
BSD 3-Clause "New" or "Revised" License
144 stars 64 forks source link

C_\ell(\kappa_I)/C_\ell(\delta) should be scale independent for NLA #1034

Closed NiallJeffrey closed 1 year ago

NiallJeffrey commented 1 year ago

In the NLA Intrinsic Alignment model, the ratio of the kappa power spectrum with pure IA (no lensing shear) to the matter power spectrum should be scale invariant. However, I find a low \ell discrepancy. f_NLA_comparison_error Code snippet to reproduce:

import matplotlib.pyplot as plt
import numpy as np
import pyccl as ccl

# Cosmology
z = np.linspace(0, 2.5, 10000)
z_fiducial = 0.9
sigma_z = 0.01
nz = np.exp(-0.5*((z-z_fiducial)/sigma_z)**2)
theory_fnla = -0.003018

cosmo_truth = ccl.Cosmology(Omega_c=0.286-0.046, Omega_b=0.046 , h=0.7, A_s=1.703983e-9, n_s=0.96)

# Calculate cl for IA shear with NLA
ell = np.unique(np.geomspace(2,1024*4,1000).astype(int)).astype(float)
t_i_nla = ccl.WeakLensingTracer(cosmo_truth, dndz=(z, nz), has_shear=False,
                                ia_bias=(z, np.ones_like(z)*0.49), use_A_ia=True)
cl_II_nla = ccl.angular_cl(cosmo_truth, t_i_nla, t_i_nla, ell)

# Convert cl to IA kappa 
prefactor_ell = []
for ell_val in ell:
    prefactor_ell.append((((ell_val-1.)*(ell_val+2.))/((ell_val)*(ell_val+1.))))

prefactor_ell = np.array(prefactor_ell)
cl_II_nla_kappa = cl_II_nla/prefactor_ell

# Calculate cl for density
clu1 = ccl.NumberCountsTracer(cosmo_truth, has_rsd=False, dndz=(z,nz), bias=(z,z*0.+1.))
cls_clu = ccl.angular_cl(cosmo_truth, clu1, clu1, ell) 

# Calculate empirical f_nla: -sqrt(C_ell(IA)/C_ell(\delta))
f_nla_empiral = -np.sqrt(cl_II_nla_kappa/cls_clu)

# Plot result
_ = plt.figure(figsize=(5,4))
_ = plt.plot(ell, f_nla_empiral, ls=':',lw=3,
         label='$-\sqrt{C_\ell(\kappa_I)/C_\ell(\delta)}$')
_ = plt.plot(ell,ell*0+theory_fnla, alpha=0.5, lw=3,label='Theory prediction')
_ = plt.xlabel(r'$\ell$', fontsize=12)
_ = plt.ylabel(r'Empirical $f_{NLA}$', fontsize=12)
_ = plt.xscale('log')
_ = plt.legend()
_ = plt.grid()
_ = plt.title(r'$C_\ell(\kappa_I)/C_\ell(\delta)\ $' + 'should be scale independent for NLA', x=0.48)
_ = plt.tight_layout()
_ = plt.savefig('f_NLA_comparison_error.png',dpi=200)
_ = plt.close()
damonge commented 1 year ago

Could this be due to the spin-2 nature of IAs? I.e. remember there's a prefactor of the form sqrt((ell+2)!/(ell-2)!)/(ell+1/2)^2 due to this.

damonge commented 1 year ago

In the code I see you're correcting to kappa, so in that case the correction factor would be ell*(ell+1)/(ell+0.5)^2

NiallJeffrey commented 1 year ago

@damonge Ah - that's not the number I get. For example using this eq. 11 - https://arxiv.org/pdf/2210.13260.pdf - I get the power spectra from shear to kappa changes by ((ell-1)(ell+2))/(ell (ell+1)). Do you see where this difference comes from?

NiallJeffrey commented 1 year ago

@damonge I actually realise you mean there is an additional correction factor. This works! The error is now sub-percent.

I need to convince myself that this makes sense for NLA in this context before I close the issue.

damonge commented 1 year ago

Kappa takes a factor ell*(ell+1)/(k*chi)^2 from translating between the transverse and full Laplacian (this is so you can express it as an integral over the matter overdensity). In the Limber approximation k*chi=(ell+1/2), hence the correction factor of ell*(ell+1)/(ell+0.5)^2 for each factor of kappa going into the power spectrum.

damonge commented 1 year ago

@NiallJeffrey let me know if the above was not convincing! Will close for now.