diff --git a/src/theory.jl b/src/theory.jl index bfb89e7..323ce43 100755 --- a/src/theory.jl +++ b/src/theory.jl @@ -24,12 +24,14 @@ function Theory(cosmology::Cosmology, elseif t_type == "galaxy_shear" zs_mean, nz_mean = files[string("nz_", name)] m = get(Nuisances, string(name, "_", "m"), 0.0) - IA_params = [get(Nuisances, "A_IA", 0.0), - get(Nuisances, "alpha_IA", 0.0)] + A_IA = get(Nuisances, "A_IA", 0.0) + alpha_IA = get(Nuisances, "alpha_IA", 0.0) nz = get(Nuisances, string(name, "_", "nz"), nz_mean) zs = get(Nuisances, string(name, "_", "zs"), zs_mean) tracer = WeakLensingTracer(cosmology, zs, nz; - m=m, IA_params=IA_params) + m=m, + A_IA=A_IA, + alpha_IA=alpha_IA) elseif t_type == "cmb_convergence" tracer = CMBLensingTracer(cosmology) diff --git a/src/tracers.jl b/src/tracers.jl index 81c8171..2504134 100755 --- a/src/tracers.jl +++ b/src/tracers.jl @@ -60,7 +60,7 @@ struct WeakLensingTracer <: Tracer end WeakLensingTracer(cosmo::Cosmology, z, nz; - IA_params = [0.0, 0.0], m=0.0) = begin + A_IA=0.0, alpha_IA=0.0, m=0.0) = begin sel = @. (z > 0.0) z = z[sel] nz = nz[sel] @@ -79,15 +79,14 @@ WeakLensingTracer(cosmo::Cosmology, z, nz; lens_prefac = 1.5*cosmo.cpar.Ωm*H0^2 chi[1] = 0.0 w_arr = @. w_arr * chi * lens_prefac * (1+z) / nz_norm - if IA_params != [0.0, 0.0] - hz = Hmpc(cosmo, z) - As = get_IA(cosmo, z, IA_params) - corr = @. As * (nz * hz / nz_norm) - w_arr = @. w_arr - corr - end + # IA correction + hz = Hmpc(cosmo, z) + As = @. A_IA*((1 + z)/1.62)^alpha_IA * (0.0134 * cosmo.cpar.Ωm / cosmo.Dz(z)) + corr = @. As * (nz * hz / nz_norm) + w_arr_ia = @. w_arr - corr # Interpolate b = m+1.0 - wint = linear_interpolation(chi, b.*w_arr, extrapolation_bc=0.0) + wint = linear_interpolation(chi, b.*w_arr_ia, extrapolation_bc=0.0) F::Function = ℓ -> @.(sqrt((ℓ+2)*(ℓ+1)*ℓ*(ℓ-1))/(ℓ+0.5)^2) WeakLensingTracer(wint, F) end diff --git a/test/runtests.jl b/test/runtests.jl index 4d4e82b..260650f 100755 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -181,9 +181,7 @@ if test_main z = Vector(range(0.01, stop=2., length=1000)) nz = @. exp(-0.5*((z-0.5)/0.05)^2) tg = NumberCountsTracer(cosmo_EisHu, z, nz; b=1.0) - ts = WeakLensingTracer(cosmo_EisHu, z, nz; - m=0.0, - IA_params=[0.0, 0.0]) + ts = WeakLensingTracer(cosmo_EisHu, z, nz) tk = CMBLensingTracer(cosmo_EisHu) Cℓ_gg = angularCℓs(cosmo_EisHu, tg, tg, ℓs) Cℓ_gs = angularCℓs(cosmo_EisHu, tg, ts, ℓs) @@ -223,9 +221,7 @@ if test_main z = Vector(range(0.01, stop=2., length=1000)) nz = @. exp(-0.5*((z-0.5)/0.05)^2) tg = NumberCountsTracer(cosmo_EisHu, z, nz; b=1.0) - ts = WeakLensingTracer(cosmo_EisHu, z, nz; - m=0.0, - IA_params=[0.0, 0.0]) + ts = WeakLensingTracer(cosmo_EisHu, z, nz) tk = CMBLensingTracer(cosmo_EisHu) Cℓ_gg = angularCℓs(cosmo_EisHu_nonlin, tg, tg, ℓs) Cℓ_gs = angularCℓs(cosmo_EisHu_nonlin, tg, ts, ℓs) @@ -265,9 +261,7 @@ if test_main z = Vector(range(0.01, stop=2., length=1000)) nz = @. exp(-0.5*((z-0.5)/0.05)^2) tg = NumberCountsTracer(cosmo_emul, z, nz; b=1.0) - ts = WeakLensingTracer(cosmo_emul, z, nz; - m=0.0, - IA_params=[0.0, 0.0]) + ts = WeakLensingTracer(cosmo_emul, z, nz) tk = CMBLensingTracer(cosmo_emul) Cℓ_gg = angularCℓs(cosmo_emul, tg, tg, ℓs) Cℓ_gs = angularCℓs(cosmo_emul, tg, ts, ℓs) @@ -306,9 +300,7 @@ if test_main z = Vector(range(0.01, stop=2., length=1000)) nz = @. exp(-0.5*((z-0.5)/0.05)^2) tg = NumberCountsTracer(cosmo_EisHu_nonlin, z, nz; b=1.0) - ts = WeakLensingTracer(cosmo_EisHu_nonlin, z, nz; - m=0.0, - IA_params=[0.0, 0.0]) + ts = WeakLensingTracer(cosmo_EisHu_nonlin, z, nz) tk = CMBLensingTracer(cosmo_EisHu_nonlin) Cℓ_gg = angularCℓs(cosmo_EisHu_nonlin, tg, tg, ℓs) Cℓ_gs = angularCℓs(cosmo_EisHu_nonlin, tg, ts, ℓs) @@ -348,9 +340,7 @@ if test_main z = Vector(range(0.01, stop=2., length=1000)) nz = @. exp(-0.5*((z-0.5)/0.05)^2) tg = NumberCountsTracer(cosmo_emul_nonlin, z, nz; b=1.0) - ts = WeakLensingTracer(cosmo_emul_nonlin, z, nz; - m=0.0, - IA_params=[0.0, 0.0]) + ts = WeakLensingTracer(cosmo_emul_nonlin, z, nz) tk = CMBLensingTracer(cosmo_emul_nonlin) Cℓ_gg = angularCℓs(cosmo_emul_nonlin, tg, tg, ℓs) Cℓ_gs = angularCℓs(cosmo_emul_nonlin, tg, ts, ℓs) @@ -572,9 +562,7 @@ if test_main z = Vector(range(0.01, stop=2., length=1000)) nz = Vector(@. exp(-0.5*((z-0.5)/0.05)^2)) tg = NumberCountsTracer(cosmo, z, nz; b=1.0) - ts = WeakLensingTracer(cosmo, z, nz; - m=0.0, - IA_params=[0.0, 0.0]) + ts = WeakLensingTracer(cosmo, z, nz) Cℓ_gs = angularCℓs(cosmo, tg, ts, ℓs) return Cℓ_gs end @@ -584,9 +572,7 @@ if test_main nz=700, nz_t=700, nz_pk=700) z = Vector(range(0.01, stop=2., length=1000)) nz = Vector(@. exp(-0.5*((z-0.5)/0.05)^2)) - ts = WeakLensingTracer(cosmo, z, nz; - m=0.0, - IA_params=[0.0, 0.0]) + ts = WeakLensingTracer(cosmo, z, nz) Cℓ_ss = angularCℓs(cosmo, ts, ts, ℓs) return Cℓ_ss end @@ -596,9 +582,7 @@ if test_main nz=500, nz_t=500, nz_pk=700) z = range(0.01, stop=2., length=2000) nz = @. exp(-0.5*((z-0.5)/0.05)^2) - ts = WeakLensingTracer(cosmo, z, nz; - m=0.0, - IA_params=[0.0, 0.0]) + ts = WeakLensingTracer(cosmo, z, nz) tk = CMBLensingTracer(cosmo) Cℓ_sk = angularCℓs(cosmo, ts, tk, ℓs) return Cℓ_sk @@ -671,8 +655,9 @@ if test_main z = Vector(range(0.01, stop=2., length=1024)) nz = @. exp(-0.5*((z-0.5)/0.05)^2) tg_b = NumberCountsTracer(cosmo_EisHu_nonlin, z, nz; b=2.0) - ts_m = WeakLensingTracer(cosmo_EisHu_nonlin, z, nz; m=1.0, IA_params=[0.0, 0.0]) - ts_IA = WeakLensingTracer(cosmo_EisHu_nonlin, z, nz; m=0.0, IA_params=[0.1, 0.1]) + ts_m = WeakLensingTracer(cosmo_EisHu_nonlin, z, nz; m=1.0) + ts_IA = WeakLensingTracer(cosmo_EisHu_nonlin, z, nz; + m=0.0, A_IA=0.1, alpha_IA=0.1) Cℓ_gg_b = angularCℓs(cosmo_EisHu_nonlin, tg_b, tg_b, ℓs) Cℓ_ss_m = angularCℓs(cosmo_EisHu_nonlin, ts_m, ts_m, ℓs) Cℓ_ss_IA = angularCℓs(cosmo_EisHu_nonlin, ts_IA, ts_IA, ℓs) @@ -707,7 +692,7 @@ if test_main cosmo.settings.cosmo_type = typeof(p) z = Vector(range(0.01, stop=2., length=2000)) .- p nz = Vector(@. exp(-0.5*((z-0.5)/0.05)^2)) - ts = WeakLensingTracer(cosmo, z, nz; m=p, IA_params=[0.0, 0.0]) + ts = WeakLensingTracer(cosmo, z, nz; m=p) ℓs = [10.0, 30.0, 100.0, 300.0] Cℓ_ss = angularCℓs(cosmo, ts, ts, ℓs) return Cℓ_ss @@ -718,7 +703,7 @@ if test_main cosmo.settings.cosmo_type = typeof(p) z = range(0.01, stop=2., length=2000) nz = @. exp(-0.5*((z-0.5)/0.05)^2) - ts = WeakLensingTracer(cosmo, z, nz; m=p, IA_params=[0.0, 0.0]) + ts = WeakLensingTracer(cosmo, z, nz; m=p) ℓs = [10.0, 30.0, 100.0, 300.0] Cℓ_sk = angularCℓs(cosmo, ts, ts, ℓs) return Cℓ_sk @@ -729,7 +714,7 @@ if test_main cosmo.settings.cosmo_type = typeof(p) z = range(0.01, stop=2., length=2000) nz = @. exp(-0.5*((z-0.5)/0.05)^2) - ts = WeakLensingTracer(cosmo, z, nz; m=2, IA_params=[p, 0.1]) + ts = WeakLensingTracer(cosmo, z, nz; m=2, A_IA=p, alpha_IA=0.1) ℓs = [10.0, 30.0, 100.0, 300.0] Cℓ_ss = angularCℓs(cosmo, ts, ts, ℓs) return Cℓ_ss @@ -740,7 +725,7 @@ if test_main cosmo.settings.cosmo_type = typeof(p) z = range(0.01, stop=2., length=2000) nz = @. exp(-0.5*((z-0.5)/0.05)^2) - ts = WeakLensingTracer(cosmo, z, nz; m=2, IA_params=[0.3, p]) + ts = WeakLensingTracer(cosmo, z, nz; m=2, A_IA=0.3, alpha_IA=p) ℓs = [10.0, 30.0, 100.0, 300.0] Cℓ_ss = angularCℓs(cosmo, ts, ts, ℓs) return Cℓ_ss diff --git a/test/test_output.npz b/test/test_output.npz index 754369e..b99ebc4 100644 Binary files a/test/test_output.npz and b/test/test_output.npz differ