fields.buffers.core.HDF5Buffer.create_dataset#
- classmethod HDF5Buffer.create_dataset(file: str | Path | File, name: str, shape: tuple | None = None, dtype: Any | None = None, *, data: ndarray | list | unyt_array | None = None, overwrite: bool = False, units: str | Unit | None = None, **kwargs) Dataset [source]#
Create a new HDF5 dataset with optional unit metadata.
- Parameters:
file (
str
,Path
, orh5py.File
) – Path to HDF5 file or open file handle.name (
str
) – Name of the dataset inside the HDF5 file.shape (
tuple
ofint
, optional) – Shape of the dataset, if not using data.dtype (
data-type
, optional) – Desired data type. If not given, inferred from data.data (
array-like
, optional) – Initial values. Will be coerced to a unyt_array.overwrite (
bool
, defaultFalse
) – Whether to overwrite an existing dataset.units (
str
orUnit
, optional) – Units to attach to the dataset. If not provided and data has units, they are preserved.**kwargs – Additional arguments to
create_dataset()
.
- Returns:
The created dataset.
- Return type: