# yt.analysis_modules.halo_mass_function.halo_mass_function module¶

Halo Mass Function and supporting functions.

class yt.analysis_modules.halo_mass_function.halo_mass_function.HaloMassFcn(simulation_ds=None, halos_ds=None, make_analytic=True, omega_matter0=0.2726, omega_lambda0=0.7274, omega_baryon0=0.0456, hubble0=0.704, sigma8=0.86, primordial_index=1.0, this_redshift=0, log_mass_min=None, log_mass_max=None, num_sigma_bins=360, fitting_function=4)[source]

Bases: object

Initalize a HaloMassFcn object to analyze the distribution of halos as a function of mass. A mass function can be created for a set of simulated halos, an analytic fit to can be created for a redshift and set of cosmological parameters, or both can be created.

Provided with a halo dataset object, this will make a the mass function for simulated halos. Prodiving a simulation dataset will set as many of the cosmological parameters as possible for the creation of the analytic mass function.

The HaloMassFcn object has arrays hanging off of it containing the mass function information.

masses_sim : Array
Halo masses from simulated halos. Units: M_solar.
n_cumulative_sim : Array
Number density of halos with mass greater than the corresponding mass in masses_sim (simulated). Units: comoving Mpc^-3
masses_analytic : Array
Masses used for the generation of the analytic mass function, Units: M_solar.
n_cumulative_analytic : Array
Number density of halos with mass greater then the corresponding mass in masses_analytic (analytic). Units: comoving Mpc^-3
dndM_dM_analytic : Array
Differential number density of halos, (dn/dM)*dM (analytic).

The HaloMassFcn object also has a convenience function write_out() that will write out the data to disk.

Creating a HaloMassFcn object with no arguments will produce an analytic mass function at redshift = 0 using default cosmolocigal values.

Parameters: simulation_ds (Simulation dataset object) – The loaded simulation dataset, used to set cosmological paramters. Default : None. halos_ds (Halo dataset object) – The halos from a simulation to be used for creation of the halo mass function in the simulation. Default : None. make_analytic (bool) – Whether or not to calculate the analytic mass function to go with the simulated halo mass function. Automatically set to true if a simulation dataset is provided. Default : True. omega_matter0 (float) – The fraction of the universe made up of matter (dark and baryonic). Default : 0.2726. omega_lambda0 (float) – The fraction of the universe made up of dark energy. Default : 0.7274. omega_baryon0 (float) – The fraction of the universe made up of baryonic matter. This is not always stored in the datset and should be checked by hand. Default : 0.0456. hubble0 (float) – The expansion rate of the universe in units of 100 km/s/Mpc. Default : 0.704. sigma8 (float) – The amplitude of the linear power spectrum at z=0 as specified by the rms amplitude of mass-fluctuations in a top-hat sphere of radius 8 Mpc/h. This is not always stored in the datset and should be checked by hand. Default : 0.86. primoridal_index (float) – This is the index of the mass power spectrum before modification by the transfer function. A value of 1 corresponds to the scale-free primordial spectrum. This is not always stored in the datset and should be checked by hand. Default : 1.0. this_redshift (float) – The current redshift. Default : 0. log_mass_min (float) – The log10 of the mass of the minimum of the halo mass range. This is set automatically by the range of halo masses if a simulated halo dataset is provided. If a halo dataset if not provided and no value is specified, it will be set to 5. Units: M_solar Default : None. log_mass_max (float) – The log10 of the mass of the maximum of the halo mass range. This is set automatically by the range of halo masses if a simulated halo dataset is provided. If a halo dataset if not provided and no value is specified, it will be set to 16. Units: M_solar Default : None. num_sigma_bins (float) – The number of bins (points) to use for the calculation of the analytic mass function. Default : 360. fitting_function (int) – Which fitting function to use. 1 = Press-Schechter, 2 = Jenkins, 3 = Sheth-Tormen, 4 = Warren, 5 = Tinker Default : 4.

Examples

This creates the halo mass function for a halo dataset from a simulation and the analytic mass function at the same redshift as the dataset, using as many cosmological parameters as can be pulled from the dataset.

>>> halos_ds = load("rockstar_halos/halo_0.0.bin")
>>> hmf = HaloMassFcn(halos_ds=halos_ds)
>>> plt.loglog(hmf.masses_sim, hmf.n_cumulative_sim)
>>> plt.loglog(hmf.masses_analytic, hmf.n_cumulative_analytic)
>>> plt.savefig("mass_function.png")


This creates only the analytic halo mass function for a simulation dataset, with default values for cosmological paramters not stored in the dataset.

>>> ds = load("enzo_tiny_cosmology/DD0046/DD0046")
>>> hmf = HaloMassFcn(simulation_ds=ds)
>>> plt.loglog(hmf.masses_analytic, hmf.n_cumulative_analytic)
>>> plt.savefig("mass_function.png")


This creates the analytic mass function for an arbitrary set of cosmological parameters, with neither a simulation nor halo dataset.

>>> 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)
>>> plt.loglog(hmf.masses_analytic, hmf.n_cumulative_analytic)
>>> plt.savefig("mass_function.png")

Dofz(redshift)[source]

Growth function

Eofz(redshift)[source]

E(z) - I don’t think this has any other name

PofK(k)[source]

returns power spectrum as a function of wavenumber k

TofK(k)[source]

returns transfer function as a function of wavenumber k.

WofK(R, k)[source]

returns W(k), which is the fourier transform of the top-hat function.

create_sim_hmf()[source]
dndm()[source]
gofz(redshift)[source]

g(z) - I don’t think this has any other name

make_simulated = None

If we want to make an analytic mass function, grab what we can from either the halo file or the data set, and make sure that the user supplied everything else that is needed.

multiplicityfunction(sigma)[source]

Multiplicity function - this is where the various fitting functions/analytic theories are different. The various places where I found these fitting functions are listed below.

omega_lambda_of_z(redshift)[source]

Omega lambda as a function of redshift

omega_matter_of_z(redshift)[source]

Omega matter as a function of redshift

set_mass_from_halos(which_limit)[source]
sigmaM()[source]

Written by BWO, 2006 (updated 25 January 2007). Converted to Python by Stephen Skory December 2009.

This routine takes in cosmological parameters and creates a file (array) with sigma(M) in it, which is necessary for various press-schechter type stuff. In principle one can calculate it ahead of time, but it’s far, far faster in the long run to calculate your sigma(M) ahead of time.

Inputs: cosmology, user must set parameters

Outputs: four columns of data containing the following information:

1. mass (Msolar/h)
2. sigma (normalized) using Msun/h as the input

The arrays output are used later.

sigma_squared_integrand(k)[source]

integrand for integral to get sigma^2(R).

sigma_squared_of_R(R)[source]

calculates sigma^2(R). This is the routine where the magic happens (or whatever it is that we do here). Integrates the sigma_squared_integrand parameter from R to infinity. Calls GSL (gnu scientific library) to do the actual integration.

Note that R is in h^-1 Mpc (comoving)

sigmaof_M_z(sigmabin, redshift)[source]

sigma(M, z)

write_out(prefix='HMF', analytic=True, simulated=True)[source]

Writes out the halo mass functions to file(s) with prefix prefix.

yt.analysis_modules.halo_mass_function.halo_mass_function.SQR(a)[source]
class yt.analysis_modules.halo_mass_function.halo_mass_function.TransferFunction(omega_matter, omega_baryon, omega_hdm, degen_hdm, omega_lambda, hubble, redshift)[source]

Bases: object

This routine takes cosmological parameters and a redshift and sets up all the internal scalar quantities needed to compute the transfer function.

Parameters: omega_matter (float) – Density of CDM, baryons, and massive neutrinos, in units of the critical density. omega_baryon (float) – Density of baryons, in units of critical. omega_hdm (float) – Density of massive neutrinos, in units of critical degen_hdm (integer) – Number of degenerate massive neutrino species omega_lambda (float) – Cosmological constant hubble (float) – Hubble constant, in units of 100 km/s/Mpc redshift (float) – The redshift at which to evaluate 0 if all is well, 1 if a warning was issued. Otherwise, (Returns) – many global variables for use in TFmdm_onek_mpc() (sets) –
TFmdm_onek_hmpc(kk)[source]

Given a wavenumber in h Mpc^-1, return the transfer function for the cosmology held in the global variables.

Parameters: kk (float) – Wavenumber in h Mpc^-1 growth_cb (float) – the transfer function for density-weighted CDM + Baryon perturbations. (return and set as a global var) growth_cbnu (float) – the transfer function for density-weighted CDM + Baryon + Massive Neutrino perturbations.
TFmdm_onek_mpc(kk)[source]

Given a wavenumber in Mpc^-1, return the transfer function for the cosmology held in the global variables.

Parameters: kk (float) – Wavenumber in Mpc^-1 growth_cb (float) – the transfer function for density-weighted CDM + Baryon perturbations. (returned and set as a global var) growth_cbnu (float) – the transfer function for density-weighted CDM + Baryon + Massive Neutrino perturbations. (set as a global var)
yt.analysis_modules.halo_mass_function.halo_mass_function.integrate_inf(fcn, error=0.001, initial_guess=10)[source]

Integrate a function fcn from zero to infinity, stopping when the answer changes by less than error. Hopefully someday we can do something better than this!