You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Julia is column-major; make sure innermost loop indices appear first in slice expressions (https://docs.julialang.org/en/v1/manual/performance-tips/#man-performance-column-major)
τs =collect(τs) # force array to avoid floating point errors with ranges in following χs due to (e.g. tiny negative χ)
@@ -80,13 +80,30 @@ function los_integrate(Ss::AbstractMatrix{T}, ls::AbstractVector, τs::AbstractV
80
80
verbose &&print("\rLOS integrating with l = $l")
81
81
for ik ineachindex(ks)
82
82
k = ks[ik]
83
-
for iτ ineachindex(τs)
84
-
S = Ss[iτ,ik]
85
-
χ = χs[iτ]
86
-
kχ = k * χ
87
-
∂I_∂τ[iτ] = S *Rl(l, kχ) #TODO: rewrite LOS integral to avoid evaluating Rl with dual numbers? # TODO: rewrite LOS integral with y = kτ0 and x=τ/τ0 to cache jls independent of cosmology
83
+
if l ≥ l_limber
84
+
χ = (l+1/2) / k
85
+
if χ > χs[1]
86
+
# χ > χini > χrec, so source function is definitely zero
87
+
S =0.0
88
+
else
89
+
# interpolate between two closest points in saved array
90
+
iχ₋ =searchsortedfirst(χs, χ; rev =true)
91
+
iχ₊ = iχ₋ -1
92
+
χ₋, χ₊ = χs[iχ₋], χs[iχ₊] # now χ₋ < χ < χ₊
93
+
S₋, S₊ = Ss[iχ₋,ik], Ss[iχ₊,ik]
94
+
S = S₋ + (S₊-S₋) * (χ-χ₋) / (χ₊-χ₋)
95
+
end
96
+
I =√(π/(2l+1)) * S / k
97
+
else
98
+
for iτ ineachindex(τs)
99
+
S = Ss[iτ,ik]
100
+
χ = χs[iτ]
101
+
kχ = k * χ
102
+
∂I_∂τ[iτ] = S *Rl(l, kχ) #TODO: rewrite LOS integral to avoid evaluating Rl with dual numbers? # TODO: rewrite LOS integral with y = kτ0 and x=τ/τ0 to cache jls independent of cosmology
103
+
end
104
+
I =integrate(τs, ∂I_∂τ; integrator) # integrate over τ # TODO: add starting I(τini) to fix small l?
88
105
end
89
-
Is[ik,il] =integrate(τs, ∂I_∂τ; integrator) # integrate over τ # TODO: add starting I(τini) to fix small l?
0 commit comments