zeus21.maps

Make maps! For fun and science.

Authors: zeus21 v2 collaboration - June 2026

Emily Bregou ; Hector Afonso G. Cruz ; Sarah Libanore ; Julian B. Muñoz ; Yonny Sklansky ; Emilie Thélie ; Alessandra Venditti

arXiv:2302.08506, arXiv:2306.09403, arXiv:2407.18294, Sklansky et al. (in prep)

Classes

ReioMapsConfig

All arguments of reionization_maps that have default values

reionization_maps

Generates 3D maps of the reionization fields.

T21_maps

Module Contents

class zeus21.maps.ReioMapsConfig[source]

All arguments of reionization_maps that have default values

input_boxlength: float = 300.0[source]
ncells: int = 300[source]
seed: int = 1234[source]
r_precision: float = 1.0[source]
Rs: list | numpy.ndarray | None = None[source]
barrier: numpy.ndarray = None[source]
PRINT_TIMER: bool = True[source]
LOGNORMAL_DENSITY: bool = False[source]
COMPUTE_DENSITY_AT_ALLZ: bool = False[source]
COMPUTE_MASSWEIGHTED: bool = False[source]
lowres_massweighting: int = 1[source]
COMPUTE_PARTIAL_IONIZATIONS: bool = False[source]
COMPUTE_ZREION: bool = False[source]
class zeus21.maps.reionization_maps(CosmoParams, CoeffStructure, input_z, input_boxlength=300.0, ncells=300, seed=1234, r_precision=1.0, Rs=None, barrier=None, PRINT_TIMER=True, LOGNORMAL_DENSITY=False, COMPUTE_DENSITY_AT_ALLZ=False, COMPUTE_MASSWEIGHTED=False, lowres_massweighting=1, COMPUTE_PARTIAL_IONIZATIONS=False, COMPUTE_ZREION=False)[source]

Generates 3D maps of the reionization fields.

Uses a density threshold barrier determined from a converged bubble mass function. With default parameters, the code takes about 20 minutes on laptop to run.

Parameters:
  • CosmoParams (zeus21.Cosmo_Parameters class) – Stores cosmology.

  • CoeffStructure (zeus21.get_T21_coefficients class) – Stores sfrd and 21cm coefficients.

  • input_z (1D np.array) – The redshifts at which to compute output maps. Narrowed down later to select available redshifts from CoeffStructure.zintegral.

  • input_boxlength (float) – Comoving physical side length of the box. Default is 300 cMpc.

  • ncells (int) – Number of cells on a side. Default is 300 cells.

  • seed (int) – Sets the predetermined generation of maps. Default is 1234.

  • r_precision (float) – Allows to change the steps of the radii for faster computation. Default (and max) is 1, lower values make the computation faster at the cost of accuracy.

  • barrier (function) – Input density barrier to be used as the threshold for map generation. Takes z value as input and returns np.array of shape. Default is None.

  • PRINT_TIMER (bool) – Whether to print the time elapsed along the process. Default is True.

  • LOGNORMAL_DENSITY (bool) – Whether to use lognormal (True) or Gaussian (False) density fields. Default is False.

  • COMPUTE_DENSITY_AT_ALLZ (bool) – Whether to output the density field at all redshifts. If False, only the density at the lower input redshift is computed. If True, the computation time and memory usage dramatically increases. Default is False.

  • COMPUTE_MASSWEIGHTED (bool) – Whether to compute the mass weighted ionized field and fraction. If True, COMPUTE_DENSITY_AT_ALLZ will be forced to True, thus increasing computation time dramatically. Default is False.

  • lowres_massweighting (int) – Compute the mass-weighted ionized field and fraction more efficiently by using lower resolution density and ionized fields. Has to be >=1 and an integer. Default is 1.

  • COMPUTE_PARTIAL_IONIZATIONS (bool) – Whether to compute the subpixel ionizations in the field and the ionized fractions.

dx[source]

Cell resolution of a side of the boxes.

Type:

float

z[source]

Redshifts at which the output maps are computed. Selected to be the closest to the input redshifts from the available ones in zeus21.

Type:

1D np.array

r

Radii at which the density field is smoothed. Selected using r_precision from the available ones in zeus21.

Type:

1D np.array

z_of_density[source]

Redshift at which the density is computed.

Type:

float

density[source]

Overdensity field at the lowest redshift asked by the user.

Type:

3D np.array

density_allz[source]

Overdensity field at all the redshifts asked by the user. First dimension correponds to redshifts. Only computed if COMPUTE_DENSITY_AT_ALLZ is True.

Type:

4D np.array

ion_field_allz

Ionized fraction field at all the redshifts asked by the user. First dimension correponds to redshifts.

Type:

4D np.array

ion_frac

Volume weighted ionized fraction at all the redshifts asked by the user.

Type:

1D np.array

ion_frac_massweighted

Mass weighted ionized fraction at all the redshifts asked by the user. Only computed if COMPUTE_MASSWEIGHTED is True.

Type:

1D np.array

input_z[source]
ncells = 300[source]
boxlength = 300.0[source]
dx = 1.0[source]
seed = 1234[source]
PRINT_TIMER = True[source]
LOGNORMAL_DENSITY = False[source]
COMPUTE_DENSITY_AT_ALLZ = False[source]
COMPUTE_MASSWEIGHTED = False[source]
COMPUTE_PARTIAL_IONIZATIONS = False[source]
COMPUTE_PARTIAL_AND_MASSWEIGHTED = False[source]
COMPUTE_ZREION = False[source]
z[source]
z_of_density[source]
density[source]
sig_corr[source]
density_smoothed_allr[source]
density_allz[source]
barrier = None[source]
lowres_massweighting = 1[source]
generate_density(CosmoParams)[source]

