Grids#
discocmb.grids provides helpers for building the wave-number, time and multipole grids over which the E-B
integration is performed, and the Bessel and Wigner tables on those grids.
The sources vary most at recombination and on the sound-horizon scale in
tau, and at the acoustic and Silk damping scales in k.
tau_grid() and k_grid() put their points there. One
trajectory of the source kernel supplies these scales and the fiducial’s
conformal time as a function of the scale factor
(_summary._kernel_thermal_history), so building the grid compiles
nothing new and integrates nothing beside the solve.
Grid.from_fiducial() adds everything else that depends on the
fiducial only: the Bessel tables of the projection
(projection_tables(), in chunks of spans()), the lensing
potential’s exact and Limber operators, the Wigner tables of the lensing
sums (lensing_tables()) and the spline matrices onto every multipole.
Every batch of an inference loop shares them.
DISCO-EB integrates in the scale factor, so the solve saves at a_save,
the scale factors at which the fiducial has the conformal times
tau_save. Another cosmology reaches other times there, which the
projection resamples onto the shared grid
(resample_stencil()).
- class discocmb.Grid(layout: Layout, operators: Operators)[source]#
The grid of a CMB computation and the operators on it, shaped by a fiducial cosmology.
from_fiducial()builds them.discoeb.solve_eb()solves the modesk_valuesat the scale factorsa_save, andtransfer_functions()projects the sources onto the multipolesellswith the operators, gigabytes of Bessel and Wigner tables. Spectra come out at every multipole tolmax = ells[-1].A grid is a JAX pytree whose leaves are the operators and whose NumPy arrays are static. A jitted function that takes it as an argument reads the tables in place as device buffers. One that closed over them would carry them as constants of its program.
- classmethod Grid.from_fiducial(cosmology, *, k_values=None, ells=None, n_k: int = 128, n_save: int = 600, k_fine_step: float = 0.00019, extrapolate_above: float | None = None, dtype=<class 'jax.numpy.float32'>, cache_dir: str | None = None) Grid[source]#
Return the grid and operators appropriate for the given
cosmology.Nearby cosmologies share where their sources vary, so one fiducial’s grid serves a batch, and every batch of an inference loop.
k_valuesare the wave modes (1/Mpc) of the temperature and polarization, up toK_MAX_CMB, and the grid addsLENSING_MODESpast the last one for the lensing potential. Without them the modes arek_grid()’sn_kwith uniform steps at lowk(solve_modes()). TheC_lquadrature runs onquadrature_modes()of stepk_fine_step, and the solve saves atn_savescale factors (tau_grid()).ellsare the multipoles to project,ELL_NODESby default, and the spectra come out at every multipole toells[-1].extrapolate_aboveleaves the modes past it unsolved and continues the last two solved ones in the lensing potential (5e-5 at 1.2 / Mpc).dtypeis the precision of the tables, of the spline onto every multipole and of the Limber tilt. Single precision costs 2.6e-4 inD_l, too much for a derivative, which needsjnp.float64and a short list ofells: the tables grow with the multipoles.The building takes about 13 s, mostly the Bessel tables on the host.
cache_dirkeeps the result on disk under a digest of the arguments, the fiducial and the installed sources of DISCO-CMB, DISCO-EB and modax.