Selecting a Portion of a DataspaceHDF5 allows you to read or write to a portion of a dataset by use of hyperslab selection. A hyperslab selection can be a logically contiguous collection of points in a dataspace, or it can be a regular pattern of points or blocks in a dataspace. You can select a hyperslab to write to or read from with the function H5Sselect_hyperslab / h5sselect_hyperslab_f.
DescriptionThis example creates a 5 x 6 integer array in a file called
sdsf.h5in FORTRAN). It selects a 3 x 4 hyperslab from the dataset as follows (Dimension 0 is offset by 1 and Dimension 1 is offset by 2):
5 x 6 array:
Then it reads the hyperslab from this file into a 2-dimensional plane (size 7 x 7) of a 3-dimensional array (size 7 x 7 x 3), as follows (with Dimension 0 offset by 3):
To obtain the example, download:here.
- H5Sselect_hyperslab / h5sselect_hyperslab_f
selects a hyperslab region to
add to the current selected region for a specified dataspace.
Be aware that the start (offset), stride, count and block arrays all work together to define a selection. A change to one of these parameters can affect the other parameters.
The start, stride, count, and block arrays must be the same size as the rank of the dataspace.
- The example programs introduce the H5Dget_space / h5dget_space_f call to obtain the dataspace of a dataset.
The C examples also introduce H5Sget_simple_extent_dims / h5sget_simple_extent_dims_f to retrieve the dataspace dimension size of a dataset, and H5Sget_simple_extent_ndims / h5sget_simples_extent_ndims_f for obtaining the number of dimensions (rank) in a dataspace.
- - Last modified: 23 September 2011