Generates the initial density field at the lowest redshift.

Parameters:

CosmoParams (CosmoParams class)

Returns:

density_field – Three-dimensional delta field evaluated at self.z_of_density.

Return type:

array

generate_density_allz(CosmoParams)[source]

Evolves the density field to all redshifts using the linear growth factor.

Parameters:

CosmoParams (CosmoParams class)

Returns:

density_allz – Four-dimensional delta field. The first dimension is z.

Return type:

array

compute_k()[source]

Computes the Fourier-space wavenumber grid for the box.

Returns:

k – Three-dimensional array of wavenumber magnitudes.

Return type:

array

smooth_density()[source]

Smooths the density field over all smoothing radii.

Returns:

density_smoothed_allr – Density field smoothed at each radius in self.r.

Return type:

array

sigma_correction(CosmoParams)[source]

Computes the non-ergodicity correction to the generated density variance.

Parameters:

CosmoParams (CosmoParams class)

Returns:

sigma_ratio – Ratio between the measured and theoretical sigma.

Return type:

float

generate_xHII(CosmoParams)[source]

Generates ionized fraction fields and volume-weighted ionized fractions.

Parameters:

CosmoParams (CosmoParams class)

Returns:

  • ion_field_allz (array) – Ionized fraction field at each redshift.

  • ion_frac (array) – Volume-weighted ionized fraction at each redshift.

ionize(CosmoParams, curr_z_idx)[source]

Computes the binary ionized field at a single redshift.

Parameters:
  • CosmoParams (CosmoParams class)

  • curr_z_idx (int) – Index of the redshift at which to compute the ionized field.

Returns:

ion_field – Binary ionized field at curr_z.

Return type:

array

compute_massweighted(CosmoParams, lowres_massweighting=1)[source]

Computes the mass-weighted ionized field and ionized fraction.

Parameters:
  • CosmoParams (CosmoParams class)

  • lowres_massweighting (int, optional) – Factor by which to downsample the density and ionized fields for mass weighting. Default is 1.

Returns:

  • ion_frac_massweighted (array) – Mass-weighted ionized fraction at each redshift.

  • ion_field_massweighted_allz (array) – Mass-weighted ionized field at each redshift.

compute_partial(CosmoParams, CoeffStructure, r=None)[source]

Computes the partially ionized field and volume-weighted partially ionized fraction.

Parameters:
  • CosmoParams (CosmoParams class)

  • CoeffStructure (get_T21_coefficients class)

  • r (float, optional) – Smoothing radius in cMpc used to evaluate the prebarrier ionized fraction. Default is None, in which case self.r[0] is used.

Returns:

  • ion_frac_partial (array) – Volume-weighted partially ionized fraction at each redshift.

  • ion_field_partial_allz (array) – Partially ionized field at each redshift.

compute_partial_massweighted(CosmoParams, CoeffStructure, r=None)[source]

Computes the mass-weighted partially ionized field and fraction.

Parameters:
  • CosmoParams (CosmoParams class)

  • CoeffStructure (get_T21_coefficients class)

  • r (float, optional) – Smoothing radius in cMpc used to evaluate the prebarrier ionized fraction. Default is None, in which case self.r[0] is used.

Returns:

  • ion_frac_partial_massweighted (array) – Mass-weighted partially ionized fraction at each redshift.

  • ion_field_partial_massweighted_allz (array) – Mass-weighted partially ionized field at each redshift.

compute_zreion_frombinaryxHII()[source]

Computes the redshift-of-reionization map from the binary ionized fraction field.

Returns:

zreion – Three-dimensional map of the z at which each cell is first ionized.

Return type:

array

compute_treion(CosmoParams)[source]

Computes the time-of-reionization map from the redshift-of-reionization map.

Parameters:

CosmoParams (CosmoParams class)

Returns:

treion – Three-dimensional map of the time at which each cell becomes ionized.

Return type:

array

class zeus21.maps.T21_maps[source]
CosmoParams: dataclasses.InitVar[zeus21.inputs.Cosmo_Parameters][source]
CoeffStructure: dataclasses.InitVar[zeus21.T21coefficients.get_T21_coefficients][source]
PowerSpectra: dataclasses.InitVar[zeus21.correlations.Power_Spectra][source]
input_z: numpy.ndarray[source]
ReioMaps_config: ReioMapsConfig[source]
ReioMaps: reionization_maps[source]
USE_xHII_MAPS: bool = True[source]
COMPUTE_TAU: bool = False[source]
input_boxlength: float = 300.0[source]
ncells: int = 300[source]
seed: int = 1234[source]
input_Resolution: float = 0.5[source]
density: numpy.ndarray[source]
xHI: numpy.ndarray[source]
xHI_massweighted: numpy.ndarray[source]
tau: numpy.ndarray[source]
T21_lin: numpy.ndarray[source]
T21_NL: numpy.ndarray[source]
T21: numpy.ndarray[source]
smooth_box: bool = False[source]
xHI_smooth: numpy.ndarray[source]
T21_smooth: numpy.ndarray[source]
T21avg: numpy.ndarray[source]
generate_density_pb()[source]

Generates density fields using PowerBox.

Returns:

  • density (array) – Density field at each redshift.

  • pbs (list) – PowerBox objects that generate the density fields.

generate_T21_lin(pbs)[source]

Generates the linear 21cm temperature field.

Parameters:

pbs (list) – PowerBox objects.

Returns:

T21_lin – Linear 21cm brightness temperature field at each redshift.

Return type:

array

generate_T21_NL()[source]

Generates the nonlinear correction to the 21cm temperature field.

Returns:

T21_NL – Nonlinear 21cm brightness temperature correction field at each redshift.

Return type:

array