xdas.virtual.VirtualLayout#

class xdas.virtual.VirtualLayout(shape, dtype, maxshape=None, filename=None)[source]#

A lazy array layout pointing toward multiple netCDF4/HDF5 files.

Instantiate this class with the final shape of the virtual array. Then Fill it up by assigning to slices of it VirtualSource objects.

Once the data assignement is completed, the layout can be virually written into a h5py.File or h5py.Group object using the to_dataset method.

The VirtualLayout can be sliced and the selected data accessed without writting the layout to disk. To that end, use numpy.asarray or the __array__ special method. Note that for now, sliced VirtualLayout cannot be written to disk.

Parameters:
  • shape (tuple of int) – The shape of the layout.

  • dtype (str of dtype) – The dtype of the layout.

  • maxshape (tuple of int or None, optional) – The layout is resizable up to this shape. Use None for axes you want to be unlimited.

  • filename (str, optional) – The name of the destination file, if known in advance. Mappings from data in the same file will be stored with filename ‘.’, allowing the file to be renamed later.

shape#

The shape of the layout.

Type:

tuple of int or

dtype#

The dtype of the layout.

Type:

dtype

ndim#

The number of dimensions of the layout.

Type:

int

nbytes#

The number of bytes virtually linked into the layout.

Type:

int

to_dataset(file_or_group, name)[source]#

Writes virtually the layout into the specified HDF5 file of group with the given name.

__init__(shape, dtype, maxshape=None, filename=None)[source]#

Methods

__init__(shape, dtype[, maxshape, filename])

create_variable(file, name[, dims, dtype])

Write this virtual array into file and register it as a named variable.

to_dataset(file_or_group, name)

Write the layout as an HDF5 virtual dataset in file_or_group.

Attributes

dtype

NumPy dtype of the layout.

empty

True if the array contains no elements.

nbytes

Total number of bytes occupied by the array elements.

ndim

Number of dimensions.

shape

Shape of the layout after any lazy selections.

size

Total number of elements.