hod_from_mock¶
- halotools.mock_observables.hod_from_mock(haloprop_galaxies, haloprop_halos, haloprop_bins=None)[source]¶
Calculate the HOD of a mock galaxy sample. It returns the expected number of galaxies per halo, in bins of whatever halo property
haloprop_galaxies
andhaloprop_halos
are given in.- Parameters:
- haloprop_galaxiesndarray
Array of shape (num_galaxies, ) used to bin the galaxies according to the property of their host halo, e.g., host halo mass.
If this quantity is not readily available in the mock galaxy catalog, the
get_haloprop_of_galaxies
function can be used to calculate it.- haloprop_halosndarray
Array of shape (num_halos, ) used to bin the halos in the same manner as the galaxies so that the counts in each bin can be properly normalized.
Note that this property (e.g. halo mass) must be the same as used for
haloprop_halos
.- haloprop_binsndarray, optional
Array defining the bin edges. If None, this defaults to 10 linearly spaced bins and so you will probably obtain better results if you pass in logarithmic quantities for the
haloprop_galaxies
andhaloprop_halos
arrays.
- Returns:
- mean_occupationndarray
Array of shape (num_bins-1, ) storing the mean occupation of the input galaxy sample as a function of the input halo property.
- bin_edgesndarray
Array of shape (num_bins, ) storing the bin edges used in the calculation.
Examples
In the following calculation, we’ll populate a mock catalog and then manually compute the central galaxy HOD (number of central galaxies above the mass threshold as a function of halo mass) from the
galaxy_table
.>>> from halotools.empirical_models import PrebuiltHodModelFactory >>> from halotools.sim_manager import FakeSim >>> from halotools.mock_observables import hod_from_mock >>> model = PrebuiltHodModelFactory('leauthaud11', threshold=10.75) >>> halocat = FakeSim() >>> model.populate_mock(halocat)
Now compute \(\langle N_{\rm cen} \rangle(M_{\rm vir})\):
>>> cenmask = model.mock.galaxy_table['gal_type'] == 'centrals' >>> central_host_mass = model.mock.galaxy_table['halo_mvir'][cenmask] >>> halo_mass = model.mock.halo_table['halo_mvir'] >>> haloprop_bins = np.logspace(11, 15, 15) >>> mean_ncen, bin_edges = hod_from_mock(central_host_mass, halo_mass, haloprop_bins)