API reference#

All functions are importable from the top-level classy_szlite namespace. For runnable code + plots, see Tutorials & examples.

Parameter containers#

class classy_szlite.CosmoParams(omega_b=0.02242, omega_cdm=0.11933, H0=67.66, tau_reio=0.054, ln10_10_As=3.047, n_s=0.9665, fEDE=0.001, log10z_c=3.562, thetai_scf=2.83, r=0.0, m_ncdm=0.02, N_ur=0.00441)[source]#

Bases: NamedTuple

Cosmological parameters for the ede-v2 emulator suite.

Defaults give the LCDM-equivalent point (Planck 18 + fEDE = 0.001).

Parameters:
H0: float | Array#

Alias for field number 2

N_ur: float | Array#

Alias for field number 11

fEDE: float | Array#

Alias for field number 6

ln10_10_As: float | Array#

Alias for field number 4

log10z_c: float | Array#

Alias for field number 7

m_ncdm: float | Array#

Alias for field number 10

n_s: float | Array#

Alias for field number 5

omega_b: float | Array#

Alias for field number 0

omega_cdm: float | Array#

Alias for field number 1

r: float | Array#

Alias for field number 9

tau_reio: float | Array#

Alias for field number 3

thetai_scf: float | Array#

Alias for field number 8

class classy_szlite.ProfileParamsA10(P0=8.13, c500=1.156, gamma=0.3292, alpha=1.062, beta=5.4807, B=1.0)[source]#

Bases: NamedTuple

Arnaud 2010 gNFW pressure-profile parameters (for tSZ Cl^yy).

B is the hydrostatic mass bias (B = M_true / M_HSE); the profile is evaluated at the effective M_HSE = M_true / B and r_500c_HSE = r_500c_true / B^(1/3).

Parameters:
B: float | Array#

Alias for field number 5

P0: float | Array#

Alias for field number 0

alpha: float | Array#

Alias for field number 3

beta: float | Array#

Alias for field number 4

c500: float | Array#

Alias for field number 1

gamma: float | Array#

Alias for field number 2

Derived parameters#

classy_szlite.derived(cosmo)[source]#

Derived parameters: sigma_8, Omega_m, S8.

Also returns the full 17-element DER emulator output as 'der_full' (σ8 is at index 1; consult the CosmoPower DER training script for the full list).

Parameters:

cosmo (CosmoParams)

Return type:

dict

The der_full array contains 17 entries from the ede-v2 DER emulator (index 0 = \(h\), index 1 = \(\sigma_8\), index 2 = \(\Omega_m\), etc.).

CMB angular power spectra#

classy_szlite.cl_TTTEEE(cosmo, spectra=('tt', 'te', 'ee'), ell_factor=True, ell_convention='classy_szfast')[source]#

CMB angular power spectra.

Returns a dict with keys 'ell' and the requested spectra ('tt','te','ee'). Values are dimensionless — multiply by Tcmb_uK² = (2.7255e6)² to convert to μK².

Parameters:
  • cosmo (CosmoParams) – CosmoParams instance (the ede-v2 input vector).

  • spectra (tuple[str, ...]) – Requested spectra, any subset of ("tt", "te", "ee", "pp").

  • ell_factor (bool) – If True (default), return D_ℓ = ℓ(ℓ+1) Cℓ / (2π). If False, return the raw Cℓ.

  • ell_convention (str) –

    • "classy_szfast" (default) — output [2, ..., 9500], with Cℓ(ℓ) = pred[ℓ−2] / ℓ². This is what classy_szfast does inside calculate_cmb; using it gives bit-identical Cls to the cobaya + classy_sz fast-mode stack that every published EDE chain (including ACT-DR6 + Planck) was fit with.

    • "emulator_modes" — output [1, ..., 9499] exactly as stored in the ede-v2 modes metadata, with Cℓ(ℓ) = pred[ℓ−1] / ℓ². Use this only if you intentionally want to disagree with the published chains.

Return type:

dict

The default output is \(D_\ell = \ell(\ell+1)C_\ell/(2\pi)\) in units of \(T_{\rm CMB}^2\) — multiply by \(T_{\rm CMB}^2 = (2.7255\times10^6\,\mu{\rm K})^2\) to get \(\mu{\rm K}^2\).

Matter power spectrum#

classy_szlite.Pk(cosmo, z_arr)[source]#

Linear P(k, z) — returns (k, pk(z, k)).

Parameters:

cosmo (CosmoParams)

classy_szlite.Pnl(cosmo, z_arr)[source]#

Non-linear P(k, z) (HMcode) — returns (k, pk(z, k)).

Parameters:

cosmo (CosmoParams)

Distances#

classy_szlite.distances(cosmo, z_arr)[source]#

Returns (Hz, chi, Da). Hz is H(z)/c in 1/Mpc; distances in Mpc.

Parameters:

cosmo (CosmoParams)

Returns Hz / c in \(1/\mathrm{Mpc}\) (multiply by \(c=299\,792.458\) km/s for \(H(z)\) in km/s/Mpc), \(\chi(z)\) in Mpc, and \(D_A(z)=\chi(z)/(1+z)\) in Mpc.

Halo-model tSZ Cl^yy#

classy_szlite.cl_yy(cosmo, profile, ell, z_grid=None, n_z=100, m_min=10000000000.0, m_max=3500000000000000.0, n_m=200, delta_crit=500.0, x_outSZ=4.0, c500_fiducial=1.156)[source]#

