Package: hmf
The halo mass function calculator.hmfis 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 toHMFcalc, the online HMF calculator.Full DocumentationRead the docs.FeaturesCalculate 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 CAMB4 filter functions20 hmf fitting functionsIncludes models for Warm Dark MatterNonlinear power spectra via HALOFITFunctions for sampling the mass function.CLI scripts for producing any quantity included.Python 2 and 3 compatibleNoteFrom v3.1,hmfsupports Python 3.6+, and has dropped support for Python 2.QuickstartOnce you havehmfinstalled, 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.dndlnmNote 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_valuesTo change the parameters (cosmological or otherwise), one should use theupdate()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.ngtmFor a more involved introduction tohmf, check out thetutorials,
or theAPI docs.Using the CLIYou can also runhmffrom the command-line. For basic usage, do:hmf run --helpConfiguration for the run can be specified on the CLI or via a TOML file (recommended).
An example TOML file can be found inexamples/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'VersioningFrom v3.1.0,hmfwill be using strict semantic versioning, such that increases in
themajorversion have potential API breaking changes,minorversions introduce
new features, andpatchversions fix bugs and other non-breaking internal changes.If your package depends onhmf, set the dependent version like this:hmf>=3.1<4.0AttributionPlease citeMurray, Power and Robotham (2013),Murray, Diemer, Chen, et al. (2021)and/orhttps://ascl.net/1412.006(whichever is more appropriate) if you find this
code useful in your research. Please also consider starring the GitHub repository.