hmf.core.power_source

Sources of the linear matter power spectrum at z = 0.

MassVariance needs only four things from the power spectrum, which make up the PowerSource protocol. The first three are kernel-level (see hmf.core._kernels): plain floats and arrays in canonical units, for library code.

  • ln_power_kernel(ln_k): the natural log of the linear power spectrum of one matter species at z = 0, with k in h/Mpc. Its amplitude is arbitrary: the normalisation to sigma_8 is a scalar applied later, by LinearPower (the amplitude of the MassFunction built on MassVariance), so only the shape matters and it has no fixed unit. A TabulatedPower gives its table in (Mpc/h)³, while Transfer.power_source’s \(k^{n_s} T(k)^2\) is dimensionless;

  • rho_mean0: the mean comoving density today of CDM + baryons, in M☉ h² / Mpc³ (rho_unit), whatever the species of the power. It converts between a halo’s mass and its Lagrangian radius, \(M = \tfrac{4\pi}{3}\bar\rho_{\rm cb} R^3\): haloes are made of CDM and baryons, as in hmf 3.x and the calibrations of the fits in hmf.core.fits. So the power of total matter and of CDM + baryons give the same R(M);

  • table_range: the TableRange of a table the user supplied, beyond which ln_power_kernel extrapolates, or None if it extrapolates no user table (a fitting formula, a Boltzmann code’s table, or a table that is not extrapolated). ln_power_kernel does not warn: the stage that evaluates it warns, with TableRange.warn_outside();

  • _unit_context: the UnitContext (with its H0) used by the units boundary of the stages built on it (see HasUnitContext). Every implementation must provide it, despite its leading underscore (see PowerSource for why).

Transfer.power_source implements it for the power of a Transfer stage, and TabulatedPower for a power spectrum given as a table.

Extrapolation warnings

Every path that evaluates a user-supplied table outside its range warns through one mechanism, TableRange.warn_outside(): an HMFExtrapolationWarning once per owner (with warn_once()) and end of the table. The owner is the object the table belongs to: the Transfer stage for its public methods, and the power source for MassVariance (which checks the extent of its k grid once) and for TabulatedPower.power(). Extrapolation by design (a Boltzmann code’s tail, the lazy extension of the mass lattice) has no TableRange, so it never warns.

Classes

PowerSource(*args, **kwargs)

A source of the linear matter power spectrum of one species at z = 0.

TableRange(k_min, k_max, where, how[, advice])

The k range of a table the user supplied, beyond which it is extrapolated.

TabulatedPower(*, k, pk, mean_density[, H0, ...])

A linear power spectrum at z = 0, given as a table.