py21cmfast.wrapper.outputs.XraySourceBox

class py21cmfast.wrapper.outputs.XraySourceBox

Bases: OutputStructZ

A class containing the filtered sfr grids.

classmethod __init_subclass__()

Store subclasses for easy access.

compute(*, halobox, R_inner, R_outer, R_ct, allow_already_computed=False)

Compute the function.

Parameters:
  • halobox (HaloBox)

  • allow_already_computed (bool)

classmethod dummy()

Create a dummy instance with the given inputs.

ensure_arrays_computed(*arrays, load=False)

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

Return type:

bool

ensure_arrays_inited(*arrays, init=False)

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

Return type:

bool

ensure_input_computed(input_box, load=False)

Ensure all the inputs have been computed.

Parameters:
  • input_box (Self)

  • load (bool)

Return type:

bool

get(ary)

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

Parameters:

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

get_full_size()

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)

Return all input arrays required to compute this object.

Parameters:

input_box (OutputStruct)

Return type:

list[str]

classmethod initial(inputs)

Create a dummy instance with the given inputs.

load_all()

Load all possible arrays into memory.

classmethod new(inputs, redshift, **kw)

Create a new XraySourceBox 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:`XraySourceBox`

  • constructor.

Parameters:
Return type:

Self

prepare(flush=None, keep=None, force=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)

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, value)

Set the value of an array.

Parameters:
  • name (str)

  • value (Any)

summarize(indent=0)

Generate a string summary of the struct.

Parameters:

indent (int)

Return type:

str

__slots__ = ()
property arrays: dict[str, py21cmfast.wrapper.arrays.Array]

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

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 cstruct: py21cmfast.wrapper.structs.StructWrapper

The object pointing to the memory accessed by C-code for this struct.

Return type:

py21cmfast.wrapper.structs.StructWrapper

filtered_sfr
filtered_sfr_mini
filtered_xray
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 matter_options: py21cmfast.wrapper.inputs.MatterOptions

The SimulationOptions object for this output struct.

Return type:

py21cmfast.wrapper.inputs.MatterOptions

mean_log10_Mcrit_LW
mean_sfr
mean_sfr_mini
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 struct: py21cmfast.wrapper.structs.StructWrapper

The python-wrapped struct associated with this input object.

Return type:

py21cmfast.wrapper.structs.StructWrapper