return_xyz_formatted_array

halotools.mock_observables.return_xyz_formatted_array(x, y, z, period=inf, cosmology=FlatLambdaCDM(name='WMAP5', H0=<Quantity 70.2 km / (Mpc s)>, Om0=0.277, Tcmb0=<Quantity 2.725 K>, Neff=3.04, m_nu=<Quantity [0., 0., 0.] eV>, Ob0=0.0459), redshift=0.0, **kwargs)[source]

Returns a Numpy array of shape (Npts, 3) storing the xyz-positions in the format used throughout the mock_observables package, optionally applying redshift-space distortions according to the input velocity, redshift and cosmology.

See Formatting your xyz coordinates for Mock Observables calculations for a tutorial.

Parameters:
x, y, zsequence of length-Npts arrays

Comoving units of Mpc assuming h=1, as throughout Halotools.

velocityarray, optional

Length-Npts array of velocities in physical units of km/s used to apply peculiar velocity distortions, e.g., \(z_{\rm dist} = z_{\rm true} + v_{\rm z}/aH\), where a and H are the scale factor and Hubble expansion rate evaluated at the input redshift.

If velocity argument is passed, velocity_distortion_dimension must also be passed.

velocity_distortion_dimensionstring, optional

If set to 'x', 'y' or 'z', the requested dimension in the returned pos array will be distorted due to peculiar motion. For example, if velocity_distortion_dimension is z, then pos can be treated as physically observed galaxy positions under the distant-observer approximation. Default is no distortions.

cosmologyastropy.cosmology.Cosmology, optional

Cosmology to assume when applying redshift-space distortions, e.g., the cosmology of the simulation. Default is set in sim_manager.sim_defaults.

redshiftfloat, optional

Redshift of the mock galaxy sample, e.g., the redshift of the simulation snapshot. Default is set in sim_manager.sim_defaults.

maskarray_like, optional

Boolean mask that can be used to select the positions of a subcollection of the galaxies stored in the galaxy_table.

periodarray_like, optional

Length-3 sequence defining the periodic boundary conditions in each dimension. If you instead provide a single scalar, period is assumed to be the same in all Cartesian directions. If period is not np.inf, then after applying peculiar velocity distortions the new coordinates will be remapped into the periodic box. Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools.

Returns:
posarray_like

Numpy array with shape (Npts, 3) with units of comoving Mpc/h.

Notes

See Derivation of z−space Distortions in Simulation Data.

Examples

>>> npts = 100
>>> Lbox = 250.
>>> x = np.random.uniform(0, Lbox, npts)
>>> y = np.random.uniform(0, Lbox, npts)
>>> z = np.random.uniform(0, Lbox, npts)
>>> pos = return_xyz_formatted_array(x, y, z, period=Lbox)

Now we will define an array of random velocities that we will use to apply z-space distortions to the z-dimension, assuming the mock galaxy sample is at the default redshift. For our random velocities we’ll assume the values are drawn from a Gaussian centered at zero using numpy.random.normal.

>>> velocity = np.random.normal(loc=0, scale=100, size=npts)
>>> pos = return_xyz_formatted_array(x, y, z, period=Lbox, velocity=velocity, velocity_distortion_dimension='z')

If we wanted to introduce redshift-space distortions at some higher redshift:

>>> pos = return_xyz_formatted_array(x, y, z, period=Lbox, velocity=velocity, velocity_distortion_dimension='z', redshift=1.5)