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

Determine the halo property in haloprop_halos for each galaxy. This crossmatches the galaxy catalog with the halo catalog using their halo_id. Return the halo property for galaxies with a match, else nan.


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


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.


Array of shape (num_halos, ) storing the halo property of interest, e.g., halo_vpeak or halo_spin.


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


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
>>> from halotools.mock_observables import get_haloprop_of_galaxies
>>> 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.