Learn R Programming

rhdf5 (version 2.16.0)

HDF5 Dataspace Interface: HDF5 Dataspace Interface

Description

These functions create and manipulate the dataspace in which to store the elements of a dataset.

Usage

H5Screate (type = h5default("H5S")) H5Screate_simple (dims, maxdims ) H5Scopy (h5space) H5Sclose (h5space) H5Sis_simple (h5space) H5Sget_simple_extent_dims (h5space) H5Sset_extent_simple (h5space, dims, maxdims) H5Sselect_hyperslab (h5space, op = h5default("H5S_SELECT"), start = NULL, stride = NULL, count = NULL, block = NULL) H5Sselect_index (h5space, index)

Arguments

type
See h5const("H5S") for possible types.
dims
Dimension of the dataspace. This argument is similar to the dim attribute of an array. When viewing the HDF5 dataset with an C-program (e.g. HDFView), the dimensions appear in inverted order, because the fastest changing dimension in R is the first one, and in C its the last one.
maxdims
Maximum extension of the dimension of the dataset in the file. If not provided, it is set to dims.
h5space
An object of class H5IdComponent representing a H5 dataspace identifier. See H5Dget_space, H5Screate_simple, H5Screate to create an object of this kind.
index
A list of integer indices. The length of the list corresponds to the number of dimensions of the HDF5 array.
op
See h5const("H5S_SELECT") for possible arguments.
start
The start coordinate of a hyperslab (similar to subsetting in R). Counting is R-style 1-based.
stride
The stride of the hypercube. Read the introduction http://ftp.hdfgroup.org/HDF5/Tutor/phypecont.html before using this argument. R behaves like Fortran in this example.
count
The number of blocks to be written.
block
The block size of the hyperslab. Read the introduction http://ftp.hdfgroup.org/HDF5/Tutor/phypecont.html before using this argument. R behaves like Fortran in this example.

Value

H5Screate, H5Screate_simple, and H5Scopy return an object of class H5IdComponent representing a dataspace.H5Sis_simple returns a boolean.H5Sget_simple_extent_dims returns an integer vector.The other functions return the standard return value from their respective C-functions.

Details

Interface to the HDF5 C-library libhdf5. See http://www.hdfgroup.org/HDF5/doc/RM/RM_H5S.html for further details.

As an introduction to use hyperslabs see these tutorials: See these introductions to hyperslabs: http://www.hdfgroup.org/HDF5/Tutor/selectsimple.html, http://www.hdfgroup.org/HDF5/Tutor/select.html and http://ftp.hdfgroup.org/HDF5/Tutor/phypecont.html. Please note that in R the first dimension is the fastest changing dimension. When viewing the HDF5 datasets with any C-program (e.g. HDFView), the order of dimensions is inverted. In the R interface counting starts with 1, whereas in the C-programs (e.g. HDFView) counting starts with 0.

H5Sselect_index is not part of the standard HDF5 C interface. It performes an iterative call to H5select_points by iterating through the given index positions. This function avoids a for loop in R. If a list element is NULL, all elements of the respective dimension are considered.

References

http://www.hdfgroup.org/HDF5

See Also

rhdf5

Examples

Run this code
sid <- H5Screate_simple(c(10,5,3))
sid
H5Sis_simple(sid)
H5Sget_simple_extent_dims(sid)

# select a subarray (called hyperslab in the hdf5 community).
# The next h5write can use this to write a subarray
H5Sselect_index(sid, list(1:3,2:4,2))

# always close dataspaces after usage to free recources
H5Sclose(sid)
sid

Run the code above in your browser using DataLab