# H5 Objects

Describe the properties of the different H5 objects

## Contents

- H5 File

- H5 Group

- H5 Dataset

- H5 Dataspace

- H5Attribute

- H5 Type

- H5 Reference

## Description

H5 objects have some accessible properties. All the properties name are case insensitive (except for the path or objects names).

## H5 File

The following properties can be accessed:

- name: the filename;

- size: the file size;

- version: the HDF5 library version;

- root: the root group "/".

If the field name starts with '/', then it is considered as a path and the returned value is the H5 object corresponding to this path.

    x = [1 2;3 4];
    save(TMPDIR + "/x.sod", "x");
    a = h5open(TMPDIR + "/x.sod");

    // a is a file
    h5isFile(a)

    // Access to the properties
    a.name, a.size, a.version, a.root

    // Open the dataset x
    a("/x")

    // Free all the resources
    h5close(a);

## H5 Group

The following properties can be accessed:

- attributes: the attributes names;

- groups: the subgroups names;

- datasets: the datasets names;

- types: the types names;

- externals: the external links names;

- softs: the soft links names;

- danglings: the dangling links names;

- hards: the hard links names;

- links: the links names and types;

- name: the group name;

- path: the group path.

If the field name is not in the previous list, then it is considered as a local path to another H5 object.

    x = [1 2;3 4];
    save(TMPDIR + "/x.sod", "x");
    a = h5open(TMPDIR + "/x.sod");
    root = a.root;

    // root is a group
    h5isGroup(root)

    // Access to the properties
    root.name, root.path, root.datasets, root.attributes

    // Open the dataset x
    dset_x = root.x

    // Free all the resources
    h5close(a);

## H5 Dataset

The following properties can be accessed:

- attributes: the attributes names;

- type: the dataset type;

- dataspace: the dataset space;

- data: the dataset data;

- name: the group name;

- path: the group path.

If the field name is not in the previous list, then it is considered as an attribute name.

    x = [1 2;3 4];
    save(TMPDIR + "/x.sod", "x");
    a = h5open(TMPDIR + "/x.sod");
    dset_x = a.root.x;

    // dset_x is a dataset
    h5isSet(dset_x)

    // Access to the properties
    dset_x.attributes, dset_x.type, dset_x.dataspace, dset_x.data

    // Open the attribute x
    attr_x = dset_x.SCILAB_Class

    // Free all the resources
    h5close(a);

## H5 Dataspace

The following properties can be accessed:

- dims: the dataspace dimensions;

- extents: the dataspace max dimensions;

- type: the dataspace type: "scalar", "simple" or "null";

- name: the parent name.

- path: the parent path.

    x = [1 2;3 4];
    save(TMPDIR + "/x.sod", "x");
    a = h5open(TMPDIR + "/x.sod");
    dspace_x = a.root.x.dataspace;

    // dspace_x is a space
    h5isSpace(dspace_x)

    // Access to the properties
    dspace_x.dims, dspace_x.extents, dspace_x.type

    // Free all the resources
    h5close(a);

## H5 Attribute

The following properties can be accessed:

- type: the attribute type;

- dataspace: the attribute dataspace;

- data: the attribute data;

- name: the attribute name.

- path: the parent path.

    x = [1 2;3 4];
    save(TMPDIR + "/x.sod", "x");
    a = h5open(TMPDIR + "/x.sod");
    attr_x = a.root.x.SCILAB_Class;

    // attr_x is an attribute
    h5isAttr(attr_x)

    // Access to the properties
    attr_x.type, attr_x.dataspace, attr_x.data

    // Free all the resources
    h5close(a);

## H5 Type

The following properties can be accessed:

- class: the type class;

- type: the type name;

- size: the size in bytes;

- nativetype: the native type associated with this type;

- nativesize: the size of the native type.

- name: the parent name.

- path: the parent path.

    x = [1 2;3 4];
    save(TMPDIR + "/x.sod", "x");
    a = h5open(TMPDIR + "/x.sod");
    type_x = a.root.x.type;

    // type_x is a type
    h5isType(type_x)

    // Access to the properties
    type_x.class, type_x.type, type_x.size, type_x.nativetype, type_x.nativesize,

    // Free all the resources
    h5close(a);

## H5 Reference

H5 Reference object wrap an hypermatrix object where elements are a reference to an H5 object.

    x = list([1 2;3 4], "Hello", uint32(123));
    save(TMPDIR + "/x.sod", "x");
    a = h5open(TMPDIR + "/x.sod");
    dims_x = a.root.x.dataspace.dims
    ref_x = a.root.x.data;

    // ref_x is a reference
    h5isRef(ref_x)

    // Get the 3 elements
    x1 = ref_x(1), x2 = ref_x(2), x3 = ref_x(3)

    // Get the data
    x1.data, x2.data, x3.data

    // Free all the resources
    h5close(a);

## See Also

- h5attr
- h5close
- h5cp
- h5dataset
- h5dump
- h5exists
- h5flush
- h5get
- h5group
- h5isAttr
- h5isFile
- h5isGroup
- h5isRef
- h5isSet
- h5isSpace
- h5isType
- h5label
- h5ln
- h5ls
- h5mount
- h5mv
- h5open
- h5read
- h5rm
- h5umount
- h5write
- h5writeattr

## History

5.5.0
HDF5 module introduced.