Get the dimensions of an HDF5 dataset
h5dim.Rd
Two convenience functions to obtain the dimensions of an HDF5 dataset as well as the dimensions of its chunks.
Arguments
- filepath
The path (as a single string) to an HDF5 file.
- name
The name (as a single string) of a dataset in the HDF5 file.
- as.integer
By default
h5dim()
returns the dimensions of the dataset in an integer vector and will raise an error if any dimension is greater than.Machine$integer.max
(= 2^31 - 1).Use
as.integer=FALSE
to support datasets with dimensions greater than.Machine$integer.max
. In this case the dimensions are returned in a numeric vector.- adjust
By default
h5chunkdim()
returns the dimensions of the chunks as reported byH5Pget_chunk
from the C HDF5 API. Note that the HDF5 specs allow some or all the dimensions of the chunks to be greater than the dimensions of the dataset.You can use
adjust=TRUE
to requesth5chunkdim()
to return adjusted chunk dimensions, that is, dimensions that do not exceed the dimensions of the dataset. The adjusted chunk dimensions are simply obtained by replacing those dimensions in the vector of chunk dimensions that are greater than the corresponding dataset dimension with the latter.
Examples
test_h5 <- system.file("extdata", "test.h5", package="h5mread")
h5ls(test_h5)
#> Warning: An open HDF5 file handle exists. If the file has changed on disk meanwhile, the function may not work properly. Run 'h5closeAll()' to close all open HDF5 object handles.
#> group name otype dclass dim
#> 0 / .m2_dimnames H5I_GROUP
#> 1 /.m2_dimnames 1 H5I_DATASET STRING 4000
#> 2 /.m2_dimnames 2 H5I_DATASET STRING 90
#> 3 / a3 H5I_DATASET INTEGER 180 x 75 x 4
#> 4 / m1 H5I_DATASET INTEGER 12 x 5
#> 5 / m2 H5I_DATASET FLOAT 4000 x 90
#> 6 / m4 H5I_DATASET INTEGER 28 x 4000
#> 7 / rwords H5I_DATASET STRING 30000
h5dim(test_h5, "m2")
#> [1] 4000 90
h5chunkdim(test_h5, "m2")
#> [1] 50 40
h5dim(test_h5, "a3")
#> [1] 180 75 4
h5chunkdim(test_h5, "a3")
#> [1] 20 20 4