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:
fstr | h5py.File | h5py.Group | zarr.Group

File to read dataset from.

datasetstr

Name of dataset to read from. Must exist.

commMPI.Comm | None, optional

MPI communicator to distribute over. If None optional, use COMM_WORLD.

axisint, optional

Axis over which the read should be distributed. This can be used to select the most efficient axis for the reading.

selSelectionTupleLike | 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_formatfileformat.FileFormat, optional

File format to use. Default HDF5.

Returns:
arrayMPIArray

MPIArray read from the dataset.

Raises:
RuntimeError

If the file format is not supported.

ValueError

If the dataset argument type is invalid.

AxisException

If the distributed axis is invalid.