Halo-model tSZ angular power spectrum (full pipeline per call).

Returns (cl_1h, cl_2h) — dimensionless C_ell. Multiply by ell*(ell+1)/(2π)*1e12 to get D_ell × 1e12.

The GNFW pressure profile is truncated at x = x_outSZ * r_500c (default 4.0, matching classy_sz / Arnaud+2010 convention).

For MCMC sampling only profile parameters at fixed cosmology, use cl_yy_factory() instead — ~3× faster.

Parameters:
classy_szlite.cl_yy_factory(cosmo, ell, z_grid=None, n_z=100, m_min=10000000000.0, m_max=3500000000000000.0, n_m=200, delta_crit=500.0, x_outSZ=4.0, c500_fiducial=1.156)[source]#

Fixed-cosmology fast-path: precompute the heavy bits, get a closure.

Builds CosmoGrids (emulators → P_lin, distances, σ(R)) and HaloGrids (Tinker 08 HMF, bias) once, then returns:

ev(profile) -> (cl_1h, cl_2h)

A subsequent ev(profile) call only runs the cl_yy_1h_2h halo-model integration — typically ~5 ms per call. Intended for MCMC over profile / nuisance parameters with fixed cosmology.

Parameters:
  • x_outSZ (float, optional) – Outer truncation radius of the GNFW pressure profile in units of r_500c (i.e. x = r / r_500c). The FT look-up table u-grid runs from 1e-5 to c500_fiducial * x_outSZ (in u = c500 * x units), matching the classy_sz x_outSZ convention. Default 4.0 (literature / ACT-DR6 may26 convention).

  • c500_fiducial (float, optional) – c500 used to convert x_outSZ → u_max at table-build time. Should match the c500 you will pass in ProfileParamsA10. Default 1.156 (Arnaud et al. 2010).

  • cosmo (CosmoParams)

  • z_grid (Array | None)

  • n_z (int)

  • m_min (float)

  • m_max (float)

  • n_m (int)

  • delta_crit (float)

classy_szlite.cl_yy_trispectrum(cosmo, profile, ell, z_grid=None, n_z=100, m_min=10000000000.0, m_max=3500000000000000.0, n_m=200, delta_crit=500.0)[source]#

1-halo connected tSZ trispectrum \(T^{1h}(\ell, \ell')\).

Symmetric (n_ell, n_ell) matrix. Used to construct the non-Gaussian part of the bandpower covariance; see cl_yy_covariance().

Same per-call cost as cl_yy() for the cosmology grids, plus an extra O(n_ell² n_z n_m) integral for the trispectrum contraction.

Parameters:
Return type:

Array

classy_szlite.cl_yy_covariance(cosmo, profile, ell, delta_ell, fsky=1.0, include_trispectrum=True, z_grid=None, n_z=100, m_min=10000000000.0, m_max=3500000000000000.0, n_m=200, delta_crit=500.0)[source]#

Bandpower covariance for tSZ \(C_\ell^{yy}\).

\[\mathrm{Cov}(C_\ell, C_{\ell'}) = \frac{2\,C_\ell^2}{(2\ell + 1)\,\Delta\ell\,f_\mathrm{sky}} \,\delta_{\ell\ell'} \;+\; \frac{T^{1h}(\ell, \ell')}{4\pi\,f_\mathrm{sky}}\]

Returns the full \((n_\ell, n_\ell)\) covariance matrix suitable for a Cholesky decomposition to generate synthetic bandpower realisations:

>>> L = jnp.linalg.cholesky(cov)
>>> y_synth = y_fid + L @ jax.random.normal(key, (len(ell),))

The covariance is on the dimensionless \(C_\ell\). If the data vector is in \(D_\ell\times 10^{12}\) units, rescale by the outer product of ell(ell+1)/(2π) × 1e12 before Cholesky.

Parameters:
  • cosmo (as for cl_yy().)

  • profile (as for cl_yy().)

  • ell (as for cl_yy().)

  • delta_ell (float or array_like) – Bandpower width(s) \(\Delta\ell\). Scalar broadcasts to all bins.

  • fsky (float) – Observed sky fraction; the Gaussian variance scales as \(1/f_\mathrm{sky}\) and the trispectrum term as \(1/(4\pi f_\mathrm{sky})\).

  • include_trispectrum (bool) – If False, return Gaussian variance only (diagonal).

  • z_grid (Array | None) – Forwarded to the cosmology / halo-model grid builders.

  • n_z (int) – Forwarded to the cosmology / halo-model grid builders.

  • m_min (float) – Forwarded to the cosmology / halo-model grid builders.

  • m_max (float) – Forwarded to the cosmology / halo-model grid builders.

  • n_m (int) – Forwarded to the cosmology / halo-model grid builders.

  • delta_crit (float) – Forwarded to the cosmology / halo-model grid builders.

Return type:

Array

See the convergence study for the dependence on \(n_z\), \(n_M\), \(M_{\rm min}\), \(M_{\rm max}\), and the Tutorials & examples page for an end-to-end example using cl_yy_covariance to generate synthetic data via Cholesky.

Utility#

classy_szlite.cosmo_to_dict(cosmo)[source]#

Convert CosmoParams to the emulator-style dict (with curly-brace key).

Values pass through as-is (float or jax.Array) so the returned dict is JAX-traceable — pass a CosmoParams of tracers to jax.grad.

Parameters:

cosmo (CosmoParams)

Return type:

dict