py21cmfast.io.caching.RunCache¶
- class py21cmfast.io.caching.RunCache¶
An object that specifies all cache files that should/can exist for a full run.
This object should be instantiated via the .from_inputs() class method.
The instance simply holds references to all possible cache files for a particular total simulation (including all evolution over redshift). Not all of these files might exist: if a file doesn’t exist it implies that the simulation has not run for that redshift/field yet. Attributes with values of None are not meant to exist as part of the simulation (e.g. they may be TsBox instances when USE_TS_FLUCT=False).
- classmethod from_example_file(path)¶
Create a RunCache object from an example file.
This method can be used to determine all the cache files that make up a full simulation, given a single example file. Note that this method is somewhat ambiguous when the input file is “high up” in the simulation heirarchy (e.g. InitialConditions or PerturbedField) because the input parameters to these objects may differ from those of the full simulation, in their astro_params and astro_options. For this reason, it is better to supply a cache object like IonizedBox or BrightnessTemp.
- Parameters:
path (Path | str) – The path to a particular file in cache. The returned OutputCache object will include this file.
- Parameters:
path (pathlib.Path | str)
- Return type:
Self
- classmethod from_inputs(inputs, cache)¶
Create a RunCache instance from input parameters and an OutputCache.
This method generates file paths for various output structures based on the provided input parameters and cache configuration.
- Parameters:
inputs (InputParameters) – The input parameters for the simulation.
cache (OutputCache) – The output cache object containing directory and path structure information.
- Returns:
RunCache – A new RunCache instance with file paths for various output structures.
- Parameters:
cache (OutputCache)
- Return type:
Self
- get_all_boxes_at_z(z=None, index=None, match_z_within=0.01, return_ics=False)¶
Return all boxes at or close to a given redshift.
- Parameters:
z (float) – The redshift at which to return the boxes.
index (int) – The node-redshift index at which to return the boxes.
match_z_within (float) – The maximum difference between the requested and closest available redshift.
- Returns:
dict[str, Box] – A dictionary mapping box names to their corresponding Box instances.
- Parameters:
z (float | None)
index (int | None)
match_z_within (float)
return_ics (bool)
- Return type:
dict[str, py21cmfast.wrapper.outputs.OutputStruct]
- get_coeval_at_z(z=None, index=None, match_z_within=0.01)¶
Return a Coeval object at or close to a given redshift.
- Parameters:
z (float) – The redshift at which to return the Coeval object.
index (int) – The node-redshift index at which to return the Coeval object.
match_z_within (float) – The maximum difference between the requested and closest available redshift.
- Returns:
Coeval – The Coeval object at the given redshift.
- Parameters:
z (float | None)
index (int | None)
match_z_within (float)
- get_ics()¶
Return the initial conditions.
- Return type:
- get_output_struct_at_z(kind, z=None, index=None, match_z_within=0.01)¶
Return an output struct of a given kind at or close to a given redshift.
- Parameters:
z (float) – The redshift at which to return an output struct.
index (int) – The node-redshift index at which to return the output struct.
allow_closest (bool) – Whether to allow the closest redshift available in the cache to be returned.
- Returns:
OutputStruct – The output struct corresponding to the kind and redshift.
- Parameters:
kind (type[py21cmfast.wrapper.outputs.OutputStruct] | str)
z (float | None)
index (int | None)
match_z_within (float)
- is_complete()¶
Whether the cache for the full simulation is complete.
- Return type:
bool
- is_complete_at(z=None, index=None)¶
Determine whether the simulation has been completed down to a given redshift.
- Parameters:
z (float | None)
index (float | None)
- Return type:
bool
- BrightnessTemp: dict[float, pathlib.Path]¶
- HaloBox: dict[float, pathlib.Path] | None¶
- HaloCatalog: dict[float, pathlib.Path] | None¶
- InitialConditions: pathlib.Path¶
- IonizedBox: dict[float, pathlib.Path]¶
- PerturbedField: dict[float, pathlib.Path]¶
- TsBox: dict[float, pathlib.Path]¶
- XraySourceBox: dict[float, pathlib.Path] | None¶
- inputs: py21cmfast.wrapper.inputs.InputParameters | None¶