zeus21.maps =========== .. py:module:: zeus21.maps .. autoapi-nested-parse:: 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 ------- .. autoapisummary:: zeus21.maps.ReioMapsConfig zeus21.maps.reionization_maps zeus21.maps.T21_maps Module Contents --------------- .. py:class:: ReioMapsConfig All arguments of reionization_maps that have default values .. py:attribute:: input_boxlength :type: float :value: 300.0 .. py:attribute:: ncells :type: int :value: 300 .. py:attribute:: seed :type: int :value: 1234 .. py:attribute:: r_precision :type: float :value: 1.0 .. py:attribute:: Rs :type: list | numpy.ndarray | None :value: None .. py:attribute:: barrier :type: numpy.ndarray :value: None .. py:attribute:: PRINT_TIMER :type: bool :value: True .. py:attribute:: LOGNORMAL_DENSITY :type: bool :value: False .. py:attribute:: COMPUTE_DENSITY_AT_ALLZ :type: bool :value: False .. py:attribute:: COMPUTE_MASSWEIGHTED :type: bool :value: False .. py:attribute:: lowres_massweighting :type: int :value: 1 .. py:attribute:: COMPUTE_PARTIAL_IONIZATIONS :type: bool :value: False .. py:attribute:: COMPUTE_ZREION :type: bool :value: False .. py:class:: 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) 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. :param CosmoParams: Stores cosmology. :type CosmoParams: zeus21.Cosmo_Parameters class :param CoeffStructure: Stores sfrd and 21cm coefficients. :type CoeffStructure: zeus21.get_T21_coefficients class :param input_z: The redshifts at which to compute output maps. Narrowed down later to select available redshifts from CoeffStructure.zintegral. :type input_z: 1D np.array :param input_boxlength: Comoving physical side length of the box. Default is 300 cMpc. :type input_boxlength: float :param ncells: Number of cells on a side. Default is 300 cells. :type ncells: int :param seed: Sets the predetermined generation of maps. Default is 1234. :type seed: int :param r_precision: 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. :type r_precision: float :param barrier: 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. :type barrier: function :param PRINT_TIMER: Whether to print the time elapsed along the process. Default is True. :type PRINT_TIMER: bool :param LOGNORMAL_DENSITY: Whether to use lognormal (True) or Gaussian (False) density fields. Default is False. :type LOGNORMAL_DENSITY: bool :param COMPUTE_DENSITY_AT_ALLZ: 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. :type COMPUTE_DENSITY_AT_ALLZ: bool :param COMPUTE_MASSWEIGHTED: 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. :type COMPUTE_MASSWEIGHTED: bool :param lowres_massweighting: 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. :type lowres_massweighting: int :param COMPUTE_PARTIAL_IONIZATIONS: Whether to compute the subpixel ionizations in the field and the ionized fractions. :type COMPUTE_PARTIAL_IONIZATIONS: bool .. attribute:: dx Cell resolution of a side of the boxes. :type: float .. attribute:: z 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 .. attribute:: r Radii at which the density field is smoothed. Selected using r_precision from the available ones in zeus21. :type: 1D np.array .. attribute:: z_of_density Redshift at which the density is computed. :type: float .. attribute:: density Overdensity field at the lowest redshift asked by the user. :type: 3D np.array .. attribute:: density_allz 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 .. attribute:: ion_field_allz Ionized fraction field at all the redshifts asked by the user. First dimension correponds to redshifts. :type: 4D np.array .. attribute:: ion_frac Volume weighted ionized fraction at all the redshifts asked by the user. :type: 1D np.array .. attribute:: 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 .. py:attribute:: input_z .. py:attribute:: ncells :value: 300 .. py:attribute:: boxlength :value: 300.0 .. py:attribute:: dx :value: 1.0 .. py:attribute:: seed :value: 1234 .. py:attribute:: PRINT_TIMER :value: True .. py:attribute:: LOGNORMAL_DENSITY :value: False .. py:attribute:: COMPUTE_DENSITY_AT_ALLZ :value: False .. py:attribute:: COMPUTE_MASSWEIGHTED :value: False .. py:attribute:: COMPUTE_PARTIAL_IONIZATIONS :value: False .. py:attribute:: COMPUTE_PARTIAL_AND_MASSWEIGHTED :value: False .. py:attribute:: COMPUTE_ZREION :value: False .. py:attribute:: z .. py:attribute:: z_of_density .. py:attribute:: density .. py:attribute:: sig_corr .. py:attribute:: density_smoothed_allr .. py:attribute:: density_allz .. py:attribute:: barrier :value: None .. py:attribute:: lowres_massweighting :value: 1 .. py:method:: generate_density(CosmoParams) Generates the initial density field at the lowest redshift. :param CosmoParams: :type CosmoParams: CosmoParams class :returns: **density_field** -- Three-dimensional delta field evaluated at self.z_of_density. :rtype: array .. py:method:: generate_density_allz(CosmoParams) Evolves the density field to all redshifts using the linear growth factor. :param CosmoParams: :type CosmoParams: CosmoParams class :returns: **density_allz** -- Four-dimensional delta field. The first dimension is z. :rtype: array .. py:method:: compute_k() Computes the Fourier-space wavenumber grid for the box. :returns: **k** -- Three-dimensional array of wavenumber magnitudes. :rtype: array .. py:method:: smooth_density() Smooths the density field over all smoothing radii. :returns: **density_smoothed_allr** -- Density field smoothed at each radius in self.r. :rtype: array .. py:method:: sigma_correction(CosmoParams) Computes the non-ergodicity correction to the generated density variance. :param CosmoParams: :type CosmoParams: CosmoParams class :returns: **sigma_ratio** -- Ratio between the measured and theoretical sigma. :rtype: float .. py:method:: generate_xHII(CosmoParams) Generates ionized fraction fields and volume-weighted ionized fractions. :param CosmoParams: :type CosmoParams: CosmoParams class :returns: * **ion_field_allz** (*array*) -- Ionized fraction field at each redshift. * **ion_frac** (*array*) -- Volume-weighted ionized fraction at each redshift. .. py:method:: ionize(CosmoParams, curr_z_idx) Computes the binary ionized field at a single redshift. :param CosmoParams: :type CosmoParams: CosmoParams class :param curr_z_idx: Index of the redshift at which to compute the ionized field. :type curr_z_idx: int :returns: **ion_field** -- Binary ionized field at curr_z. :rtype: array .. py:method:: compute_massweighted(CosmoParams, lowres_massweighting=1) Computes the mass-weighted ionized field and ionized fraction. :param CosmoParams: :type CosmoParams: CosmoParams class :param lowres_massweighting: Factor by which to downsample the density and ionized fields for mass weighting. Default is 1. :type lowres_massweighting: int, optional :returns: * **ion_frac_massweighted** (*array*) -- Mass-weighted ionized fraction at each redshift. * **ion_field_massweighted_allz** (*array*) -- Mass-weighted ionized field at each redshift. .. py:method:: compute_partial(CosmoParams, CoeffStructure, r=None) Computes the partially ionized field and volume-weighted partially ionized fraction. :param CosmoParams: :type CosmoParams: CosmoParams class :param CoeffStructure: :type CoeffStructure: get_T21_coefficients class :param r: Smoothing radius in cMpc used to evaluate the prebarrier ionized fraction. Default is None, in which case self.r[0] is used. :type r: float, optional :returns: * **ion_frac_partial** (*array*) -- Volume-weighted partially ionized fraction at each redshift. * **ion_field_partial_allz** (*array*) -- Partially ionized field at each redshift. .. py:method:: compute_partial_massweighted(CosmoParams, CoeffStructure, r=None) Computes the mass-weighted partially ionized field and fraction. :param CosmoParams: :type CosmoParams: CosmoParams class :param CoeffStructure: :type CoeffStructure: get_T21_coefficients class :param r: Smoothing radius in cMpc used to evaluate the prebarrier ionized fraction. Default is None, in which case self.r[0] is used. :type r: float, optional :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. .. py:method:: compute_zreion_frombinaryxHII() 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. :rtype: array .. py:method:: compute_treion(CosmoParams) Computes the time-of-reionization map from the redshift-of-reionization map. :param CosmoParams: :type CosmoParams: CosmoParams class :returns: **treion** -- Three-dimensional map of the time at which each cell becomes ionized. :rtype: array .. py:class:: T21_maps .. py:attribute:: CosmoParams :type: dataclasses.InitVar[zeus21.inputs.Cosmo_Parameters] .. py:attribute:: CoeffStructure :type: dataclasses.InitVar[zeus21.T21coefficients.get_T21_coefficients] .. py:attribute:: PowerSpectra :type: dataclasses.InitVar[zeus21.correlations.Power_Spectra] .. py:attribute:: input_z :type: numpy.ndarray .. py:attribute:: ReioMaps_config :type: ReioMapsConfig .. py:attribute:: ReioMaps :type: reionization_maps .. py:attribute:: USE_xHII_MAPS :type: bool :value: True .. py:attribute:: COMPUTE_TAU :type: bool :value: False .. py:attribute:: input_boxlength :type: float :value: 300.0 .. py:attribute:: ncells :type: int :value: 300 .. py:attribute:: seed :type: int :value: 1234 .. py:attribute:: input_Resolution :type: float :value: 0.5 .. py:attribute:: density :type: numpy.ndarray .. py:attribute:: xHI :type: numpy.ndarray .. py:attribute:: xHI_massweighted :type: numpy.ndarray .. py:attribute:: tau :type: numpy.ndarray .. py:attribute:: T21_lin :type: numpy.ndarray .. py:attribute:: T21_NL :type: numpy.ndarray .. py:attribute:: T21 :type: numpy.ndarray .. py:attribute:: smooth_box :type: bool :value: False .. py:attribute:: xHI_smooth :type: numpy.ndarray .. py:attribute:: T21_smooth :type: numpy.ndarray .. py:attribute:: T21avg :type: numpy.ndarray .. py:method:: generate_density_pb() Generates density fields using PowerBox. :returns: * **density** (*array*) -- Density field at each redshift. * **pbs** (*list*) -- PowerBox objects that generate the density fields. .. py:method:: generate_T21_lin(pbs) Generates the linear 21cm temperature field. :param pbs: PowerBox objects. :type pbs: list :returns: **T21_lin** -- Linear 21cm brightness temperature field at each redshift. :rtype: array .. py:method:: generate_T21_NL() Generates the nonlinear correction to the 21cm temperature field. :returns: **T21_NL** -- Nonlinear 21cm brightness temperature correction field at each redshift. :rtype: array