Skip to content

Commit

Permalink
no print
Browse files Browse the repository at this point in the history
  • Loading branch information
JaimeRZP committed Oct 17, 2024
1 parent 48e7ac1 commit 26aa8bd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 17 deletions.
9 changes: 6 additions & 3 deletions src/theory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ function Theory(cosmology::Cosmology,
names, types, pairs,
idx, files;
Nuisances=Dict(),
res_wl=350, res_gc=1000)
res_wl=350, res_gc=1000,
int_wl="linear", int_gc="linear")

nui_type = eltype(valtype(Nuisances))
if !(nui_type <: Float64) & (nui_type != Any)
Expand All @@ -23,7 +24,8 @@ function Theory(cosmology::Cosmology,
zs = get(Nuisances, string(name, "_", "zs"), zs_mean)
dz = get(Nuisances, string(name, "_", "dz"), 0.0)
tracer = NumberCountsTracer(cosmology, zs .+ dz, nz;
b=b, res_gc=res_gc)
b=b, res=res_gc,
nz_interpolation=int_gc)
elseif t_type == "galaxy_shear"
zs_mean, nz_mean = files[string("nz_", name)]
m = get(Nuisances, string(name, "_", "m"), 0.0)
Expand All @@ -34,7 +36,8 @@ function Theory(cosmology::Cosmology,
dz = get(Nuisances, string(name, "_", "dz"), 0.0)
tracer = WeakLensingTracer(cosmology, zs .+ dz, nz;
m=m, IA_params=IA_params,
res=res_wl)
res=res_wl,
nz_interpolation=int_wl)

elseif t_type == "cmb_convergence"
tracer = CMBLensingTracer(cosmology)
Expand Down
38 changes: 24 additions & 14 deletions src/tracers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ Kwargs:
Returns:
- `NumberCountsTracer::NumberCountsTracer` : Number counts tracer structure.
"""
NumberCountsTracer(cosmo::Cosmology, z_n, nz; b=1.0, res=1000) = begin
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)
nz_norm = integrate(z_w, nz_w, SimpsonEven())

Expand Down Expand Up @@ -60,7 +61,8 @@ struct WeakLensingTracer <: Tracer
end

WeakLensingTracer(cosmo::Cosmology, z_n, nz;
IA_params = [0.0, 0.0], m=0.0, res=350, kwargs...) = begin
IA_params = [0.0, 0.0], m=0.0,
res=350, nz_interpolate="linear") = begin
cosmo_type = cosmo.settings.cosmo_type
z_w, nz_w = nz_interpolate(z_n, nz, res)
res = length(z_w)
Expand Down Expand Up @@ -152,17 +154,25 @@ 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, res=nothing)
dz = mean(z[2:end] - z[1:end-1])
z_range = z[1]:dz:z[end]
nz_int = cubic_spline_interpolation(z_range, nz)
if res==nothing
dzz = dz/10
function nz_interpolate(z, nz; mode="linear", res=nothing)
if mode!="none"
if mode=="linear"
nz_int = linear_interpolation(z, nz, extrapolation_bc=Line())
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)
end
if res==nothing
dzz = dz/10
else
L = z[end] - z[1]
dzz = L/res
end
zz_range = z[1]:dzz:z[end]
nzz = nz_int(zz_range)
return zz_range, nzz
else
L = z[end] - z[1]
dzz = L/res
return z, nz
end
zz_range = z[1]:dzz:z[end]
nzz = nz_int(zz_range)
return zz_range, nzz
end
end
Binary file modified test/test_output.npz
Binary file not shown.

0 comments on commit 26aa8bd

Please sign in to comment.