Skip to main content

A halo mass function calculator

Project description

The halo mass function calculator.

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

hmf is a python application that provides a flexible and simple way to calculate the Halo Mass Function for a range of varying parameters. It is also the backend to HMFcalc, the online HMF calculator.

Full Documentation

Read the docs.

Features

  • Calculate mass functions and related quantities extremely easily.

  • Very simple to start using, but wide-ranging flexibility.

  • Caching system for optimal parameter updates, for efficient iteration over parameter space.

  • Support for all LambdaCDM cosmologies.

  • Focus on flexibility in models. Each “Component”, such as fitting functions, filter functions, growth factor models and transfer function fits are implemented as generic classes that can easily be altered by the user without touching the source code.

  • Focus on simplicity in frameworks. Each “Framework” mixes available “Components” to derive useful quantities – all given as attributes of the Framework.

  • Comprehensive in terms of output quantities: access differential and cumulative mass functions, mass variance, effective spectral index, growth rate, cosmographic functions and more.

  • Comprehensive in terms of implemented Component models:

    • 5+ models of transfer functions including directly from CAMB

    • 4 filter functions

    • 20 hmf fitting functions

  • Includes models for Warm Dark Matter

  • Nonlinear power spectra via HALOFIT

  • Functions for sampling the mass function.

  • CLI scripts for producing any quantity included.

  • Python 2 and 3 compatible

Note

From v3.1, hmf supports Python 3.6+, and has dropped support for Python 2.

Quickstart

Once you have hmf installed, you can quickly generate a mass function by opening an interpreter (e.g. IPython/Jupyter) and doing:

>>> from hmf import MassFunction
>>> hmf = MassFunction()
>>> mass_func = hmf.dndlnm

Note that all parameters have (what I consider reasonable) defaults. In particular, this will return a Tinker (2008) mass function between 10^10 and 10^15 solar masses, at z=0 for the default PLANCK15 cosmology. Nevertheless, there are several parameters which can be input, either cosmological or otherwise. The best way to see these is to do:

>>> MassFunction.parameter_info()

We can also check which parameters have been set in our “default” instance:

>>> hmf.parameter_values

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

>>> hmf = MassFunction()
>>> hmf.update(cosmo_params={"Ob0": 0.05}, z=10) #update baryon density and redshift
>>> cumulative_mass_func = hmf.ngtm

For a more involved introduction to hmf, check out the tutorials, or the API docs.

Using the CLI

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

hmf 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.:

hmf run -- z=1.0 hmf_model='SMT01'

Versioning

From v3.1.0, hmf will be using strict semantic versioning, such that increases in the major version have potential API breaking changes, minor versions introduce new features, and patch versions fix bugs and other non-breaking internal changes.

If your package depends on hmf, set the dependent version like this:

hmf>=3.1<4.0

Attribution

Please cite Murray, Power and Robotham (2013), Murray, Diemer, Chen, et al. (2021) and/or https://ascl.net/1412.006 (whichever is more appropriate) if you find this code useful in your research. Please also consider starring the GitHub repository.

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

hmf-3.4.1.tar.gz (2.1 MB view details)

Uploaded Source

Built Distribution

hmf-3.4.1-py2.py3-none-any.whl (72.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file hmf-3.4.1.tar.gz.

File metadata

  • Download URL: hmf-3.4.1.tar.gz
  • Upload date:
  • Size: 2.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for hmf-3.4.1.tar.gz
Algorithm Hash digest
SHA256 bb8921f1606da131f123688f00268fef89d79818674419d36d158a77694442b1
MD5 5f9e656e6a07a487e57a3bf3d448cd1e
BLAKE2b-256 08cdae6614855bc9800b64d43bd1f9472395ce9f2fa442590a7e5165e88a3f39

See more details on using hashes here.

File details

Details for the file hmf-3.4.1-py2.py3-none-any.whl.

File metadata

  • Download URL: hmf-3.4.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 72.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for hmf-3.4.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 209b15c49a9a972e5c857225d27be30094bed343e5a70d3279e9e328fb376672
MD5 ca5175237867e456398c7d80babd6c8c
BLAKE2b-256 8dd02856cf58eb07bcd7dbd4c56d8f01de6797ec406da2cd4d2db7e0133e7a8b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page