hdf5

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package hdf5 reads the parts of the HDF5 file format that the open science centre's strain files use, as the HDF5 File Format Specification, version 3.0, describes them, and refuses the rest.

It reads a version 0 superblock with eight-byte offsets and lengths, version 1 object headers and their continuations, and old-style groups: a version 1 B-tree of symbol table nodes over a local heap of names.

It reads datasets and attributes of little-endian integers, binary32 and binary64 floats, and fixed and variable-length strings.

A dataset is contiguous or chunked, and a chunk may be deflated and may carry a Fletcher-32 checksum, which is checked.

Anything else is refused with ErrUnsupported, which names the part and its section of the specification. Bytes that contradict the specification or themselves are refused with ErrCorrupt, and bytes that are not HDF5 at all with ErrNotHDF5. A refusal gives nothing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrCorrupt

func ErrCorrupt() error

ErrCorrupt is the cause of a refusal when the file contradicts the specification or itself: a field out of range, an address outside the file, a checksum that does not match, a stream that does not inflate.

func ErrNotFound

func ErrNotFound() error

ErrNotFound is the cause of an error when a path or an attribute name is not in the file.

func ErrNotHDF5

func ErrNotHDF5() error

ErrNotHDF5 is the cause of a refusal when the bytes are not an HDF5 file: the format signature is missing.

func ErrUnsupported

func ErrUnsupported() error

ErrUnsupported is the cause of a refusal when the file is HDF5 but uses a part of the format this reader does not read. The refusal names the part.

func ErrWrongType

func ErrWrongType() error

ErrWrongType is the cause of an error when a read asks for a kind of value the object does not hold, such as text from a float dataset.

Types

type File

type File struct {
	// contains filtered or unexported fields
}

File is an open HDF5 file. It reads from the io.ReaderAt it was given, when asked, and holds nothing of the file but its superblock.

func NewFile

func NewFile(reader io.ReaderAt, size int64) (*File, error)

NewFile opens the HDF5 file a reader holds, so many bytes long. It refuses a file that is not HDF5 with ErrNotHDF5, one that uses a part of the format this reader does not read with ErrUnsupported, saying which part and where, and a size below nothing, and then gives no file.

func (*File) Attribute

func (file *File) Attribute(path, name string) (*Values, error)

Attribute is the elements of an attribute of the group or dataset at a path, by its name, such as Xspacing on strain/Strain. It refuses a path or a name the file does not have, and then gives none.

func (*File) Members

func (file *File) Members(path string) ([]string, error)

Members is the names of the members of the group at a path, in order. The path "" and "/" are the root group. It refuses a path the file does not have and an object there that is no group, and then gives none.

func (*File) Read

func (file *File) Read(path string) (*Values, error)

Read is the elements of the dataset at a path of names joined by slashes, such as strain/Strain. It refuses a path the file does not have, an object there that is no dataset, and a dataset this reader cannot read, and then gives none.

type Values

type Values struct {
	// contains filtered or unexported fields
}

Values is the elements of a dataset or an attribute as read: their shape, and the bytes the file holds, decoded when asked for in a kind.

func (*Values) Floats

func (held *Values) Floats() ([]float64, error)

Floats is the values as floats, in the file's order. It refuses values that are not floating-point, and then gives none.

func (*Values) Integers

func (held *Values) Integers() ([]int64, error)

Integers is the values as integers, in the file's order. It refuses values that are not fixed-point, and then gives none.

func (*Values) Shape

func (held *Values) Shape() []uint64

Shape is the size of each of the values' dimensions; a scalar has none.

func (*Values) Texts

func (held *Values) Texts() ([]string, error)

Texts is the values as text, fixed or variable in length, in the file's order. It refuses values that are not strings, and then gives none.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL