py21cmfast.wrapper.run_coeval

py21cmfast.wrapper.run_coeval(*, redshift=None, user_params=None, cosmo_params=None, astro_params=None, flag_options=None, regenerate=None, write=None, direc=None, init_box=None, perturb=None, use_interp_perturb_field=False, pt_halos=None, random_seed=None, cleanup=True, hooks=None, always_purge: bool = False, **global_kwargs)[source]

Evaluate a coeval ionized box at a given redshift, or multiple redshifts.

This is generally the easiest and most efficient way to generate a set of coeval cubes at a given set of redshift. It self-consistently deals with situations in which the field needs to be evolved, and does this with the highest memory-efficiency, only returning the desired redshift. All other calculations are by default stored in the on-disk cache so they can be re-used at a later time.

Note

User-supplied redshift are not used as previous redshift in any scrolling, so that pristine log-sampling can be maintained.

Parameters:
  • redshift (array_like) – A single redshift, or multiple redshift, at which to return results. The minimum of these will define the log-scrolling behaviour (if necessary).

  • user_params (UserParams, optional) – Defines the overall options and parameters of the run.

  • cosmo_params (CosmoParams , optional) – Defines the cosmological parameters used to compute initial conditions.

  • astro_params (AstroParams , optional) – The astrophysical parameters defining the course of reionization.

  • flag_options (FlagOptions , optional) – Some options passed to the reionization routine.

  • init_box (InitialConditions, optional) – If given, the user and cosmo params will be set from this object, and it will not be re-calculated.

  • perturb (list of PerturbedField, optional) – If given, must be compatible with init_box. It will merely negate the necessity of re-calculating the perturb fields.

  • use_interp_perturb_field (bool, optional) – Whether to use a single perturb field, at the lowest redshift of the lightcone, to determine all spin temperature fields. If so, this field is interpolated in the underlying C-code to the correct redshift. This is less accurate (and no more efficient), but provides compatibility with older versions of 21cmFAST.

  • pt_halos (bool, optional) – If given, must be compatible with init_box. It will merely negate the necessity of re-calculating the perturbed halo lists.

  • cleanup (bool, optional) – A flag to specify whether the C routine cleans up its memory before returning. Typically, if spin_temperature is called directly, you will want this to be true, as if the next box to be calculate has different shape, errors will occur if memory is not cleaned. Note that internally, this is set to False until the last iteration.

  • **global_kwargs – Any attributes for GlobalParams. This will temporarily set global attributes for the duration of the function. Note that arguments will be treated as case-insensitive.

Returns:

coevals (Coeval) – The full data for the Coeval class, with init boxes, perturbed fields, ionized boxes, brightness temperature, and potential data from the conservation of photons. If a single redshift was specified, it will return such a class. If multiple redshifts were passed, it will return a list of such classes.

Other Parameters:

regenerate, write, direc, random_seed – See docs of initial_conditions() for more information.