py21cmfast.wrapper.outputs.EmissivityFields

class py21cmfast.wrapper.outputs.EmissivityFields

Bases: OutputStructZ

A class containing all gridded halo properties.

compute(*, initial_conditions: InitialConditions, perturbed_field: PerturbedField, halo_catalog: HaloCatalog, previous_spin_temp: TsBox, previous_ionize_box: IonizedBox, allow_already_computed: bool = False)

Compute the function.

Parameters:
classmethod dummy()

Create a dummy instance with the given inputs.

ensure_arrays_computed(*arrays, load=False) → bool

Check if the given arrays are computed (not just initialized).

Return type:

bool

ensure_arrays_inited(*arrays, init=False) → bool

Check if the given arrays are initialized (or computed).

Return type:

bool

ensure_input_computed(input_box: Self, load: bool = False) → bool

Ensure all the inputs have been computed.

Parameters:
  • input_box (Self)

  • load (bool)

Return type:

bool

get(ary: str | py21cmfast.wrapper.arrays.Array)

If possible, load an array from disk, storing it and returning the underlying array.

Parameters:

ary (str | py21cmfast.wrapper.arrays.Array)

get_full_size() → int

Return the size of the object in bytes.

This represents the size of the object if it is fully initialized/computed and all in memory. Equivalently, it is close to the file size on disk.

Return type:

int

get_required_input_arrays(input_box: OutputStruct) → list[str]

Return all input arrays required to compute this object.

Parameters:

input_box (OutputStruct)

Return type:

list[str]

has(name: str) → bool

Whether the named array currently has data available, in memory or on disk.

Reading the attribute of the same name is only meaningful when this is true; otherwise it raises, because there is no data anywhere to give you. Use this rather than testing the attribute against None: an array that exists but has never been computed is not the same thing as an optional array that this set of inputs doesn’t produce (for which the attribute is None).

Parameters:

name (str)

Return type:

bool

classmethod initial(inputs)

Create a dummy instance with the given inputs.

load_all()

Load all possible arrays into memory.

classmethod new(inputs: py21cmfast.wrapper.inputs.InputParameters, redshift: float, **kw) → Self

Create a new EmissivityFields instance with the given inputs.

Parameters:
  • inputs (InputParameters) – The input parameters defining the output struct.

  • redshift (float) – The redshift at which to compute fields.

Other Parameters:
  • All other parameters are passed through to the :class:`EmissivityFields`

  • constructor.

Parameters:
Return type:

Self

prepare(flush: collections.abc.Sequence[str] | None = None, keep: collections.abc.Sequence[str] | None = None, force: bool = False)

Prepare the instance for being passed to another function.

This will flush all arrays in “flush” from memory, and ensure all arrays in “keep” are in memory. At least one of these must be provided. By default, the complement of the given parameter is all flushed/kept.

Parameters:
  • flush – Arrays to flush out of memory. Note that if no file is associated with this instance, these arrays will be lost forever.

  • keep – Arrays to keep or load into memory. Note that if these do not already exist, they will be loaded from file (if the file exists). Only one of flush and keep should be specified.

  • force – Whether to force flushing arrays even if no disk storage exists.

Parameters:
  • flush (collections.abc.Sequence[str] | None)

  • keep (collections.abc.Sequence[str] | None)

  • force (bool)

prepare_for_next_snapshot(next_z, force: bool = False)

Prepare the EmissivityFields for the next snapshot.

Parameters:

force (bool)

pull_from_backend()

Sync the current state of the object with the underlying C-struct.

This will pull any primitives calculated in the backend to the python object. Arrays are passed in as pointers, and do not need to be copied back.

purge(force=False)

Flush all the boxes out of memory.

Parameters:

force – Whether to force the purge even if no disk storage exists.

push_to_backend()

Push the current state of the object with the underlying C-struct.

This will link any memory initialized by numpy in this object with the underlying C-struct, and also update the C struct with any values in the python object.

set(name: str, value: Any)

Set the value of an array.

Parameters:
  • name (str)

  • value (Any)

summarize(indent: int = 0) → str

Generate a string summary of the struct.

Parameters:

indent (int)

Return type:

str

property arrays: dict[str, py21cmfast.wrapper.arrays.Array]

