| name | ccl |
| description | Guide to CCL (pyccl), the DESC Core Cosmology Library for theoretical cosmological calculations. Use this skill whenever the user imports pyccl, works with Cosmology objects, computes angular power spectra (angular_cl), uses tracers (WeakLensingTracer, NumberCountsTracer, CMBLensingTracer), computes 3D power spectra (linear_matter_power, nonlin_matter_power), uses Pk2D, calls scalar functions like sigma8/growth_factor/comoving_radial_distance, configures halo model components, or asks about CCL cosmological calculations, units conventions, or parameter naming in any DESC pipeline context. |
CCL — Core Cosmology Library (pyccl)
You're helping a user write code with CCL (pyccl), DESC's Core Cosmology Library for standardized theoretical predictions.
CCL is TXPipe's cosmological backbone: every TXPipe theory or simulation stage reads a FiducialCosmology YAML file and converts it to a ccl.Cosmology via FiducialCosmology.to_ccl().
Overview
Cosmology construction
import pyccl as ccl
import numpy as np
cosmo = ccl.Cosmology(
Omega_c=0.27, Omega_b=0.045, h=0.67,
sigma8=0.8, n_s=0.96,
Omega_k=0.0, w0=-1.0, wa=0.0, Neff=3.046,
matter_power_spectrum="halofit",
transfer_function="bbks",
)
cosmo = ccl.Cosmology.read_yaml("fiducial_cosmology.yml")
Key gotchas: Distances return Mpc (not Mpc/h).
Set exactly one of sigma8 / A_s; pass None for the other.
For w0waCDM just set w0/wa in the same constructor.
Distances and growth
a = 1.0 / (1 + z)
chi = ccl.comoving_radial_distance(cosmo, a)
D = ccl.growth_factor(cosmo, a)
f = ccl.growth_rate(cosmo, a)
s8 = ccl.sigma8(cosmo)
Angular power spectra
z = np.linspace(0, 3, 300)
nz = np.exp(-0.5 * ((z - 0.5) / 0.1)**2)
wl = ccl.WeakLensingTracer(cosmo, dndz=(z, nz))
nc = ccl.NumberCountsTracer(cosmo, dndz=(z, nz),
has_rsd=False, bias=(z, np.ones_like(z)))
cmb = ccl.CMBLensingTracer(cosmo, z_source=1100.0)
ell = np.arange(2, 2000)
cl_shear = ccl.angular_cl(cosmo, wl, wl, ell)
cl_ggl = ccl.angular_cl(cosmo, nc, wl, ell)
cl_density = ccl.angular_cl(cosmo, nc, nc, ell)
angular_cl returns the standard lensing/clustering angular power spectrum without any ell prefactor.
3D power spectra and Pk2D
k = np.logspace(-4, 2, 200)
pk_lin = ccl.linear_matter_power(cosmo, k, a=1.0)
pk_nl = ccl.nonlin_matter_power(cosmo, k, a=1.0)
pk2d = ccl.Pk2D.from_function(pkfunc=lambda k, a: pk_lin,
is_logp=False)
See references/api.md for full parameter tables, halo model components, and units details.
TXPipe usage
Every TXPipe theory or simulation stage reads a FiducialCosmology YAML and converts it to ccl.Cosmology via FiducialCosmology.to_ccl().
See references/txpipe.md for the stage table and utility functions.
Reference