Spectra#

discocmb.spectra integrates the transfer functions over wave modes against a primordial spectrum.

The transfer functions of discocmb.transfer and the primordial curvature spectrum give:

C_l^{XY} = 4 pi int dln k  P_R(k) X_l(k) Y_l(k), P_R = A_s (k/k_p)^{n_s - 1}

where X and Y stand for the temperature Theta_l or the E-mode E_l, and the lensing potential’s C_l^{psi psi} by the same integral, exact at low l and Limber above (lensing_potential_spectrum()). cmb_power_spectrum() takes any primordial spectrum (power_law() by default) and returns Spectra at every multipole.

solve_cmb() runs the steps for a batch in one call: the solve, the transfer functions and cmb_power_spectrum(). It is differentiable in the cosmologies’ parameters.

discocmb.solve_cmb(cosmologies, *, grid: Grid | None = None, **solve_kwargs)[source]#

Return (ells, C_l, D_l) of a batch: the multipoles and two Spectra.

cosmologies is one DISCO-EB cosmology or a list of one model’s, [discoeb.LCDM(omega_b=..., ...), ...]. ells is 0..grid.lmax and each spectrum (n_cosmologies, lmax + 1): TT, TE, EE and the lensing potential, unlensed. lensed_spectra() lenses C_l.

The steps, each of which can run on its own:

  1. discoeb.solve_eb() solves every wave mode of every cosmology in one launch and keeps the sources, which LineOfSightSources evaluates in the kernel, with error_weights().

  2. transfer_functions() projects the sources onto the multipoles.

  3. cmb_power_spectrum() integrates the transfer functions over the wave modes against the cosmologies’ primordial spectra.

grid (from from_fiducial()) fix the wave modes, save times, multipoles and operators. Build them once and pass them to every batch. Without them the first cosmology shapes the grid, and the last of these stays cached. solve_kwargs go to the solver (rtol, atol, max_steps, …), and error_weights there go over error_weights().

Derivatives. The spectra are differentiable in every parameter of the cosmologies, in forward and reverse mode (jax.jacfwd, jax.grad): a cosmology is a pytree, and jax.jacfwd of a function of one returns the derivatives as a cosmology. The kernel carries forward sensitivities through the hierarchy and the recombination history, and the kept conformal times carry the distance to every source. cosmology.replace also sets a column DISCO-EB derives from the parameters, such as omega_g (discoeb.derived_parameters()), for a derivative in it. Derivatives need a grid in double precision (dtype=jnp.float64), and for many directions split_derivatives=True keeps a thread’s memory that of one column.

discocmb.cmb_power_spectrum(transfers, cosmologies, *, primordial=None)[source]#

Return (C_l, D_l), each a Spectra at every multipole to lmax.

The integral over the wave modes,

C_l^{XY} = 4 pi int dln k  P_R(k) X_l(k) Y_l(k),

of the Transfers transfers, where X and Y stand for Theta_l or E_l. The lensing potential’s C_l^{psi psi} is the same integral, exact at low l and Limber above (lensing_potential_spectrum()). The projection computes the multipoles grid.ells, and a cubic spline in ln l gives every other one. At grid.ells the values are the projection’s own.

cosmologies are the batch’s, whose T_cmb converts D_l to muK^2. primordial maps wave numbers (n, ...) to P_R, one row per cosmology (power_law()). By default it is the power law of the cosmologies’ A_s, n_s and k_p. Traceable.

namedtuple discocmb.Spectra(tt: jax.Array, te: jax.Array, ee: jax.Array, pp: jax.Array)[source]#

Bases: NamedTuple

The temperature, cross, E-mode and lensing potential spectra.

Each field is (n_cosmologies, lmax + 1), indexed by the multipole from l = 0. As C_l the first three are in units of T_cmb^2 and pp, C_l^{psi psi}, is dimensionless. As D_l the first three are l(l+1) C_l / 2pi in muK^2 and pp is [l(l+1)]^2 C_l^{psi psi} / 2pi.

Fields:
  1.  tt (Array) – The temperature spectrum.

  2.  te (Array) – The temperature and E-mode cross spectrum.

  3.  ee (Array) – The E-mode spectrum.

  4.  pp (Array) – The lensing potential spectrum.

discocmb.spectra.power_law(A_s, n_s, k_pivot)[source]#

Return P_R(k) = A_s (k / k_pivot)^(n_s - 1) as a function of k (n, ...).

A_s, n_s and k_pivot are numbers or (n,), one per cosmology. cmb_power_spectrum() takes the function as primordial. The tilt takes the precision of k.