py21cmfast.drivers.single_field =============================== .. py:module:: py21cmfast.drivers.single_field .. autoapi-nested-parse:: Compute single physical fields. These functions are high-level wrappers around C-functions that compute 3D fields, for example initial conditions, perturbed fields and ionization fields. .. !! processed by numpydoc !! Attributes ---------- .. autoapisummary:: py21cmfast.drivers.single_field.logger Functions --------- .. autoapisummary:: py21cmfast.drivers.single_field.brightness_temperature py21cmfast.drivers.single_field.compute_halo_grid py21cmfast.drivers.single_field.compute_initial_conditions py21cmfast.drivers.single_field.compute_ionization_field py21cmfast.drivers.single_field.compute_spin_temperature py21cmfast.drivers.single_field.compute_xray_source_field py21cmfast.drivers.single_field.determine_halo_catalog py21cmfast.drivers.single_field.interp_halo_boxes py21cmfast.drivers.single_field.perturb_field py21cmfast.drivers.single_field.perturb_halo_catalog Module Contents --------------- .. py:function:: brightness_temperature(*, ionized_box, perturbed_field, spin_temp = None) Compute a coeval brightness temperature box. :Parameters: * **ionized_box** (:class:`IonizedBox`) -- A pre-computed ionized box. * **perturbed_field** (:class:`PerturbedField`) -- A pre-computed perturbed field at the same redshift as `ionized_box`. * **spin_temp** (:class:`TsBox`, optional) -- A pre-computed spin temperature, at the same redshift as the other boxes. :returns: :class:`BrightnessTemp` instance. .. !! processed by numpydoc !! .. py:function:: compute_halo_grid(*, redshift, initial_conditions, inputs = None, halo_catalog = None, previous_spin_temp = None, previous_ionize_box = None) Compute grids of halo properties from a catalogue. At the moment this simply produces halo masses, stellar masses and SFR on a grid of HII_DIM. In the future this will compute properties such as emissivities which will be passed directly into ionize_box etc. instead of the catalogue. :Parameters: * **initial_conditions** (:class:`~InitialConditions`) -- The initial conditions of the run. * **inputs** (:class:`~InputParameters`, optional) -- The input parameters specifying the run. * **halo_catalog** (:class:`~HaloCatalog`, optional) -- This contains all the dark matter haloes obtained if using a discrete halo model. This is a list of halo masses and coordinates for the dark matter halos. * **previous_spin_temp** (:class:`TsBox`, optional) -- The previous spin temperature box. Used for feedback when USE_MINI_HALOS==True * **previous_ionize_box** (:class:`IonizedBox` or None) -- An at the last timestep. Used for feedback when USE_MINI_HALOS==True :returns: :class:`~HaloBox` -- An object containing the halo box data. :Other Parameters: **regenerate, write, cache** -- See docs of :func:`initial_conditions` for more information. .. !! processed by numpydoc !! .. py:function:: compute_initial_conditions(*, inputs) Compute initial conditions. :Parameters: * **inputs** -- The InputParameters instance defining the run. * **regenerate** (*bool, optional*) -- Whether to force regeneration of data, even if matching cached data is found. * **cache** -- An OutputCache object defining how to read cached boxes. * **write** -- A boolean specifying whether we need to cache the box. :returns: :class:`~InitialConditions` .. !! processed by numpydoc !! .. py:function:: compute_ionization_field(*, perturbed_field, initial_conditions, inputs = None, previous_perturbed_field = None, previous_ionized_box = None, spin_temp = None, halobox = None) Compute an ionized box at a given redshift. This function has various options for how the evolution of the ionization is computed (if at all). See the Notes below for details. :Parameters: * **initial_conditions** (:class:`~InitialConditions` instance) -- The initial conditions. * **inputs** (:class:`~InputParameters`) -- The input parameters specifying the run. Since this may be the first box to use the astro params/flags, it is needed when we have not computed a TsBox or HaloBox. * **perturbed_field** (:class:`~PerturbedField`) -- The perturbed density field. * **previous_perturbed_field** (:class:`~PerturbedField`, optional) -- An perturbed field at higher redshift. This is only used if USE_MINI_HALOS is included. * **previous_ionize_box** (:class:`IonizedBox` or None) -- An ionized box at higher redshift. This is only used if `INHOMO_RECO` and/or `USE_TS_FLUCT` are true. If either of these are true, and this is not given, then it will be assumed that this is the "first box", i.e. that it can be populated accurately without knowing source statistics. * **spin_temp** (:class:`TsBox` or None, optional) -- A spin-temperature box, only required if `USE_TS_FLUCT` is True. If None, will try to read in a spin temp box at the current redshift, and failing that will try to automatically create one, using the previous ionized box redshift as the previous spin temperature redshift. * **halobox** (:class:`~HaloBox` or None, optional) -- If passed, this contains all the dark matter haloes obtained if using the lagrangian source models. These are grids containing summed halo properties such as ionizing emissivity. :returns: :class:`~IonizedBox` -- An object containing the ionized box data. .. rubric:: Notes Typically, the ionization field at any redshift is dependent on the evolution of xHI up until that redshift, which necessitates providing a previous ionization field to define the current one. If neither the spin temperature field, nor inhomogeneous recombinations (specified in flag options) are used, no evolution needs to be done. If the redshift is beyond Z_HEAT_MAX, previous fields are not required either. .. !! processed by numpydoc !! .. py:function:: compute_spin_temperature(*, initial_conditions, perturbed_field, inputs = None, xray_source_box = None, previous_spin_temp = None, cleanup = False) Compute spin temperature boxes at a given redshift. See the notes below for how the spin temperature field is evolved through redshift. :Parameters: * **initial_conditions** (:class:`~InitialConditions`) -- The initial conditions * **inputs** (:class:`~InputParameters`) -- The input parameters specifying the run. Since this will be the first box to use the astro params/flags when SOURCE_MODEL='E-INTEGRAL' and USE_TS_FLUCT=True. * **perturbed_field** (:class:`~PerturbedField`, optional) -- If given, this field will be used, otherwise it will be generated. To be generated, either `initial_conditions` and `redshift` must be given, or `simulation_options`, `cosmo_params` and `redshift`. By default, this will be generated at the same redshift as the spin temperature box. The redshift of perturb field is allowed to be different than `redshift`. If so, it will be interpolated to the correct redshift, which can provide a speedup compared to actually computing it at the desired redshift. * **xray_source_box** (:class:`XraySourceBox`, optional) -- When using a lagrangian source model, this box specifies the filtered sfr and xray emissivity at all redshifts/filter radii required by the spin temperature algorithm. * **previous_spin_temp** (:class:`TsBox` or None) -- The previous spin temperature box. Needed when we are beyond the first snapshot :returns: :class:`~TsBox` -- An object containing the spin temperature box data. :Other Parameters: **regenerate, write, cache** -- See docs of :func:`initial_conditions` for more information. .. !! processed by numpydoc !! .. py:function:: compute_xray_source_field(*, initial_conditions, hboxes, redshift) Compute filtered grid of SFR for use in spin temperature calculation. This will filter over the halo history in annuli, computing the contribution to the SFR density If no halo field is passed one is calculated at the desired redshift as if it is the first box. :Parameters: * **initial_conditions** (:class:`~InitialConditions`) -- The initial conditions of the run. The user and cosmo params * **hboxes** (Sequence of :class:`~HaloBox` instances) -- This contains the list of Halobox instances which are used to create this source field :returns: :class:`~XraySourceBox` -- An object containing x ray heating, ionisation, and lyman alpha rates. :Other Parameters: **regenerate, write, cache** -- See docs of :func:`initial_conditions` for more information. .. !! processed by numpydoc !! .. py:function:: determine_halo_catalog(*, redshift, inputs = None, initial_conditions, descendant_halos = None) Find a halo list, given a redshift. :Parameters: * **redshift** (*float*) -- The redshift at which to determine the halo list. * **initial_conditions** (:class:`~InitialConditions` instance) -- The initial conditions fields (density, velocity). * **descendant_halos** (:class:`~HaloCatalog` instance, optional) -- The halos that form the descendants (i.e. lower redshift) of those computed by this function. If this is not provided, we generate the initial stochastic halos directly in this function (and progenitors can then be determined by these). :returns: :class:`~HaloCatalog` :Other Parameters: **regenerate, write, cache** -- See docs of :func:`initial_conditions` for more information. .. !! processed by numpydoc !! .. py:function:: interp_halo_boxes(halo_boxes, fields, redshift) Interpolate HaloBox history to the desired redshift. Photon conservation & Xray sources require halo boxes at redshifts that are not equal to the current redshift, and may be between redshift steps. So we need a function to interpolate between two halo boxes. We assume here that z_arr is strictly INCERASING :Parameters: * **halo_boxes** (*list of HaloBox instances*) -- The halobox history to be interpolated * **fields** (*List of Strings*) -- The properties of the haloboxes to be interpolated * **redshift** (*float*) -- The desired redshift of interpolation :returns: :class:`~HaloBox` -- An object containing the halo box data .. !! processed by numpydoc !! .. py:function:: perturb_field(*, redshift, inputs = None, initial_conditions) Compute a perturbed field at a given redshift. :Parameters: * **redshift** (*float*) -- The redshift at which to compute the perturbed field. * **initial_conditions** (:class:`~InitialConditions` instance) -- The initial conditions. :returns: :class:`~PerturbedField` :Other Parameters: **regenerate, write, cache** -- See docs of :func:`initial_conditions` for more information. .. rubric:: Examples >>> initial_conditions = compute_initial_conditions() >>> field7 = perturb_field(7.0, initial_conditions) >>> field8 = perturb_field(8.0, initial_conditions) The user and cosmo parameter structures are by default inferred from the ``initial_conditions``. .. !! processed by numpydoc !! .. py:function:: perturb_halo_catalog(*, initial_conditions, inputs = None, previous_spin_temp = None, previous_ionize_box = None, halo_catalog) Given a halo list, perturb the halos for a given redshift. :Parameters: * **initial_conditions** (:class:`~InitialConditions`) -- The initial conditions of the run. The user and cosmo params as well as the random seed will be set from this object. * **halo_catalog** (:class: `~HaloCatalog`) -- The halo catalogue in Lagrangian space to be perturbed. :returns: :class:`~PerturbedHaloCatalog` :Other Parameters: **regenerate, write, direc** -- See docs of :func:`initial_conditions` for more information. .. rubric:: Examples Fill this in once finalised .. !! processed by numpydoc !! .. py:data:: logger