Warning
This is the state of the documentation before this module was moved to the attic. It is likely that code examples shown here do not work as advertised. If you would like to take on any code, you are welcome to its documentation.
The Halo Mass Function extension is capable of outputting the halo mass function for a collection halos (input), and/or an analytical fit over a given mass range for a set of specified cosmological parameters. This extension is based on code generously provided by Brian O’Shea.
A halo mass function can be created for the halos identified in a cosmological simulation, as well as analytic fits using any arbitrary set of cosmological parameters. In order to create a mass function for simulated halos, they must first be identified using a halo finder and loaded as a halo dataset object. The distribution of halo masses will then be found, and can be compared to the analytic prediction at the same redshift and using the same cosmological parameters as were used in the simulation. Care should be taken in this regard, as the analytic fit requires the specification of cosmological parameters that are not necessarily stored in the halo or simulation datasets, and must be specified by the user. Efforts have been made to set reasonable defaults for these parameters, but setting them to identically match those used in the simulation will produce a much better comparison.
Analytic halo mass functions can also be created without a halo dataset by providing either a simulation dataset or specifying cosmological parameters by hand. yt includes 5 analytic fits for the halo mass function which can be selected.
There are five analytical fits to choose from.
We encourage reading each of the primary sources.
In general, we recommend the Warren fitting function because it matches
simulations over a wide range of masses very well.
The Warren fitting function is the default (equivalent to not specifying
fitting_function
in HaloMassFcn()
, below).
The Tinker fit is for the \(\Delta=300\) fits given in the paper, which
appears to fit HOP threshold=80.0 fairly well.
The simplest way to create a halo mass function object is to simply pass it no arguments and let it use the default cosmological parameters.
from yt.analysis_modules.halo_mass_function.api import *
hmf = HaloMassFcn()
This will create a HaloMassFcn object off of which arrays holding the information about the analytic mass function hang. Creating the halo mass function for a set of simulated halos requires only the loaded halo dataset to be passed as an argument. This also creates the analytic mass function using all parameters that can be extracted from the halo dataset, at the same redshift, spanning a similar range of halo masses.
from yt.mods import *
from yt.analysis_modules.halo_mass_function.api import *
my_halos = load("rockstar_halos/halos_0.0.bin")
hmf = HaloMassFcn(halos_ds=my_halos)
A simulation dataset can be passed along with additional cosmological parameters to create an analytic mass function.
from yt.mods import *
from yt.analysis_modules.halo_mass_function.api import *
my_ds = load("RD0027/RedshiftOutput0027")
hmf = HaloMassFcn(simulation_ds=my_ds, omega_baryon0=0.05, primordial_index=0.96,
sigma8 = 0.8, log_mass_min=5, log_mass_max=9)
The analytic mass function can be created for a set of arbitrary cosmological parameters without any dataset being passed as an argument.
from yt.mods import *
from yt.analysis_modules.halo_mass_function.api import *
hmf = HaloMassFcn(omega_baryon0=0.05, omega_matter0=0.27,
omega_lambda0=0.73, hubble0=0.7, this_redshift=10,
log_mass_min=5, log_mass_max=9, fitting_function=5)
A HaloMassFnc object has several arrays hanging off of it containing the
After the mass function has been created for both simulated halos and the corresponding analytic fits, they can be plotted though something along the lines of
import yt
from yt.analysis_modules.halo_mass_function.api import *
import matplotlib.pyplot as plt
my_halos = yt.load("rockstar_halos/halos_0.0.bin")
hmf = HaloMassFcn(halos_ds=my_halos)
plt.loglog(hmf.masses_sim, hmf.n_cumulative_sim)
plt.loglog(hmf.masses_analytic, hmf.n_cumulative_analytic)
Attached to hmf
is the convenience function write_out
, which saves the
halo mass function to a text file. (continued from above)
.. code-block:: python
hmf.write_out(prefix=’hmf’, analytic=True, simulated=True)
This writes the files hmf-analytic.dat
with columns:
and the file hmf-simulated.dat
with columns: