@@ -207,13 +207,17 @@ function spectrum_cmb(modes::AbstractVector, prob::CosmologyProblem, jl::Spheric
207207 iE = ' E' in join (modes) ? iT + 1 : 0
208208 Ss = Num[]
209209 iT > 0 && push! (Ss, prob. M. ST0)
210- iE > 0 && push! (Ss, prob. M. ST2_polarization )
210+ iE > 0 && push! (Ss, prob. M. SE_kχ² )
211211 ks_coarse = range (ks_fine[begin ], ks_fine[end ]; length = 2 )
212212 ks_coarse, Ss_coarse = source_grid_adaptive (prob, Ss, τs, ks_coarse; bgopts, ptopts, verbose, sourceopts... ) # TODO : thread flag # TODO : pass kτ0 and x # TODO : pass bgsol
213213
214214 # Interpolate source function to finer k-grid
215215 Ss_fine = source_grid (Ss_coarse, ks_coarse, ks_fine)
216- Ss_fine[:, end , :] .= 0.0
216+ if iE > 0
217+ χs = τs[end ] .- τs
218+ Ss_fine[iE, :, :] ./= (ks_fine' .* χs) .^ 2
219+ end
220+ Ss_fine[:, end , :] .= 0.0 # can be Inf, but is always weighted by zero-valued spherical Bessel function in LOS integration
217221
218222 ΘlTs = iT > 0 ? los_integrate (@view (Ss_fine[iT, :, :]), ls, τs, ks_fine, jl; integrator, verbose, kwargs... ) : nothing
219223 ΘlEs = iE > 0 ? los_integrate (@view (Ss_fine[iE, :, :]), ls, τs, ks_fine, jl; integrator, verbose, kwargs... ) .* transpose (@. √ ((ls+ 2 )* (ls+ 1 )* (ls+ 0 )* (ls- 1 ))) : nothing
0 commit comments