py21cmfast.rsds

Module for accounting redshift space distortions.

Functions

apply_rsds(field, los_velocity, redshifts, inputs, ...)

Apply redshift-space distortions to a field.

estimate_rsd_displacements(classy_output, cosmo, redshifts)

Estimate the rms of the redshift space distortions displacement field at given redshifts.

include_dvdr_in_tau21(brightness_temp, los_velocity, ...)

Include velocity gradient corrections to the brightness temperature field.

rsds_shift(field, los_displacement[, n_rsd_subcells, ...])

Shift the cells of a field according to the los displacement.

Module Contents

py21cmfast.rsds.apply_rsds(field, los_velocity, redshifts, inputs, periodic, n_rsd_subcells=4)[source]

Apply redshift-space distortions to a field.

Notes

To ensure that we cover all the slices in the field after the velocities have been applied, we extrapolate the densities and velocities on either end by the maximum velocity offset in the field. Then, to ensure we don’t pick up cells with zero particles (after displacement), we interpolate the slices onto a finer regular grid (in comoving distance) and then displace the field on that grid, before interpolating back onto the original slices.

Parameters:
  • field – A box of the field on which redshift-space distortions shall be applied.

  • los_velocity – Line-of-sight velocities for each cell of brightness_temp, in Mpc/second.

  • redshifts – An array of the redshifts along the los. Can also be a float (could be useful for coeval boxes)

  • inputs – The input parameters corresponding to the box.

  • periodic (bool) – Whether to assume periodic boundary conditions along the line-of-sight.

  • n_rsd_subcells (int, optional) – The number of subcells into which each cell is divided when redshift space distortions are applied. Default is 4.

Returns:

field_with_rsds – A box of the field, with redshift space distortions.

Parameters:
Return type:

numpy.ndarray

py21cmfast.rsds.estimate_rsd_displacements(classy_output, cosmo, redshifts, factor=1.0)[source]

Estimate the rms of the redshift space distortions displacement field at given redshifts.

Parameters:
  • classy_output (classy.Class) – An object containing all the information from the CLASS calculation.

  • cosmo (astropy.cosmology) – The assumed cosmology

  • redshifts (list) – List of the redshifts at which the rms of the displacement field is computed.

  • factor (float, optional) – Factor to multiply the rms velocity from CLASS. Default is 1.

Returns:

displacements (np.array) – The rms of the RSD displacement field.

Parameters:
  • classy_output (classy.Class)

  • cosmo (astropy.cosmology)

  • redshifts (collections.abc.Sequence[float])

  • factor (float)

Return type:

collections.abc.Sequence[astropy.units.Quantity]

py21cmfast.rsds.include_dvdr_in_tau21(brightness_temp, los_velocity, redshifts, inputs, periodic, tau_21=None)[source]

Include velocity gradient corrections to the brightness temperature field.

Parameters:
  • brightness_temp – A box of the brightness temperature, without velocity gradient corrections.

  • los_velocity – Line-of-sight velocities for each cell of brightness_temp, in Mpc/second.

  • redshifts – An array of the redshifts along the los. Can also be a float (could be useful for coeval boxes)

  • inputs – The input parameters corresponding to the box.

  • tau_21 – A box of the 21cm optical depth. Not required if inputs.astro_options.USE_TS_FLUCT = False.

  • periodic – Whether to assume periodic boundary conditions along the line-of-sight.

Returns:

tb_with_dvdr – A box of the brightness temperature, with velocity gradient corrections.

Parameters:
Return type:

numpy.ndarray

py21cmfast.rsds.rsds_shift(field, los_displacement, n_rsd_subcells=4, periodic=False)[source]

Shift the cells of a field according to the los displacement.

Parameters:
  • field – A box of the field on which redshift-space distortions shall be applied, shape (nslices, ncoords).

  • los_displacement – The line-of-sight “apparent” displacement of the field, in pixel coordinates. Equal to v / H(z) / cell_size. Positive values are towards the observer, shape (nslices, ncoords).

  • periodic (bool, optioanl) – Whether to assume periodic boundary conditions along the line-of-sight.

  • n_rsd_subcells (int, optional) – The number of subcells into which each cell is divided when redshift space distortions are applied. Default is 4.

Returns:

field_with_rsds – A box of the field, with redshift space distortions, shape (nslices, ncoords).

Parameters:
  • field (numpy.ndarray)

  • los_displacement (numpy.ndarray)

  • n_rsd_subcells (int)

  • periodic (bool)

Return type:

numpy.ndarray