hmf

hmf is a python application that provides a flexible and simple way to calculate the Halo Mass Function for any input cosmology, redshift, dark matter model, virial overdensity or several other variables. Addition of further variables should be simple.

It is also the backend to HMFcalc, the online HMF calculator.

Installation

hmf is built on several other packages, most of which will be familiar to the scientific python programmer. All of these dependencies should be automatically installed when installing hmf, except for one. Explicitly, the dependencies are numpy, scipy, scitools, cosmolopy and emcee.

You will only need emcee if you are going to be using the fitting capabilities of hmf. The final, optional, library is pycamb, which can not be installed using pip currently. To install pycamb:

cd <Directory that pycamb source will live in>
git clone https://github.com/steven-murray/pycamb
cd pycamb
[sudo] python setup.py install [--get=www.address-where-camb-code-lives.org]

The final command gives the option of automatically downloading and compiling CAMB while installing pycamb. It cannot be done more automatically at this point due to licensing. Alternatively, if one does not know the location of the camb downloads, go to camb.info and follow the instructions. Download the source directory to your pycamb folder, and untar it there. Then use ``python setup.py install” and it should work.

Note

At present, versions of CAMB post March 2013 are not working with pycamb. Please use earlier versions until further notice.

Finally the hmf package needs to be installed: pip install hmf. If you want to install the latest build (not necessarily stable), grab it here.

Basic Usage

hmf can be used interactively (for instance in ipython) or in a script and is called like this:

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

This will return a Sheth-Mo-Tormen (2001) mass function between \(10^{10}-10^{15} M_\odot\), at \(z=0\) for the default PLANCK cosmology. Cosmological parameters may be passed to the initialiser, MassFunction()

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(omegab = 0.05,z=10) #update baryon density and redshift
>>> cumulative_mass_func = hmf.ngtm

Note

Older versions of hmf used the class called Perturbations() rather than MassFunction().

Please check the more in-depth user-guide for more details, or even the API documentation.

User Guide

Look here for more details concerning the usage in general.

Indices and tables