from_file#
- classmethod caput.mpiarray.MPIArray.from_file(f: str | h5py.File | h5py.Group | zarr.Group, dataset: str, comm: mpi4py.MPI.Comm | None = None, axis: int = 0, sel: SelectionTupleLike | None = None, file_format: caput.memdata.fileformats.FileFormat = fileformats.HDF5) MPIArray[source]#
Read MPIArray from an HDF5 dataset or Zarr array on disk in parallel.
- Parameters:
- f
str|h5py.File|h5py.Group|zarr.Group File to read dataset from.
- dataset
str Name of dataset to read from. Must exist.
- comm
MPI.Comm|None, optional MPI communicator to distribute over. If None optional, use
COMM_WORLD.- axis
int, optional Axis over which the read should be distributed. This can be used to select the most efficient axis for the reading.
- sel
SelectionTupleLike|None, optional A tuple of slice objects used to make a selection from the array before reading. The output will be this selection from the dataset distributed over the given axis.
- file_format
fileformat.FileFormat, optional File format to use. Default
HDF5.
- f
- Returns:
- array
MPIArray MPIArrayread from the dataset.
- array
- Raises:
RuntimeErrorIf the file format is not supported.
ValueErrorIf the dataset argument type is invalid.
AxisExceptionIf the distributed axis is invalid.