API reference¶
- galsampler.crossmatch.crossmatch(x, y, skip_bounds_checking=False)[source]¶
Finds where the elements of
xappear in the arrayy, including repeats.The elements in x may be repeated, but the elements in y must be unique. The arrays x and y may be only partially overlapping.
Applications of this function involve cross-matching two catalogs which share an ID.
- Parameters:
x (integer array) – Array of integers with possibly repeated entries.
y (integer array) – Array of unique integers.
skip_bounds_checking (bool, optional) – The first step in the crossmatch function is to test that the input arrays satisfy the assumptions of the algorithm (namely that
xandystore integers, and that all values inyare unique). Ifskip_bounds_checkingis set to True, this testing is bypassed and the function evaluates faster. Default is False.
- Returns:
idx_x (integer array) – Integer array used to apply a mask to x such that x[idx_x] = y[idx_y]
y_idx (integer array) – Integer array used to apply a mask to y such that x[idx_x] = y[idx_y]
- galsampler.crossmatch.compute_richness(unique_halo_ids, halo_id_of_galaxies)[source]¶
For every ID in unique_halo_ids, calculate the number of times the ID appears in halo_id_of_galaxies.
- Parameters:
unique_halo_ids (ndarray) – Numpy array of shape (num_halos, ) storing unique integers
halo_id_of_galaxies (ndarray) – Numpy integer array of shape (num_galaxies, ) storing the host ID of each galaxy
- Returns:
richness – Numpy integer array of shape (num_halos, ) storing richness of each host halo
- Return type:
ndarray
Examples
>>> num_hosts = 100 >>> num_sats = int(1e5) >>> unique_halo_ids = np.arange(5, num_hosts + 5) >>> halo_id_of_galaxies = np.random.randint(0, 5000, num_sats) >>> richness = compute_richness(unique_halo_ids, halo_id_of_galaxies)
- galsampler.galmatch.galsample(source_galaxies_host_halo_id, source_halo_ids, target_halo_ids, source_halo_props, target_halo_props)[source]¶
Calculate the indexing array that transfers source galaxies to target halos
- Parameters:
source_galaxies_host_halo_id (ndarray of shape (n_source_gals, )) – Integer array storing the value of the halo ID of the source halo of each source galaxy Each entry in source_galaxies_host_halo_id must appear in source_halo_ids This quantity can be computed via the following function in halotools: halotools.utils.value_added_halo_table_functions.compute_uber_hostid
source_halo_ids (ndarray of shape (n_source_halos, )) –
target_halo_ids (ndarray of shape (n_target_halos, )) –
source_halo_props (sequence of n_props ndarrays) – Sequence of n_props of ndarrays, each with shape (n_source_halos, ) These properties determine the correspondence between source and target halos
target_halo_props (sequence of n_props ndarrays) – Sequence of n_props of ndarrays, each with shape (n_target_halos, ) These properties determine the correspondence between source and target halos
- Returns:
target_gals_selection_indx (ndarray of shape (n_target_gals, )) – Integer array storing values in the range [0, n_source_gals-1]
target_galaxy_target_halo_ids (ndarray of shape (n_target_gals, )) – Integer array storing values appearing in target_halo_ids
target_galaxy_source_halo_ids (ndarray of shape (n_target_gals, )) – Integer array storing values appearing in source_halo_ids