Skip to main content
https://github.com/steven-murray/halomod/workflows/Tests/badge.svg https://badge.fury.io/py/halomod.svg https://codecov.io/gh/steven-murray/halomod/branch/master/graph/badge.svg https://img.shields.io/pypi/pyversions/halomod.svg https://img.shields.io/badge/code%20style-black-000000.svg

halomod is a python application that provides a flexible and simple interface for dealing with the Halo Model of Dark Matter Halos, built on hmf.

It also has a full-feature web application at https://thehalomod.app – check it out!

Full Documentation

Read the docs.

Features

  • All the features of hmf (several transfer function models, 15+ HMF fitting functions, efficient caching etc.)

  • Extended components for halo model:

    • 10+ halo bias models, plus scale-dependent bias from Tinker (2005).

    • 3+ basic concentration-mass-redshift relations, including the analytic Bullock (2001) model

    • Several plug-and-play halo-exclusion models (including ng-matched from Tinker+2005).

    • 5+ built-in HOD parametrisations.

    • Many built-in halo profiles, including NFW, generalised NFW, Hernquist etc.

    • Support for WDM models.

  • All basic quantities such as 3D correlations and power spectra, and projected 2PCF.

  • Several derived quantities (eg. effective bias, satellite fraction).

  • All models/components specifically written to be easily extendable.

  • Simple routine for populating a halo catalogue with galaxies via a HOD.

  • CLI script for producing any quantity included.

Usage

halomod can be used interactively (for instance in ipython or a jupyter notebook) or in a script. To use interactively, in ipython do something like the following:

>>> from halomod import HaloModel
>>> hm = HaloModel()  # Construct the object
>>> help(hm)          # Lists many of the available quantities.
>>> galcorr = hm.corr_auto_tracer
>>> bias = hm.bias
>>> ...

All parameters to HaloModel have defaults so none need to be specified. There are quite a few that can be specified however. Check the docstring to see the details. Furthermore, as halomod extends the functionality of hmf, almost all parameters accepted by hmf.MassFunction() can be used (check its docstring).

To change the parameters (cosmological or otherwise), one should use the update() method, if a HaloModel() object already exists. For example

>>> hm.update(rmin=0.1,rmax=1.0,rnum=100) #update scale vector
>>> corr_2h = hm.corr_2h_auto_tracer #The 2-halo term of the galaxy correlation function

Since HaloModel is a sub-class of MassFunction, all the quantities associated with the hmf are also included, so for example

>>> mass_variance = hm.sigma
>>> mass_function = hm.dndm
>>> linear_power = hm.power

Any parameter which defines a model choice (eg. a bias model) is named <component>_model, so for example, the bias model is called bias_model. Every model has an associated parameter called <component>_params, which is a dictionary of parameters to that model. The available choices for this dictionary depend on the model chosen (so that the Sheth-Tormen HMF has a different set of parameters than does the Tinker+2008 model). Within the constructed object, the actual model is instantiated and saved as <component>, so that this object can be accessed, and several internal methods can be called. Some of these are exposed directly by the HaloModel class (eg. one can call hm.n_sat directly, which itself calls a method of the hm.hod component).

Using the CLI

You can also run halomod from the command-line. For basic usage, do:

halomod run --help

Configuration for the run can be specified on the CLI or via a TOML file (recommended). An example TOML file can be found in examples/example_run_config.toml. Any parameter specifiable in the TOML file can alternatively be specified on the commmand line after an isolated double-dash, eg.:

halomod run -- z=1.0 hmf_model='SMT01' bias_model='Tinker10'

Acknowledgments

Thanks to Florian Beutler, Chris Blake and David Palamara who have all contributed significantly to the ideas, implementation and testing of this code.

Some parts of the code have been adapted from, influenced by or tested against:

Along with these, several other private codes have been compared to.

Attribution

Please cite

  1. Murray, Power and Robotham (2013) and/or https://ascl.net/1412.006 (whichever is more appropriate)

  2. Murray, Diemer and Chen (2020)

if you find this code useful in your research. Please also consider starring the GitHub repository.

Metadata

Release files for halomod 2.2.3

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

Source distribution (sdist)

Source distribution for halomod 2.2.3
File Size Uploaded
halomod-2.2.3.tar.gz 24.7 MB Details

Built distribution (wheel)

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

Total release size: 31.6 MB

Release files / halomod-2.2.3.tar.gz

Download URL halomod-2.2.3.tar.gz
Size 24.7 MB
Tags Source
SHA-256 checksum
How to use checksums
570a3d544d10306fc9d1d60d92acb017dabdf0fa278035c3c1cb57231db03463
BLAKE2b-256 checksum
How to use checksums
b78b44f72496fad4d11784eb45cab25ee9e5112c17ee64d4020bf57d430df571
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 3, 2026.

Transparency log

Release files / halomod-2.2.3-py3-none-any.whl

Download URL halomod-2.2.3-py3-none-any.whl
Size 6.9 MB
Tags Python 3
SHA-256 checksum
How to use checksums
c3c8023f3f13b28a2f5eb2269c4571d939f308a969ce67d9c2bd12b2bb66c677
BLAKE2b-256 checksum
How to use checksums
a44773ca5c729a07e2e93010fb99ae6582fb67a1edcd2a3a13e1d83e2231d007
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 3, 2026.

Transparency log
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