HOD galaxy clustering and weak lensing prediction and fitting
Project description
hod_mod
JAX-accelerated HOD galaxy clustering and weak lensing predictions and fitting.
Overview
hod_mod is a Python 3.11+ package for forward-modelling galaxy clustering (w_p)
and weak gravitational lensing (ΔΣ) from Halo Occupation Distribution (HOD) and
inverse-SHMR (ICSMF) models. All numerical code is JAX-native, enabling
automatic differentiation and JIT compilation for efficient MCMC inference.
Install
Create and activate the conda environment, then install the package in editable mode:
mamba env create -f environment.yml
mamba activate hod_mod
pip install -e .
Tests
pytest # run all tests
pytest tests/test_cosmology.py # single module
pytest -x # stop on first failure
pytest -v # verbose output
pytest --tb=short # compact tracebacks
The test suite covers cosmology, HOD models, clustering predictions, data I/O, and fitting. Tests that require optional backends (camb, colossus) are skipped automatically if those packages are absent.
Supported HOD models
| Class | Reference |
|---|---|
HODModel |
Zheng et al. 2007 |
MoreHODModel |
More et al. 2015 (BOSS CMASS) |
Kravtsov04HODModel |
Kravtsov et al. 2004 |
Guo18ICSMFModel |
Guo et al. 2018 |
Guo19ICSMFModel |
Guo et al. 2019 (eBOSS ELGs) |
Zacharegkas25HODModel |
Zacharegkas et al. 2025 |
VanUitert16CSMFModel |
van Uitert et al. 2016 |
ZuMandelbaum15HODModel |
Zu & Mandelbaum 2015 (iHOD) |
ZuMandelbaum16QuenchingModel |
Zu & Mandelbaum 2016 |
Leauthaud12HODModel |
Leauthaud et al. 2012 |
All clustering HOD classes subclass HODBase (ABC) and implement nc_ns() and
default_params().
Quick start
import hod_mod
from hod_mod.cosmology.power_spectrum import LinearPowerSpectrum
from hod_mod.cosmology.halo_mass_function import make_hmf
from hod_mod.cosmology.halo_profiles import HaloProfile
from hod_mod.galaxies import MoreHODModel, FullHaloModelPrediction
import jax.numpy as jnp
pk_lin = LinearPowerSpectrum()
theta = pk_lin.default_cosmology()
hmf = make_hmf("tinker08", pk_func=pk_lin.pk_linear)
colossus_cosmo = dict(flat=True, H0=67.36, Om0=0.31, Ob0=0.0493, sigma8=0.811, ns=0.965)
hp = HaloProfile(colossus_cosmo, cm_relation="diemer19")
hod = MoreHODModel(hmf, hmf.bias)
pred = FullHaloModelPrediction(pk_lin, hod, hp, profile="nfw")
rp = jnp.logspace(-1, 1.5, 20)
params = MoreHODModel.default_params()
wp = pred.wp(rp, pi_max=60.0, z=0.5, theta_cosmo=theta, hod_params=params)
HOD fitting
Run from the repository root (paths in configs are resolved relative to it):
from hod_mod.fitting import load_config, WpFitter
cfg = load_config("configs/hod_fit_more2015_cmass.yml")
fitter = WpFitter(cfg)
result = fitter.map_fit() # Nelder-Mead MAP → dict
sampler = fitter.sample() # emcee MCMC → EnsembleSampler
chain = sampler.get_chain(flat=True) # shape (n_steps * n_walkers, n_free)
The sample data file data/more2015_boss_cmass/wp_cmass_z052.csv is included in the repository (More+2015, arXiv:1407.1856, Figure 2).
Citation
If you use hod_mod in published work please cite the papers for the HOD models
you use (see table above) and include a reference to this package.
License
MIT — see LICENSE.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hod_mod-0.0.1.tar.gz.
File metadata
- Download URL: hod_mod-0.0.1.tar.gz
- Upload date:
- Size: 217.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36a3488d98b7300da312c6fb7a2744a1ffc83356dbbab58fac9088eb943f5e0b
|
|
| MD5 |
60819b78eebf8e8c40735c9a6ecd3972
|
|
| BLAKE2b-256 |
91f232ff7cec0248ac1a8875391b5fc82da5822f4e2b03e046af36eba3cfc78c
|
File details
Details for the file hod_mod-0.0.1-py3-none-any.whl.
File metadata
- Download URL: hod_mod-0.0.1-py3-none-any.whl
- Upload date:
- Size: 215.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
047e5bc46f0b1f441b3061d0434ac2ad2e8d08f032f328175a7ac5faa3631495
|
|
| MD5 |
e2cadc06bf882ce064787e8f520fea58
|
|
| BLAKE2b-256 |
ecc6d09d51f8bf9ac9f35708aed07f93625fdd48533ed54ecdd46c6a187d70ec
|