H5Group

H5Group

Representation of a group inside a HDF5 file.

Constructor

new H5Group(file, name)

Source:
Parameters:
Name Type Description
file string

Path to the HDF5 file.

name string

Name of the group inside the file.

Extends

Classes

H5Group

Members

attributes :Array

Source:
Overrides:

Array containing the names of all attributes of this object.

Type:
  • Array

children :object

Source:

An object where the keys are the names of the immediate children and the values are strings specifying the object type of each child. Each string can be one of "Group", "DataSet" or "Other".

Type:
  • object

file :string

Source:
Overrides:

Path to the HDF5 file.

Type:
  • string

name :string

Source:
Overrides:

Name of the object inside the file.

Type:
  • string

Methods

createDataSet(name, type, shape, optionsopt) → {H5DataSet}

Source:
Parameters:
Name Type Attributes Default Description
name string

Name of the dataset to create.

type string

Type of dataset to create. This can be "IntX" or "UintX" for X of 8, 16, 32, or 64; or "FloatX" for X of 32 or 64; or "String"; or "Enum".

shape Array

Array containing the dimensions of the dataset to create. This can be set to an empty array to create a scalar dataset.

options object <optional>
{}

Optional parameters.

Properties
Name Type Attributes Default Description
maxStringLength number <optional>
10

Maximum length of the strings to be saved. Only used when type = "String".

compression number <optional>
6

Deflate compression level.

chunks Array <optional>
<nullable>
null

Array containing the chunk dimensions. This should have length equal to shape, with each value being no greater than the corresponding value of shape. If null, it defaults to shape.

levels Array <optional>
<nullable>
null

Array of strings containing enum levels. Only used (and mandatory) when type = "Enum".

Returns:

A dataset of the specified type and shape is created as an immediate child of the current group. A H5DataSet object is returned representing this new dataset.

Type
H5DataSet

createGroup(name)

Source:
Parameters:
Name Type Description
name string

Name of the group to create.

Returns:

{@H5Group} A group is created as an immediate child of the current group. A H5Group object is returned representing this new group. If a group already exists at name, it is returned directly.

open(name, optionsopt) → {H5Group|H5DataSet}

Source:
Parameters:
Name Type Attributes Default Description
name string

Name of the child element to open.

options object <optional>
{}

Further options to pass to the H5Group or H5DataSet constructors.

Returns:

Object representing the child element.

Type
H5Group | H5DataSet

readAttribute(attr) → {object}

Source:
Overrides:

Read an attribute of the object.

Parameters:
Name Type Description
attr string

Name of the attribute.

Returns:

Object containing the attribute values and the shape of the attribute. For HDF5 enums, an additional level property is present, containing the levels indexed by the integer values.

Type
object

writeAttribute(attr, type, shapenullable, x, optionsopt)

Source:
Overrides:

Write an attribute for the object.

Parameters:
Name Type Attributes Default Description
attr string

Name of the attribute.

type string

Type of dataset to create. This can be "IntX" or "UintX" for X of 8, 16, 32, or 64; or "FloatX" for X of 32 or 64; or "String"; or "Enum".

shape Array <nullable>

Array containing the dimensions of the dataset to create. If set to an empty array, this will create a scalar dataset. If set to null, this is determined from x.

x TypedArray | Array | string | number

Values to be written to the new dataset, see write. This should be of length equal to the product of shape; unless shape is empty, in which case it should either be of length 1, or a single number or string.

options object <optional>
{}

Optional parameters.

Properties
Name Type Attributes Default Description
maxStringLength number <optional>
<nullable>
null

Maximum length of the strings to be saved. Only used when type = "String". If null, this is inferred from the maximum length of strings in x.

levels Array <optional>
<nullable>
null

Array of strings containing enum levels when type = "Enum". If supplied, x should be an array of integers that index into levels. Alternatively, levels may be null, in which case x should be an array of strings that is used to infer levels.

writeDataSet(name, type, shape, x, optionsopt) → {H5DataSet}

Source:

This convenience method combines createDataSet with write. It is particularly useful for string types as it avoids having to specify the maxStringLength during creation based on the x used during writing.

Parameters:
Name Type Attributes Default Description
name string

Name of the dataset to create.

type string

Type of dataset to create. This can be "IntX" or "UintX" for X of 8, 16, 32, or 64; or "FloatX" for X of 32 or 64; or "String".

shape Array

Array containing the dimensions of the dataset to create. If set to an empty array, this will create a scalar dataset. If set to null, this is determined from x.

x TypedArray | Array | string | number

Values to be written to the new dataset, see write.

options object <optional>
{}

Optional parameters.

Properties
Name Type Attributes Default Description
levels Array <optional>
<nullable>
null

Array of strings containing enum levels when type = "Enum". If supplied, x should be an array of integers that index into levels. Alternatively, levels may be null, in which case x should be an array of strings that is used to infer levels.

compression number <optional>
6

Deflate compression level.

chunks Array <optional>
<nullable>
null

Array containing the chunk dimensions. This should have length equal to shape, with each value being no greater than the corresponding value of shape. If null, it defaults to shape.

cache boolean <optional>
false

Whether to cache the written values in the returned H5DataSet object.

Returns:

A dataset of the specified type and shape is created as an immediate child of the current group. The same dataset is then filled with the contents of x. A H5DataSet object is returned representing this new dataset.

Type
H5DataSet