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]¶
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 velocitiesvxc, vyc, vzc
of each satellite’s central are not known in advance, these can be computed by knowing thehalo_hostid
of the satellites, as shown in the Examples.- Parameters:
- xs, ys, zsndarrays
Arrays of length (ngals, ) storing the xyz-coordinates of the satellites
- vxs, vys, vzsndarrays
Arrays of length (ngals, ) storing the xyz-velocities of the satellites
- xc, yc, zcndarrays
Arrays of length (ngals, ) storing the xyz-coordinates of the centrals
- vxc, vyc, vzcndarrays
Arrays of length (ngals, ) storing the xyz-velocities of the centrals
- periodfloat 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:
- dradndarray
Array of shape (ngals, ) storing the radial distances
- vradndarray
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)