py21cmfast.io¶
I/O for the 21cmFAST package.
Submodules¶
Functions¶
|
Read the InputParameters from a cache file. |
|
Read an output struct from an HDF5 file. |
|
Write an output struct in standard HDF5 format. |
Package Contents¶
- py21cmfast.io.read_inputs(group: h5py.Group | pathlib.Path | h5py.File, safe: bool = True) py21cmfast.wrapper.inputs.InputParameters[source]¶
Read the InputParameters from a cache file.
- Parameters:
group (h5py.Group | Path | h5py.File) – A file, or HDF5 Group within a file, to read the input parameters from.
safe (bool, optional) – If in safe mode, errors will be raised if keys exist in the file that are not valid attributes of the InputParameters. Otherwise, only warnings will be raised.
- Returns:
inputs (InputParameters) – The input parameters contained in the file.
- Parameters:
group (h5py.Group | pathlib.Path | h5py.File)
safe (bool)
- Return type:
- py21cmfast.io.read_output_struct(path: pathlib.Path, group: str = '/', struct: str | None = None, safe: bool = True) py21cmfast.wrapper.outputs.OutputStruct[source]¶
Read an output struct from an HDF5 file.
- Parameters:
path (Path) – The path to the HDF5 file.
group (str, optional) – A path within the HDF5 heirarchy to the top-level of the OutputStruct. This is usually the root of the file.
struct – A string specifying the kind of OutputStruct to read (e.g. InitialConditions). Generally, this does not need to be provided, as cache files contain just a single output struct.
safe – Whether to read the file in “safe” mode. If True, keys found in the file that are not valid attributes of the struct will raise an exception. If False, only a warning will be raised.
- Returns:
OutputStruct – An OutputStruct that is contained in the cache file.
- Parameters:
path (pathlib.Path)
group (str)
struct (str | None)
safe (bool)
- Return type:
- py21cmfast.io.write_output_to_hdf5(output: py21cmfast.wrapper.outputs.OutputStruct, path: pathlib.Path, group: str | None = None, mode: str = 'w')[source]¶
Write an output struct in standard HDF5 format.
- Parameters:
output – The OutputStruct to write.
path (Path) – The path to write the output struct to.
group (str, optional) – The HDF5 group into which to write the object. By default, this is the root.
mode (str) – The mode in which to open the file.
- Parameters:
path (pathlib.Path)
group (str | None)
mode (str)