H5D: HDF5 Dataset Interface

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

These functions create and manipulate dataset objects, and set and retrieve their constant or persistent properties.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
H5Dcreate           (h5loc, name, dtype_id, h5space, lcpl=NULL, dcpl=NULL, dapl=NULL)
H5Dopen             (h5loc, name, dapl=NULL)
H5Dclose            (h5dataset)
H5Dget_space        (h5dataset)
H5Dget_type         (h5dataset)
H5Dget_create_plist (h5dataset)
H5Dget_storage_size (h5dataset)
H5Dread             (h5dataset, h5spaceFile = NULL, h5spaceMem = NULL,
                     buf = NULL, compoundAsDataFrame = TRUE,
                     bit64conversion, drop = FALSE)
H5Dwrite            (h5dataset, buf, h5spaceMem = NULL, h5spaceFile = NULL)
H5Dset_extent       (h5dataset, size)

Arguments

h5loc

An object of class H5IdComponent representing a H5 location identifier (file or group). See H5Fcreate, H5Fopen, H5Gcreate, H5Gopen to create an object of this kind.

name

Name of the dataset (character).

dtype_id

A character name of a datatype. See h5const("H5T") for possible datatypes. Can also be an integer representing an HDF5 datatype.

h5space

An object of class H5IdComponent representing a H5 dataspace. See H5Dget_space, H5Screate_simple, H5Screate to create an object of this kind.

h5dataset

An object of class H5IdComponent representing a H5 dataset. See H5Dcreate, H5Dopen to create an object of this kind.

h5spaceFile,h5spaceMem

An object of class H5IdComponent representing a H5 dataspace. See H5Dget_space, H5Screate_simple, H5Screate to create an object of this kind. The dimensions of the dataset in the file and in memory. The dimensions in file and in memory are interpreted in an R-like manner. The first dimension is the fastest changing dimension. When reading the file with a C-program (e.g. HDFView) the order of dimensions will invert, because in C the fastest changing dimension is the last one.

buf

Reading and writing buffer containing the data to written/read. When using the buffer for reading, the buffer size has to fit the size of the memory space h5spaceMem. No extra memory will be allocated for the data. A pointer to the same data is returned.

compoundAsDataFrame

If true, a compound datatype will be coerced to a data.frame. This is not possible, if the dataset is multi-dimensional. Otherwise the compound datatype will be returned as a list. Nested compound data types will be returned as a nested list.

bit64conversion

Defines, how 64-bit integers are converted. Internally, R does not support 64-bit integers. All integers in R are 32-bit integers. By setting bit64conversion='int', a coercing to 32-bit integers is enforced, with the risc of data loss, but with the insurance that numbers are represented as integers. bit64conversion='double' coerces the 64-bit integers to floating point numbers. doubles can represent integers with up to 54-bits, but they are not represented as integer values anymore. For larger numbers there is again a data loss. bit64conversion='bit64' is recommended way of coercing. It represents the 64-bit integers as objects of class 'integer64' as defined in the package 'bit64'. Make sure that you have installed 'bit64'. The datatype 'integer64' is not part of base R, but defined in an external package. This can produce unexpected behaviour when working with the data.

drop

(logical) If TRUE, the HDF5 object is read as a vector with NULL dim attributes.

size

An integer vector with the new dimension of the dataset. Calling this function is only valid for chunked datasets.

lcpl

An object of class H5IdComponent representing a H5 link creation property list. See H5Pcreate, H5Pcopy to create an object of this kind.

dcpl

An object of class H5IdComponent representing a H5 dataset creation property list. See H5Pcreate, H5Pcopy to create an object of this kind.

dapl

An object of class H5IdComponent representing a H5 dataset access property list. See H5Pcreate, H5Pcopy to create an object of this kind.

Details

Interface to the HDF5 C-library libhdf5. See https://portal.hdfgroup.org/display/HDF5/Datasets for further details.

Value

H5Dcreate and H5Dopen return an object of class H5IdComponent represinting a H5 dataset identifier.

H5Dget_space returns an object of class H5IdComponent representing a H5 dataspace identifier.

H5Dread returns an array with the read data.

The other functions return the standard return value from their respective C-functions.

Author(s)

Bernd Fischer

References

https://portal.hdfgroup.org/display/HDF5

See Also

rhdf5

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# write a dataset
fid <- H5Fcreate("ex_H5D.h5")
fid
sid <- H5Screate_simple(c(10,5,3))
sid
did <- H5Dcreate(fid, "A", "H5T_STD_I32LE", sid)
did
H5Dwrite(did, 1L:150L, h5spaceMem = sid, h5spaceFile = sid)
H5Dclose(did)
H5Sclose(sid)
H5Fclose(fid)

# read a dataset
fid <- H5Fopen("ex_H5D.h5")
fid
did <- H5Dopen(fid, "A")
did
sid <- H5Dget_space(did)
sid
B <- H5Dread(did)
B
H5Dclose(did)
H5Sclose(sid)
H5Fclose(fid)

