# mean_los_velocity_vs_rp¶

halotools.mock_observables.mean_los_velocity_vs_rp(sample1, velocities1, rp_bins, pi_max, sample2=None, velocities2=None, period=None, do_auto=True, do_cross=True, num_threads=1, approx_cell1_size=None, approx_cell2_size=None, seed=None)[source] [edit on github]

Calculate the mean pairwise line-of-sight (LOS) velocity as a function of projected separation, $$\bar{v}_{z,12}(r_p)$$.

Example calls to this function appear in the documentation below.

Parameters: sample1 : array_like Npts x 3 numpy array containing 3-D positions of points. velocities1 : array_like N1pts x 3 array containing the 3-D components of the velocities. rp_bins : array_like array of boundaries defining the radial bins perpendicular to the LOS in which pairs are counted. pi_max : float maximum LOS separation sample2 : array_like, optional Npts x 3 array containing 3-D positions of points. velocities2 : array_like, optional N2pts x 3 array containing the 3-D components of the velocities. period : array_like, optional Length-3 array defining periodic boundary conditions. If only one number, Lbox, is specified, period is assumed to be [Lbox, Lbox, Lbox]. do_auto : boolean, optional caclulate the auto-pairwise velocities? do_cross : boolean, optional caclulate the cross-pairwise velocities? num_threads : int, optional number of threads to use in calculation. Default is 1. A string ‘max’ may be used to indicate that the pair counters should use all available cores on the machine. approx_cell1_size : array_like, optional Length-3 array serving as a guess for the optimal manner by how points will be apportioned into subvolumes of the simulation box. The optimum choice unavoidably depends on the specs of your machine. Default choice is to use max(rbins) in each dimension, which will return reasonable result performance for most use-cases. Performance can vary sensitively with this parameter, so it is highly recommended that you experiment with this parameter when carrying out performance-critical calculations. approx_cell2_size : array_like, optional Analogous to approx_cell1_size, but for sample2. See comments for approx_cell1_size for details. seed : int, optional Random number seed used to randomly downsample data, if applicable. Default is None, in which case downsampling will be stochastic. vz_12 : numpy.array len(rbins)-1 length array containing the mean pairwise LOS velocity, $$\bar{v}_{z12}(r)$$, computed in each of the bins defined by rp_bins.

Notes

The pairwise LOS velocity, $$v_{z12}(r)$$, is defined as:

$v_{z12} = |\vec{v}_{\rm 1, pec} \cdot \hat{z}-\vec{v}_{\rm 2, pec}\cdot\hat{z}|$

where $$\vec{v}_{\rm 1, pec}$$ is the peculiar velocity of object 1, and $$\hat{z}$$ is the unit-z vector.

$$\bar{v}_{z12}(r_p)$$ is the mean of this quantity in projected radial bins.

Pairs and radial velocities are calculated using velocity_marked_npairs_xy_z.

Examples

For demonstration purposes we will work with halos in the FakeSim.

>>> from halotools.sim_manager import FakeSim
>>> halocat = FakeSim()

>>> x = halocat.halo_table['halo_x']
>>> y = halocat.halo_table['halo_y']
>>> z = halocat.halo_table['halo_z']


We transform our x, y, z points into the array shape used by the pair-counter by taking the transpose of the result of numpy.vstack. This boilerplate transformation is used throughout the mock_observables sub-package:

>>> sample1 = np.vstack((x,y,z)).T


We will do the same to get a random set of velocities.

>>> vx = halocat.halo_table['halo_vx']
>>> vy = halocat.halo_table['halo_vy']
>>> vz = halocat.halo_table['halo_vz']
>>> velocities = np.vstack((vx,vy,vz)).T

>>> rp_bins = np.logspace(-2,-1,10)
>>> pi_max = 0.3
>>> vz_12 = mean_los_velocity_vs_rp(sample1, velocities, rp_bins, pi_max, period=halocat.Lbox)