H5File

H5File

Representation of a HDF5 file as a top-level group.

Constructor

new H5File(file, optionsopt)

Source:
Parameters:
Name Type Attributes Default Description
file string

Path to the HDF5 file.

options object <optional>
{}

Further options to pass to the H5Group constructor.

Extends

Classes

H5File

Members

attributes :Array

Source:
Overrides:

Array containing the names of all attributes of this object.

Type:
  • Array

children :object

Source:
Overrides:

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:
Overrides:
Parameters:
Name Type Attributes Default Description
name string

Name of the dataset to create.

type string

Type of dataset to create, see H5DataSet.type.

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
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.

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:
Overrides:
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:
Overrides:
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;

  • values, an array containing the values of the attribute. This is of length 1 if the attribute is scalar.
  • shape, an array specifying the shape of the attribute. This is empty if the attribute is scalar.
  • type, the type of the attribute. This may be a string, a H5StringType, a H5EnumType or a H5CompoundType.
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 | H5StringType | H5EnumType | H5CompoundType

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

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.

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

Source:
Overrides:

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, see H5DataSet.type.

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 H5DataSet.write.

options object <optional>
{}

Optional parameters.

Properties
Name Type Attributes Default Description
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.

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