# write a subarray
fid <- H5Fopen("ex_H5D.h5")
fid
did <- H5Dopen(fid, "A")
did
sid <- H5Dget_space(did)
sid
H5Sselect_index(sid, list(1:3,2:4,2))
sidmem <- H5Screate_simple(c(3,3,1))
sidmem
A = array(-801:-809,dim=c(3,3,1))
H5Dwrite(did, A, h5spaceMem = sidmem, h5spaceFile = sid)
H5Dread(did)
H5Sclose(sid)
H5Dclose(did)
H5Sclose(sidmem)
H5Fclose(fid)

Example output

HDF5 FILE
        name /
    filename 

[1] name   otype  dclass dim   
<0 rows> (or 0-length row.names)
HDF5 DATASPACE
        rank 3
        size 10 x 5 x 3
     maxsize 10 x 5 x 3
HDF5 DATASET
        name /A
    filename 
        type H5T_STD_I32LE
        rank 3
        size 10 x 5 x 3
     maxsize 10 x 5 x 3
HDF5 FILE
        name /
    filename 

  name       otype  dclass        dim
0    A H5I_DATASET INTEGER 10 x 5 x 3
HDF5 DATASET
        name /A
    filename 
        type H5T_STD_I32LE
        rank 3
        size 10 x 5 x 3
     maxsize 10 x 5 x 3
HDF5 DATASPACE
        rank 3
        size 10 x 5 x 3
     maxsize 10 x 5 x 3
, , 1

      [,1] [,2] [,3] [,4] [,5]
 [1,]    1   11   21   31   41
 [2,]    2   12   22   32   42
 [3,]    3   13   23   33   43
 [4,]    4   14   24   34   44
 [5,]    5   15   25   35   45
 [6,]    6   16   26   36   46
 [7,]    7   17   27   37   47
 [8,]    8   18   28   38   48
 [9,]    9   19   29   39   49
[10,]   10   20   30   40   50

, , 2

      [,1] [,2] [,3] [,4] [,5]
 [1,]   51   61   71   81   91
 [2,]   52   62   72   82   92
 [3,]   53   63   73   83   93
 [4,]   54   64   74   84   94
 [5,]   55   65   75   85   95
 [6,]   56   66   76   86   96
 [7,]   57   67   77   87   97
 [8,]   58   68   78   88   98
 [9,]   59   69   79   89   99
[10,]   60   70   80   90  100

, , 3

      [,1] [,2] [,3] [,4] [,5]
 [1,]  101  111  121  131  141
 [2,]  102  112  122  132  142
 [3,]  103  113  123  133  143
 [4,]  104  114  124  134  144
 [5,]  105  115  125  135  145
 [6,]  106  116  126  136  146
 [7,]  107  117  127  137  147
 [8,]  108  118  128  138  148
 [9,]  109  119  129  139  149
[10,]  110  120  130  140  150

HDF5 FILE
        name /
    filename 

  name       otype  dclass        dim
0    A H5I_DATASET INTEGER 10 x 5 x 3
HDF5 DATASET
        name /A
    filename 
        type H5T_STD_I32LE
        rank 3
        size 10 x 5 x 3
     maxsize 10 x 5 x 3
HDF5 DATASPACE
        rank 3
        size 10 x 5 x 3
     maxsize 10 x 5 x 3
HDF5 DATASPACE
        rank 3
        size 3 x 3 x 1
     maxsize 3 x 3 x 1
, , 1

      [,1] [,2] [,3] [,4] [,5]
 [1,]    1   11   21   31   41
 [2,]    2   12   22   32   42
 [3,]    3   13   23   33   43
 [4,]    4   14   24   34   44
 [5,]    5   15   25   35   45
 [6,]    6   16   26   36   46
 [7,]    7   17   27   37   47
 [8,]    8   18   28   38   48
 [9,]    9   19   29   39   49
[10,]   10   20   30   40   50

, , 2

      [,1] [,2] [,3] [,4] [,5]
 [1,]   51 -801 -804 -807   91
 [2,]   52 -802 -805 -808   92
 [3,]   53 -803 -806 -809   93
 [4,]   54   64   74   84   94
 [5,]   55   65   75   85   95
 [6,]   56   66   76   86   96
 [7,]   57   67   77   87   97
 [8,]   58   68   78   88   98
 [9,]   59   69   79   89   99
[10,]   60   70   80   90  100

, , 3

      [,1] [,2] [,3] [,4] [,5]
 [1,]  101  111  121  131  141
 [2,]  102  112  122  132  142
 [3,]  103  113  123  133  143
 [4,]  104  114  124  134  144
 [5,]  105  115  125  135  145
 [6,]  106  116  126  136  146
 [7,]  107  117  127  137  147
 [8,]  108  118  128  138  148
 [9,]  109  119  129  139  149
[10,]  110  120  130  140  150

rhdf5 documentation built on Nov. 8, 2020, 6:56 p.m.