A dictionary of Array objects whose memory is shared between this object and the C backend.

This is the handle for anything to do with an array’s memory - its state, its cache backend, and the functional transitions between them. Reading the attribute of the same name off this object gives you the array’s data, as a plain numpy array.

Return type:

dict[str, py21cmfast.wrapper.arrays.Array]

property astro_options: py21cmfast.wrapper.inputs.AstroOptions

The AstroOptions object for this output struct.

Return type:

py21cmfast.wrapper.inputs.AstroOptions

property astro_params: py21cmfast.wrapper.inputs.AstroParams

The AstroParams object for this output struct.

Return type:

py21cmfast.wrapper.inputs.AstroParams

property cosmo_params: py21cmfast.wrapper.inputs.CosmoParams

The CosmoParams object for this output struct.

Return type:

py21cmfast.wrapper.inputs.CosmoParams

property count: py21cmfast.wrapper.arrays.Array

The halo number (per cell).

This property is deprecated and will be removed in a future version. Please use halo_number directly instead.

Return type:

py21cmfast.wrapper.arrays.Array

property halo_mass: py21cmfast.wrapper.arrays.Array

The halo mass density field.

This property is deprecated and will be removed in a future version. Please use halo_mass_density directly instead.

Return type:

py21cmfast.wrapper.arrays.Array

property halo_sfr: py21cmfast.wrapper.arrays.Array

The star formation rate density field in ACGs.

This property is deprecated and will be removed in a future version. Please use sfrd_acg directly instead.

Return type:

py21cmfast.wrapper.arrays.Array

property halo_sfr_mini: py21cmfast.wrapper.arrays.Array

The star formation rate density field in MCGs.

This property is deprecated and will be removed in a future version. Please use sfrd_mcg directly instead.

Return type:

py21cmfast.wrapper.arrays.Array

property halo_stars: py21cmfast.wrapper.arrays.Array

The stellar mass density field in ACGs.

This property is deprecated and will be removed in a future version. Please use stellar_mass_density_acg directly instead.

Return type:

py21cmfast.wrapper.arrays.Array

property halo_stars_mini: py21cmfast.wrapper.arrays.Array

The stellar mass density field in MCGs.

This property is deprecated and will be removed in a future version. Please use stellar_mass_density_mcg directly instead.

Return type:

py21cmfast.wrapper.arrays.Array

property halo_xray: py21cmfast.wrapper.arrays.Array

The X-ray emissivity field.

This property is deprecated and will be removed in a future version. Please use xray_emissivity directly instead.

Return type:

py21cmfast.wrapper.arrays.Array

inputs: py21cmfast.wrapper.inputs.InputParameters
property is_computed: bool

Whether this instance has been computed at all.

This is true either if the current instance has called compute(), or if it has a current existing path pointing to stored data, or if such a path exists.

Just because the instance has been computed does not mean that all relevant quantities are available – some may have been purged from memory without writing. Use has() to check whether certain arrays are available.

Return type:

bool

property log10_Mcrit_ACG_ave: float

The average log10 of the turnover mass for ACGs.

This property is deprecated and will be removed in a future version. Please use log10_mturn_acg_ave directly instead.

Return type:

float

property log10_Mcrit_MCG_ave: float

The average log10 of the turnover mass for MCGs.

This property is deprecated and will be removed in a future version. Please use log10_mturn_mcg_ave directly instead.

Return type:

float

log10_mturn_acg_ave: float
log10_mturn_mcg_ave: float
property matter_options: py21cmfast.wrapper.inputs.MatterOptions

The SimulationOptions object for this output struct.

Return type:

py21cmfast.wrapper.inputs.MatterOptions

property random_seed: int

The random seed for this particular instance.

Return type:

int

redshift: float
property simulation_options: py21cmfast.wrapper.inputs.SimulationOptions

The SimulationOptions object for this output struct.

Return type:

py21cmfast.wrapper.inputs.SimulationOptions

property whalo_sfr: py21cmfast.wrapper.arrays.Array

The star formation rate density field, weighted by escape fraction, in both ACGs and MCGs.

This property is deprecated and will be removed in a future version. Please use fesc_weighted_sfrd directly instead.

Return type:

py21cmfast.wrapper.arrays.Array