API reference¶
Everything importable from CosmoFit itself is on this page; the
subpackages below carry the rest.
Models¶
Twenty expansion histories written out by hand, and three routes to
one that is not here. Every one is a Cosmology subclass, so
every dataset, likelihood, sampler and plot works on all of them
without knowing which.
Base class for all cosmological models. |
|
Generic container for the parameters shared by every cosmological model implemented in CosmoFit (LCDM, CPL, ...). |
|
The model cannot answer this question at any parameter values. |
|
Flat or curved Lambda-CDM. |
|
Flat or curved wCDM: dark energy with a constant equation of state w0 (does not evolve with redshift; |
|
Chevallier-Polarski-Linder (CPL) dark-energy model. |
|
Jassal-Bagla-Padmanabhan (JBP) dark-energy model. |
|
Barboza-Alcaniz (BA) dark-energy model. |
|
Logarithmic (Efstathiou) dark-energy parametrization, |
|
Phenomenologically Emergent Dark Energy (Li & Shafieloo 2019). |
|
Generalized Emergent Dark Energy (Li & Shafieloo 2020). |
|
Lambda_s CDM (Akarsu et al. 2021): LCDM, except that the cosmological constant changes sign at a redshift |
|
Generalized Chaplygin Gas (GCG). |
|
Interacting Dark Energy: dark matter and dark energy exchange energy, with a coupling |
|
Running Vacuum Model: a cosmological "constant" that runs with the expansion rate, |
|
Modified Polytropic Cardassian expansion (Freese & Lewis 2002; Wang et al. 2003),. |
|
Holographic dark energy with a future-event-horizon cutoff. |
|
New agegraphic dark energy: the holographic cutoff is the age of the universe, in conformal time. |
|
Ricci dark energy: the holographic cutoff is the Ricci scalar. |
|
Dvali-Gabadadze-Porrati braneworld gravity, self-accelerating branch. |
|
f(Q) gravity, exponential model. |
|
f(R,T) gravity, linear model: f(R,T) = R + 2*lambda*T. |
|
f(R) gravity, Hu & Sawicki (2007) model. |
|
Build a new |
|
Same as |
Likelihoods¶
One class per dataset, plus the joint likelihood that combines them. Three of these are tabulated rather than Gaussian – they carry a released likelihood surface instead of a mean and a covariance.
Joint likelihood composed of multiple independent likelihoods. |
|
Combined SDSS BAO-only likelihood: BOSS DR12 (z=0.38, 0.51) + eBOSS DR16 LRG (z=0.698) + eBOSS DR16 QSO (z=1.48), each an independent, non-overlapping-redshift measurement -- see |
|
SDSS BAO + full-shape consensus: |
|
eBOSS DR16 emission-line galaxies, |
|
eBOSS DR16 emission-line galaxies, full shape: the joint likelihood of |
|
eBOSS DR16 Lyman-alpha forest BAO, |
|
The two BAO measurements below z = 0.2: 6dFGS at z = 0.106 (Beutler et al. 2011) and the SDSS DR7 Main Galaxy Sample at z = 0.15 (Ross et al. 2015). |
|
Pantheon+ / Pantheon+SH0ES Supernova likelihood. |
|
DES-SN5YR (Dark Energy Survey 5-year) Supernova likelihood. |
|
Union3 (Rubin et al. 2023): 2087 supernovae compressed into 22 binned distance moduli with a full 22x22 covariance. |
|
Planck 2018 |
|
Planck 2018 lensing-potential bandpowers against a Boltzmann-computed |
|
Planck 2018 low-multipole EE, via its released probability table. |
|
ACT DR6 lensing bandpowers against a Boltzmann-computed |
|
Growth-rate (fsigma8) likelihood, e.g. the "Gold-2018" RSD compilation ( |
|
A single Gaussian S8 = sigma8 * sqrt(Omega_m / 0.3) constraint from a weak-lensing survey (default: KiDS-1000; also DES Y3 -- see |
|
A local distance-ladder H0 measurement. |
|
A BBN constraint on the physical baryon density |
|
The Planck 2018 large-scale-polarization constraint on the reionization optical depth, |
Fitting¶
Ties together a cosmological model, one or more datasets, a prior, and (optionally) an MCMC run and best-fit search. |
|
Interface a sampling backend must implement to be usable by |
|
|
|
Everything a finished (or in-progress) fit produced, in one object: which model/datasets/parameters it is, the best-fit point (if |
|
Maximum-likelihood point, as found by |
|
Posterior summary of an MCMC run, as found by |
Plotting¶
Plotting methods for a |
Saved chains¶
A chain is written as it is sampled, resumed rather than re-sampled next time, and can be reopened months later without loading a single dataset.
An HDF5 file holding one MCMC chain, plus the CosmoFit metadata describing it. |
|
A chain read back from disk, wearing the small part of the |
|
Read a saved chain back for analysis, without a |
|
What's in a chain file -- model, datasets, parameters, how many steps -- without reading the chain itself. |
Datasets¶
Return all available versions of a dataset. |
|
The citation string for a dataset version, without loading any of its files. |
Types¶
The two array types this library’s public surface speaks in.
Every model here takes a redshift and returns a number per redshift, and both ends are deliberately loose about shape: you may pass a Python float, a list, or an array, and what comes back matches.
Spelling that out once is what makes the rest of the annotations
honest. E(0.5) returns np.float64 and E([0.1, 0.2])
returns an ndarray – np.asarray(z, dtype=float) on a scalar
gives a 0-d array, and numpy’s ufuncs turn that back into a scalar on
the way out. Annotating the return as np.ndarray alone would be
wrong for the commonest call in the library.
>>> from CosmoFit.typing import Array, Redshift
>>>
>>> def E(self, z: Redshift) -> Array:
... ...
- CosmoFit.typing.Array = numpy.float64 | NDArray[numpy.float64]
a scalar for a scalar, an array for an array.
- Type:
What comes back
- CosmoFit.typing.PathLike = str | os.PathLike
a string, or anything implementing the os.PathLike protocol (pathlib.Path, most obviously).
- Type:
Anywhere a file is written or read