Skip to main content

bihalofit-JAX

JAX implementation of the BiHaloFit nonlinear matter bispectrum (Takahashi et al. 2020), with fully differentiable P(k) backends and GPU support. Documentation: https://bihalofit-jax.readthedocs.io

This package provides support for:

  • The 3D matter bispectrum, $B_\delta(k_1,k_2,k_3,z)$.
  • The Limber-projected angular bispectrum for a tomographic sample. Each triangle leg picks its own projection tracer ('lensing', 'counts' for galaxy clustering, 'cmb_lensing', or 'ia' for intrinsic alignments), so the same function covers cosmic shear, galaxy-galaxy lensing, CMB-lensing cross bispectra and the NLA alignment terms. See notebooks/tutorials/projected_bihalofit_tutorial.ipynb.
  • Third-order aperture-mass statistics. $\langle X_1X_2X_3\rangle(\theta_1,\theta_2,\theta_3)$ from the projected bispectrum. See notebooks/tutorials/aperture_statistics_tutorial.ipynb.
  • Skew spectra. The bispectrum compressed onto a single multipole, cross-correlating one field with a filtered quadratic combination of two others; filters are differentiable JAX pytrees, so band shapes can be optimised. See notebooks/tutorials/skew_spectra_tutorial.ipynb.

Install

pip install bihalofit-jax                 # eh, eh_99 and syren backends
pip install "bihalofit-jax[baccoemu]"     # also the baccoemu backend
pip install -e ".[dev]"                   # from a clone: editable, with the test dependencies

The skew spectra need pyshtools (pip install "bihalofit-jax[skew]"); jax[cuda12] gives GPU support.

Quick start

import numpy as np
import jax
import bihalofit_jax
from bihalofit_jax import Cosmology, make_bihalofit

# Input k vector
k = np.array([0.1, 0.2, 0.3])  # h/Mpc

# Build cosmology
cosmo = Cosmology(omega_cold=0.3156, omega_baryon=0.0492,
                  sigma8_cold=0.831, ns=0.9645, hubble=0.6727)

# Build bihalofit callable
bhf = make_bihalofit(k1=k, k2=k, k3=k, expfactors=np.array([1.0]))
# Call bihalofit for given cosmology
B = bhf(cosmo)

# Evaluating gradients
dB = jax.grad(lambda c: bhf(c).sum())(cosmo)   # Cosmology is a pytree: gradients come back named
dB.sigma8_cold

See notebooks/tutorials/bihalofit_jax_tutorial.ipynb for the full walkthrough, including multiple cosmologies, multiple redshifts and automatic differentiation.

Backends

pk_source Linear P(k) Extra dependency
'syren' (default) Symbolic regression (wCDM + neutrinos) none
'baccoemu' baccoemu neural-network emulator baccoemu
'eh' Eisenstein & Hu 1998 no-wiggle fitting formula none
'eh_99' Eisenstein & Hu 1999 CDM+HDM fitting formula (at fν=0) none

Repository layout

src/                 the package itself
tests/               pytest suite
notebooks/           the four tutorials
docs/                the Sphinx site

Each of them except src/ has its own README.

Citation

If you use this package, please cite the BiHalofit paper

@article{Takahashi2020,
  author  = {Takahashi, Ryuichi and Nishimichi, Takahiro and Namikawa, Toshiya and
             Taruya, Atsushi and Kayo, Issha and Osato, Ken and Kobayashi, Yosuke and
             Shirasaki, Masato},
  title   = {Fitting the nonlinear matter bispectrum by the Halofit approach},
  journal = {The Astrophysical Journal},
  volume  = {895},
  number  = {2},
  pages   = {113},
  year    = {2020},
  doi     = {10.3847/1538-4357/ab908d},
  eprint  = {1911.07886}
}

and the paper for the linear P(k) backend you use: baccoemu (Aricò et al. 2021), syren (Sui et al. 2025), Eisenstein & Hu 1998, or Eisenstein & Hu 1999.

Note that the skew-spectrum implementation follows Andrina Nicola et al.'s bispectrum.

Metadata

Release files for bihalofit-jax 0.1.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 bihalofit-jax 0.1.0
File Size Uploaded Provenance Actions
bihalofit_jax-0.1.0.tar.gz 67.1 kB Without provenance Details for bihalofit_jax-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bihalofit-jax 0.1.0
File Interpreter ABI Platform Actions
bihalofit_jax-0.1.0-py3-none-any.whl Python 3 none any Details for bihalofit_jax-0.1.0-py3-none-any.whl

Total release size: 142.4 kB

Release files / bihalofit_jax-0.1.0.tar.gz

Download URL bihalofit_jax-0.1.0.tar.gz
Size 67.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c64f6caef896f88f626b5b3b08efc31e4ad41518a5dc4abc6b38c7e4577c4fb6
BLAKE2b-256 checksum
How to use checksums
3495c44f7723e8b6f02a31dc58225efd6657ffe64dbfeda94ad999cf56852a22
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.12

Release files / bihalofit_jax-0.1.0-py3-none-any.whl

Download URL bihalofit_jax-0.1.0-py3-none-any.whl
Size 75.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1f3494fddf98a46433f235d3794870850bf64108df5fad8fba80be49b6db97de
BLAKE2b-256 checksum
How to use checksums
d761790557f7bda1194255747d184f1e48387a30635d5a5fb9ff65b20b56fac5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.12

Security for bihalofit-jax 0.1.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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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