Skip to content

Commit

Permalink
bug
Browse files Browse the repository at this point in the history
  • Loading branch information
JaimeRZP committed Oct 17, 2024
1 parent 23372fb commit 00ba8c7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/tracers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ Returns:
"""
NumberCountsTracer(cosmo::Cosmology, z_n, nz;
b=1.0, res=1000, nz_interpolation="linear") = begin
z_w, nz_w = nz_interpolate(z_n, nz;
res=res, mode=nz_interpolation)
z_w, nz_w = nz_interpolate(z_n, nz, res;
mode=nz_interpolation)
nz_norm = integrate(z_w, nz_w, SimpsonEven())

chi = cosmo.chi(z_w)
Expand Down Expand Up @@ -65,8 +65,8 @@ WeakLensingTracer(cosmo::Cosmology, z_n, nz;
IA_params = [0.0, 0.0], m=0.0,
res=350, nz_interpolation="linear") = begin
cosmo_type = cosmo.settings.cosmo_type
z_w, nz_w = nz_interpolate(z_n, nz;
res=res, mode=nz_interpolation)
z_w, nz_w = nz_interpolate(z_n, nz, res;
mode=nz_interpolation)
res = length(z_w)
nz_norm = integrate(z_w, nz_w, SimpsonEven())
chi = cosmo.chi(z_w)
Expand Down Expand Up @@ -156,23 +156,19 @@ function get_IA(cosmo::Cosmology, zs, IA_params)
return @. A_IA*((1 + zs)/1.62)^alpha_IA * (0.0134 * cosmo.cpar.Ωm / cosmo.Dz(zs))
end

function nz_interpolate(z, nz; mode="linear", res=nothing)
function nz_interpolate(z, nz, res; mode="linear")
if mode!="none"
if mode=="linear"
nz_int = linear_interpolation(z, nz, extrapolation_bc=Line())
nz_int = linear_interpolation(z, nz;
extrapolation_bc=Line())
end
if mode=="cubic"
dz = mean(z[2:end] - z[1:end-1])
z_range = z[1]:dz:z[end]
nz_int = cubic_spline_interpolation(z_range, nz)
nz_int = cubic_spline_interpolation(z_range, nz;
extrpolation_bc=Line())
end
if res==nothing
dzz = dz/10
else
L = z[end] - z[1]
dzz = L/res
end
zz_range = z[1]:dzz:z[end]
zz_range = range(0.00001, stop=z[end], length=res)
nzz = nz_int(zz_range)
return zz_range, nzz
else
Expand Down
Binary file modified test/test_output.npz
Binary file not shown.

0 comments on commit 00ba8c7

Please sign in to comment.