get_haloprop_of_galaxies

halotools.mock_observables.get_haloprop_of_galaxies(halo_id_galaxies, halo_id_halos, haloprop_halos)[source] [edit on github]

Calculate the host halo property of every galaxy with a halo_id that matches one of the input halos. This function can be used, for example, to calculate the host halo mass of a galaxy.

Parameters:

halo_id_galaxies : ndarray

Integer array of shape (num_galaxies, ) storing the halo_id that each galaxy belongs to.

halo_id_halos : ndarray

Integer array of shape (num_halos, ) storing the halo_id of every host halo in the entire halo catalog used to populate the mock. Repeated entries are not permissible, but halos with zero or multiple galaxies are accepted.

haloprop_halos : ndarray

Array of shape (num_halos, ) storing the halo property of interest, e.g., halo_mvir.

Returns:

haloprop_galaxies : ndarray

Array of shape (num_galaxies, ) storing the property of the halo that each galaxy belongs to. Galaxies with no matching halo will receive value of nan

Examples

When you populate a mock catalog, the host halo mass of every galaxy is automatically included in the galaxy_table. However, you may wish to know other halo properties for each mock galaxy, such as the spin of the halo the galaxy lives in. The code below demonstrates how to use the get_haloprop_of_galaxies function to do this.

>>> from halotools.empirical_models import PrebuiltHodModelFactory
>>> from halotools.sim_manager import FakeSim
>>> model = PrebuiltHodModelFactory('leauthaud11')
>>> halocat = FakeSim()
>>> model.populate_mock(halocat)
>>> halo_id_halos = halocat.halo_table['halo_id']
>>> halo_id_galaxies = model.mock.galaxy_table['halo_id']
>>> haloprop_halos = halocat.halo_table['halo_spin']
>>> halo_spin_galaxies = get_haloprop_of_galaxies(halo_id_galaxies, halo_id_halos, haloprop_halos)
>>> model.mock.galaxy_table['halo_spin'] = halo_spin_galaxies

Note that we needed to use the original halo catalog to retrieve the halo_spin of the halos; in order to save memory, the version of the halo_table that is bound to model.mock has a restricted subset of columns.