grids.core.UniformGrid.from_hdf5#

classmethod UniformGrid.from_hdf5(filename: str, group_name: str | None = None, **kwargs)[source]#

Load a UniformGrid from an HDF5 file.

This method reconstructs a grid previously saved using to_hdf5(). It restores the domain shape, bounding box, ghost zones, chunking structure, coordinate system, and unit metadata.

Parameters:
  • filename (str) – Path to the HDF5 file to load from.

  • group_name (str, optional) – Name of the HDF5 group in which the grid was saved. If None, loads from the file root.

  • **kwargs – Additional keyword arguments passed to the grid constructor.

Returns:

Fully reconstructed grid instance.

Return type:

UniformGrid

Raises:

IOError – If the file or group does not exist, or if required metadata is missing.

Notes

The method expects a file structure produced by to_hdf5(), including the necessary attributes and subgroups. For example:

├── [attrs]
│   ├── axes                → list of str
│   ├── chunking            → bool
│   ├── chunk_size          → list[int]
│   ├── grid_shape          → list[int]
│   ├── bbox                → (2, ndim) array
│   ├── ghost_zones         → (2, ndim) array
│   ├── coordinate_system   → str
│   └── centered            → bool
│
├── units/                  → group of base unit strings
└── coord_systm/            → symbolic data for coordinate system reconstruction

The coordinate arrays are not saved to disk, because they are deterministically defined from the bounding box and resolution.