radial_distance_and_velocity

halotools.mock_observables.radial_distance_and_velocity(xs, ys, zs, vxs, vys, vzs, xc, yc, zc, vxc, vyc, vzc, period)[source] [edit on github]

Calculate the radial distance between the positions of a set of satellites and their centrals, accounting for periodic boundary conditions.

If the positions xc, yc, zc and velocities vxc, vyc, vzc of each satellite’s central are not known in advance, these can be computed by knowing the halo_hostid of the satellites, as shown in the Examples.

Parameters:

xs, ys, zs : ndarrays

Arrays of length (ngals, ) storing the xyz-coordinates of the satellites

vxs, vys, vzs : ndarrays

Arrays of length (ngals, ) storing the xyz-velocities of the satellites

xc, yc, zc : ndarrays

Arrays of length (ngals, ) storing the xyz-coordinates of the centrals

vxc, vyc, vzc : ndarrays

Arrays of length (ngals, ) storing the xyz-velocities of the centrals

period : float or 3-element sequence

Length of the periodic box in each Cartesian direction. If a single float is given, the box will be assumed to be a periodic cube. If the points are not in a periodic box, set period to np.inf.

Returns:

drad : ndarray

Array of shape (ngals, ) storing the radial distances

vrad : ndarray

Array of shape (ngals, ) storing the radial velocities

Examples

For demonstration purposes we will use a fake halo catalog and compute the radial distances between all the satellites and their host halos.

>>> from halotools.sim_manager import FakeSim
>>> halocat = FakeSim()
>>> satmask = halocat.halo_table['halo_upid'] != -1
>>> satellites = halocat.halo_table[satmask]

Since Halotools catalogs do not come with the host halo position pre-computed, we will need to calculate this information from knowledge of the halo_hostid of each satellite.

>>> from halotools.utils import crossmatch
>>> idxA, idxB = crossmatch(satellites['halo_hostid'], halocat.halo_table['halo_id'])
>>> satellites['halo_x_host_halo'] = np.nan
>>> satellites['halo_y_host_halo'] = np.nan
>>> satellites['halo_z_host_halo'] = np.nan
>>> satellites['halo_vx_host_halo'] = np.nan
>>> satellites['halo_vy_host_halo'] = np.nan
>>> satellites['halo_vz_host_halo'] = np.nan
>>> satellites['halo_x_host_halo'][idxA] = halocat.halo_table['halo_x'][idxB]
>>> satellites['halo_y_host_halo'][idxA] = halocat.halo_table['halo_y'][idxB]
>>> satellites['halo_z_host_halo'][idxA] = halocat.halo_table['halo_z'][idxB]
>>> satellites['halo_vx_host_halo'][idxA] = halocat.halo_table['halo_vx'][idxB]
>>> satellites['halo_vy_host_halo'][idxA] = halocat.halo_table['halo_vy'][idxB]
>>> satellites['halo_vz_host_halo'][idxA] = halocat.halo_table['halo_vz'][idxB]
>>> xs, ys, zs = satellites['halo_x'], satellites['halo_y'], satellites['halo_z']
>>> vxs, vys, vzs = satellites['halo_vx'], satellites['halo_vy'], satellites['halo_vz']
>>> xc, yc, zc = satellites['halo_x_host_halo'], satellites['halo_y_host_halo'], satellites['halo_z_host_halo']
>>> vxc, vyc, vzc = satellites['halo_vx_host_halo'], satellites['halo_vy_host_halo'], satellites['halo_vz_host_halo']
>>> drad, vrad = radial_distance_and_velocity(xs, ys, zs, vxs, vys, vzs, xc, yc, zc, vxc, vyc, vzc, halocat.Lbox)