Skip to main content

CosmoWAP

   ______                         _       _____    ____
  / ____/___  _________ ___  ____| |     / /   |  / __ \
 / /   / __ \/ ___/ __ `__ \/ __ \ | /| / / /| | / /_/ /
/ /___/ /_/ (__  ) / / / / / /_/ / |/ |/ / ___ |/ ____/
\____/\____/____/_/ /_/ /_/\____/|__/|__/_/  |_/_/

PyPI version Tests Licence Docs Codacy Badge ASCL PyPI Downloads Ruff

Cosmology with Wide-separation, relAtivistic and Primordial non-Gaussian contributions.

CosmoWAP is a project that has grown organically alongside several research works, taking an increasingly central role in their development. It is designed to be a flexible and user-friendly Python framework to enable quick and easy forecasts of large-scale galaxy clustering using 3D power spectrum and/or bispectrum multipoles.

The modelling covers several key areas: relativistic effects, wide-separation corrections, and Primordial non-Gaussianity (PNG) in standard perturbation theory. The signal is built numerically from the redshift-space kernels of each field and projected onto multipoles, while analytic expressions derived in Mathematica (see MathWAP) and exported as .py files supply the wide-separation corrections and a check on the kernels. Both ingest a cosmology (via CLASS) and a flexible set of bias models, and have been thoroughly validated with sanity checks and against existing literature results.

To enable realistic forecasts, the associated machinery has been built around the core: thorough bias modelling with HOD/luminosity functions, theoretical covariances, Fisher matrices, and MCMC modules. These tools are easily accessible and can be used flexibly for a wide range of survey scenarios.

Documentation

Installation

pip install cosmowap

For Development mode...

Clone repository:

git clone https://github.com/craddis1/CosmoWAP.git

and then make an editable install with the dev tools (pytest, ruff, pre-commit):

cd CosmoWAP
pip install -e ".[dev]"
pre-commit install

See pyproject.toml's dependencies for full list of dependencies (most are common python libraries). classy (CLASS python wrapper) is necessary to fully use CosmoWAP.

Quick start

import numpy as np
import cosmo_wap as cw
from cosmo_wap.lib import utils
from cosmo_wap.forecast import FullForecast

cosmo = utils.get_cosmo()  # CLASS, Planck 2018 by default
cosmo_funcs = cw.ClassWAP(cosmo, cw.SurveyParams.Euclid(cosmo))

# Newtonian + local relativistic signal, with wide-separation corrections
m = cw.Model(cosmo_funcs, kernels=['N', 'LP'], wide_separation=True)

k = np.linspace(0.005, 0.2, 100)
P_l = m.pk(k, l=[0, 1, 2], zz=1.0)                       # power spectrum multipoles
xi_l = m.xi(np.linspace(10, 200, 39), l=[0, 2], zz=1.0)  # correlation function multipoles
B_lm = m.bk(0.1, 0.08, 0.05, l=[0, 1, (2, 1)], zz=1.0)   # bispectrum (l, m) multipoles

# Fisher forecast on local fNL from P_0 and P_2 over 4 redshift bins
forecast = FullForecast(cosmo_funcs, kmax_func=0.15, N_bins=4)
fisher = forecast.get_fish(["fNL", "A_s", "n_s"], kernels=["N", "Loc"], pkln=[0, 2])
print(fisher.errors)

See Getting started and the notebooks in examples/ for more.

Features

Core Observables

3D redshift space statistics: Multipoles and full line-of-sight (LOS) dependent expressions (fully multi-tracer compatible).

  • $P_{\ell}(k)$: Legendre Power spectrum multipoles - and correlation function multipoles $\xi_{\ell}(r)$ via Hankel transforms.
  • $B_{\ell,m}(k_1,k_2,k_3)$: Scoccimarro Bispectrum multipoles, all $m$ up to $\ell=4$ (TriPosH extension planned).
  • Survey window: Window-convolved multipoles from a window matrix, with wide-angle orders and integral constraints.

Physical Contributions

  • Wide-separation (WS) corrections: Wide-angle and radial redshift contributions up to second order in the WS expansion.
  • Local Relativistic (GR) effects: Dynamical and projection effects that arise beyond the Kaiser term.
  • Integrated effects: Lensing, ISW, and time delay contributions for the power spectrum (bispectrum planned).
  • Primordial non-Gaussianity (PNG): Contributions for local, equilateral, and orthogonal types — uses peak background split approach for biases.
  • Non-linearities: Finger-of-God damping and non-linear HaloFit/HMcode $P(k)$.

Forecasting and Analysis

  • Bias modelling: Uses a range of literature Luminosity Functions, HOD/HMF and peak-background split approach for different surveys - with built-in Euclid, Roman, DESI BGS, MegaMapper, SKAO and SPHEREx setups.
  • Multi-tracer covariances: Multipole covariances for power spectrum and bispectrum - including non-gaussian, wide-separation and integrated corrections.
  • Forecasting modules: Fisher matrices and MCMC capabilities through Cobaya and emulated $P(k)$ with CosmoPower.
  • Acceleration: numba-jitted hot paths, plus optional compiled C bispectrum kernels and cached tables for MCMC - see Performance.
  • Built-in plotting library: Designed for exploring theoretical expressions, covariances and forecasts — plots of parameter posteriors implemented with ChainConsumer.

Citation

If you use CosmoWAP in your research, please cite the relevant papers (BibTeX on the citation page):

  • Original code: arXiv:2407.00168
  • Integrated effects in the power spectrum and forecasting routines: arXiv:2511.09466
  • PNG, HODs and forecasting routines: arXiv:26xx.xxxx

If you find CosmoWAP useful, a star on GitHub helps other people find it.

Contributing

Contributions are welcome - please open an issue first for anything substantial. LLM-assisted contributions are fine as long as the physics and implementation is understood (coding agents should read AGENTS.md).

LLM Usage

The vast majority is written by myself over the process of several years but LLMs have increasingly been used for formatting, bug fixing, tests, optimisation, adding additional features, documentation and docstrings. However, I retain full editorial control and oversight.

Licence

MIT - see LICENSE.txt.

Contact

If you find any bugs or errors or have any questions and suggestions feel free to get in touch :) - c.l.j.addis@qmul.ac.uk

Metadata

Release files for cosmowap 0.10.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cosmowap 0.10.0
File Size Uploaded Provenance Actions
cosmowap-0.10.0.tar.gz 11.0 MB Without provenance Details for cosmowap-0.10.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cosmowap 0.10.0
File Interpreter ABI Platform Actions
cosmowap-0.10.0-py3-none-any.whl Python 3 none any Details for cosmowap-0.10.0-py3-none-any.whl

Total release size: 22.1 MB

Release files / cosmowap-0.10.0.tar.gz

Download URL cosmowap-0.10.0.tar.gz
Size 11.0 MB
Tags Source
SHA-256 checksum
How to use checksums
2c0bd7fbe8e8b121e1692125f40ab78858a048faa012c20223221ea9143f2c24
BLAKE2b-256 checksum
How to use checksums
338f7ff914c480c42965b005b216d80e8a601d5386efc53667b33d3a6a17de91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / cosmowap-0.10.0-py3-none-any.whl

Download URL cosmowap-0.10.0-py3-none-any.whl
Size 11.1 MB
Tags Python 3
SHA-256 checksum
How to use checksums
4d0e328931b3bf1a2e50b08efbe4aec1effea731c85c16554ffd6dc91c4cabbc
BLAKE2b-256 checksum
How to use checksums
bbb97c02735dfd1c84d07cd8239edf68421e4854f346f64d9ccfa02fed9ffa46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Security for cosmowap 0.10.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page