CAMB Output¶
Complete workflow: configure CAMB, compute, wrap with CambOutput, plot all observables.
Optional dependency
This example requires the camb Python package:
camb is an optional dependency.
Setup¶
import camb
import numpy as np
import cplots
pars = camb.set_params(
H0=67.4, ombh2=0.022, omch2=0.12,
mnu=0.06, omk=0, tau=0.054,
As=2.1e-9, ns=0.965,
lmax=2500,
redshifts=[0.0, 0.5, 1.0],
WantTransfer=True,
)
results = camb.get_results(pars)
out = cplots.CambOutput(results)
Background evolution¶
Plot only H(z) and luminosity distance:
bg = out.background(
quantities=["H [km/s/Mpc]", "lum. dist."],
labels={"lum. dist.": r"$d_L$ [Mpc]"},
)
cplots.BackgroundEvolution(bg).show()
Matter power spectrum¶
Linear P(k) at z=0 in h/Mpc units:
Because pk() uses an interpolator internally, z does not need to appear in the
pre-computed redshift list passed to set_params:
fig = cplots.Figure()
for z in [0.0, 0.3, 0.7, 1.5]:
pk = out.pk(z=z, n_k=300)
fig.add(cplots.PKSpectrum(pk, label=f"z={z}"))
fig.show()
CMB angular power spectra¶
TT, EE, and TE spectra with the standard ℓ(ℓ+1)/2π scaling:
cls = out.cl(spectra=["tt", "ee", "te"], lensed=True, ell_factor=True)
cplots.ClSpectrum(cls).show()
Unlensed TT only, in K²:
Primordial power spectrum¶
Computed analytically from the inflation parameters (As, ns, pivot_scalar) — no
extra CAMB output flag needed:
Thermodynamics¶
Not available for CAMB
thermodynamics() raises NotImplementedError for CambOutput. CAMB does not
expose a visibility table equivalent to CLASS's thermodynamics output. Use
ClassOutput if you need thermodynamic background quantities.