hdf5

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

README

hdf5

Build status Build Status GoDoc

Naive cgo bindings for the C-API of hdf5.

WIP: No stable API for this package yet.

NOTE that starting with Go >= 1.6, one needs to run with GODEBUG=cgocheck=0 to disable the new stricter CGo rules.

Example

Note

  • Only version 1.8.x of HDF5 is supported.
  • In order to use HDF5 functions in more than one goroutine simultaneously, you must build the HDF5 library with threading support. Many binary distributions (RHEL/centos/Fedora packages, etc.) do not have this enabled. Therefore, you must build HDF5 yourself on these systems.

Known problems

  • the h5pt packet table interface is broken.
  • support for structs with slices and strings as fields is broken

License

Please see github.com/gonum/gonum for general license information, contributors, authors, etc on the Gonum suite of packages.

Documentation

Overview

Package hdf5 provides access to the HDF5 C library.

Index

Constants

View Source
const (
	D_CHUNK_CACHE_NSLOTS_DEFAULT int     = -1 // The number of chunk slots in the raw data chunk cache for this dataset
	D_CHUNK_CACHE_NBYTES_DEFAULT int     = -1 // The total size of the raw data chunk cache for this dataset
	D_CHUNK_CACHE_W0_DEFAULT     float64 = -1 // The chunk preemption policy for this dataset
)

Used to unset chunk cache configuration parameter. https://support.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetChunkCache

View Source
const (
	F_ACC_RDONLY  int = 0x0000 // absence of rdwr => rd-only
	F_ACC_RDWR    int = 0x0001 // open for read and write
	F_ACC_TRUNC   int = 0x0002 // Truncate file, if it already exists, erasing all data previously stored in the file.
	F_ACC_EXCL    int = 0x0004 // Fail if file already exists.
	F_ACC_DEBUG   int = 0x0008 // print debug info
	F_ACC_CREAT   int = 0x0010 // create non-existing files
	F_ACC_DEFAULT int = 0xffff // value passed to set_elink_acc_flags to cause flags to be taken from the parent file
)

File constants

View Source
const (
	NoCompression      = zlib.NoCompression
	BestSpeed          = zlib.BestSpeed
	BestCompression    = zlib.BestCompression
	DefaultCompression = zlib.DefaultCompression
)

Variables

View Source
var (
	P_DEFAULT        *PropList = newPropList(C._go_hdf5_H5P_DEFAULT())
	P_DATASET_CREATE PropType  = PropType(C._go_hdf5_H5P_DATASET_CREATE()) // Properties for dataset creation
	P_DATASET_ACCESS PropType  = PropType(C._go_hdf5_H5P_DATASET_ACCESS()) // Properties for dataset access
)

Functions

func Close

func Close() error

Close flushes all data to disk, closes all open identifiers, and cleans up memory. It should generally be called before your application exits.

func DisplayErrors

func DisplayErrors(on bool) error

DisplayErrors enables/disables HDF5's automatic error printing

func GarbageCollect

func GarbageCollect() error

GarbageCollect collects garbage on all free-lists of all types.

func IsHDF5

func IsHDF5(name string) bool

IsHDF5 Determines whether a file is in the HDF5 format.

Types

type ArrayType

type ArrayType struct {
	Datatype
}

func NewArrayType

func NewArrayType(base_type *Datatype, dims []int) (*ArrayType, error)

NewArrayType creates a new ArrayType. The base_type specifies the element type of the array and dims specify the dimensions of the array. The returned arraytype must be closed by the user when it is no longer needed.

func (*ArrayType) ArrayDims

func (t *ArrayType) ArrayDims() []int

ArrayDims returns the array dimensions.

func (*ArrayType) NDims

func (t *ArrayType) NDims() int

NDims returns the rank of an ArrayType.

type Attribute

type Attribute struct {
	Identifier
}

func (*Attribute) Close

func (s *Attribute) Close() error

Close releases and terminates access to an attribute.

func (*Attribute) Datatype

func (s *Attribute) Datatype() (*Datatype, error)

Datatype returns the HDF5 Datatype of the Attribute. The returned datatype must be closed by the user when it is no longer needed.

func (*Attribute) GetName

func (s *Attribute) GetName() (string, error)

func (*Attribute) GetType

func (s *Attribute) GetType() Identifier

Access the type of an attribute

func (*Attribute) Read

func (s *Attribute) Read(data interface{}, dtype *Datatype) error

Read reads raw data from a attribute into a buffer.

func (*Attribute) Space

func (s *Attribute) Space() *Dataspace

Space returns an identifier for a copy of the dataspace for a attribute.

func (*Attribute) Write

func (s *Attribute) Write(data interface{}, dtype *Datatype) error

Write writes raw data from a buffer to an attribute.

type CommonFG

type CommonFG struct {
	Identifier
}

CommonFG is for methods common to both File and Group

func (*CommonFG) AttributeNameByIndex added in v0.0.3

func (g *CommonFG) AttributeNameByIndex(idx uint) (string, error)

AttributeNameByIndex returns the name of the object at idx.

func (*CommonFG) CreateDataset

func (g *CommonFG) CreateDataset(name string, dtype *Datatype, dspace *Dataspace) (*Dataset, error)

CreateDataset creates a new Dataset. The returned dataset must be closed by the user when it is no longer needed.

func (*CommonFG) CreateDatasetWith

func (g *CommonFG) CreateDatasetWith(name string, dtype *Datatype, dspace *Dataspace, dcpl *PropList) (*Dataset, error)

CreateDatasetWith creates a new Dataset with a user-defined PropList. The returned dataset must be closed by the user when it is no longer needed.

func (*CommonFG) CreateGroup

func (g *CommonFG) CreateGroup(name string) (*Group, error)

CreateGroup creates and returns a new empty group and links it to a location in the file. The returned group must be closed by the user when it is no longer needed.

func (*CommonFG) LinkExists

func (g *CommonFG) LinkExists(name string) bool

LinkExists returns whether a link with the specified name exists in the group.

func (*CommonFG) NumObjects

func (g *CommonFG) NumObjects() (uint, error)

NumObjects returns the number of objects in the Group.

func (*CommonFG) ObjectNameByIndex

func (g *CommonFG) ObjectNameByIndex(idx uint) (string, error)

ObjectNameByIndex returns the name of the object at idx.

func (*CommonFG) ObjectTypeByIndex

func (g *CommonFG) ObjectTypeByIndex(idx uint) (GType, error)

ObjectTypeByIndex returns the type of the object at idx.

func (*CommonFG) OpenDataset

func (g *CommonFG) OpenDataset(name string) (*Dataset, error)

OpenDataset opens and returns a named Dataset. The returned dataset must be closed by the user when it is no longer needed.

func (*CommonFG) OpenDatasetWith

func (g *CommonFG) OpenDatasetWith(name string, dapl *PropList) (*Dataset, error)

OpenDatasetWith opens and returns a named Dataset with a user-defined PropList. The returned dataset must be closed by the user when it is no longer needed.

func (*CommonFG) OpenGroup

func (g *CommonFG) OpenGroup(name string) (*Group, error)

OpenGroup opens and returns an existing child group from this Group. The returned group must be closed by the user when it is no longer needed.

type CompoundType

type CompoundType struct {
	Datatype
}

func NewCompoundType

func NewCompoundType(size int) (*CompoundType, error)

NewCompoundType creates a new CompoundType. The size is the size in bytes of the compound datatype. The returned compound type must be closed by the user when it is no longer needed.

func (*CompoundType) Insert

func (t *CompoundType) Insert(name string, offset int, field *Datatype) error

Insert adds a new member to a compound datatype.

func (*CompoundType) MemberClass

func (t *CompoundType) MemberClass(mbr_idx int) TypeClass

MemberClass returns datatype class of compound datatype member.

func (*CompoundType) MemberIndex

func (t *CompoundType) MemberIndex(name string) int

MemberIndex returns the index of a compound or enumeration datatype member.

func (*CompoundType) MemberName

func (t *CompoundType) MemberName(mbr_idx int) string

MemberName returns the name of a compound or enumeration datatype member.

func (*CompoundType) MemberOffset

func (t *CompoundType) MemberOffset(mbr_idx int) int

MemberOffset returns the offset of a field of a compound datatype.

func (*CompoundType) MemberType

func (t *CompoundType) MemberType(mbr_idx int) (*Datatype, error)

MemberType returns the datatype of the specified member. The returned datatype must be closed by the user when it is no longer needed.

func (*CompoundType) NMembers

func (t *CompoundType) NMembers() int

NMembers returns the number of elements in a compound or enumeration datatype.

func (*CompoundType) Pack

func (t *CompoundType) Pack() error

Pack recursively removes padding from within a compound datatype. This is analogous to C struct packing and will give a space-efficient type on the disk. However, using this may require type conversions on more machines, so may be a worse option.

type Dataset

type Dataset struct {
	Identifier
	// contains filtered or unexported fields
}

func (*Dataset) AttributeNameByIndex

func (s *Dataset) AttributeNameByIndex(idx uint) (string, error)

AttributeNameByIndex returns the name of the object at idx.

func (*Dataset) Close

func (s *Dataset) Close() error

Close releases and terminates access to a dataset.

func (*Dataset) CreateAttribute

func (s *Dataset) CreateAttribute(name string, dtype *Datatype, dspace *Dataspace) (*Attribute, error)

Creates a new attribute at this location. The returned attribute must be closed by the user when it is no longer needed.

func (*Dataset) CreateAttributeWith

func (s *Dataset) CreateAttributeWith(name string, dtype *Datatype, dspace *Dataspace, acpl *PropList) (*Attribute, error)

Creates a new attribute at this location. The returned attribute must be closed by the user when it is no longer needed.

func (*Dataset) Datatype

func (s *Dataset) Datatype() (*Datatype, error)

Datatype returns the HDF5 Datatype of the Dataset. The returned datatype must be closed by the user when it is no longer needed.

func (*Dataset) NumAttributes

func (s *Dataset) NumAttributes() (uint, error)

NumAttributes returns the number of attributes in the dataset

func (*Dataset) OpenAttribute

func (s *Dataset) OpenAttribute(name string) (*Attribute, error)

Opens an existing attribute. The returned attribute must be closed by the user when it is no longer needed.

func (*Dataset) Read

func (s *Dataset) Read(data interface{}) error

Read reads raw data from a dataset into a buffer.

func (*Dataset) ReadSubset

func (s *Dataset) ReadSubset(data interface{}, memspace, filespace *Dataspace) error

ReadSubset reads a subset of raw data from a dataset into a buffer.

func (*Dataset) Space

func (s *Dataset) Space() *Dataspace

Space returns an identifier for a copy of the dataspace for a dataset.

func (*Dataset) Write

func (s *Dataset) Write(data interface{}) error

Write writes raw data from a buffer to a dataset.

func (*Dataset) WriteSubset

func (s *Dataset) WriteSubset(data interface{}, memspace, filespace *Dataspace) error

WriteSubset writes a subset of raw data from a buffer to a dataset.

type Dataspace

type Dataspace struct {
	Identifier
}

func CreateDataspace

func CreateDataspace(class SpaceClass) (*Dataspace, error)

CreateDataspace creates a new dataspace of a specified type. The returned dataspace must be closed by the user when it is no longer needed.

func CreateSimpleDataspace

func CreateSimpleDataspace(dims, maxDims []uint) (*Dataspace, error)

CreateSimpleDataspace creates a new simple dataspace and opens it for access. The returned dataspace must be closed by the user when it is no longer needed.

func (*Dataspace) Close

func (s *Dataspace) Close() error

Close releases and terminates access to a dataspace.

func (*Dataspace) Copy

func (s *Dataspace) Copy() (*Dataspace, error)

Copy creates an exact copy of a dataspace. The returned dataspace must be closed by the user when it is no longer needed.

func (*Dataspace) IsSimple

func (s *Dataspace) IsSimple() bool

IsSimple returns whether a dataspace is a simple dataspace.

func (*Dataspace) SelectHyperslab

func (s *Dataspace) SelectHyperslab(offset, stride, count, block []uint) error

SelectHyperslab creates a subset of the data space.

func (*Dataspace) SetOffset

func (s *Dataspace) SetOffset(offset []uint) error

SetOffset sets the offset of a simple dataspace.

func (*Dataspace) SimpleExtentDims

func (s *Dataspace) SimpleExtentDims() (dims, maxdims []uint, err error)

SimpleExtentDims returns dataspace dimension size and maximum size.

func (*Dataspace) SimpleExtentNDims

func (s *Dataspace) SimpleExtentNDims() int

SimpleExtentNDims returns the dimensionality of a dataspace.

func (*Dataspace) SimpleExtentNPoints

func (s *Dataspace) SimpleExtentNPoints() int

SimpleExtentNPoints returns the number of elements in a dataspace.

func (*Dataspace) SimpleExtentType

func (s *Dataspace) SimpleExtentType() SpaceClass

SimpleExtentType returns the current class of a dataspace.

type Datatype

type Datatype struct {
	Identifier
	// contains filtered or unexported fields
}
var (
	T_C_S1       *Datatype = NewDatatype(C._H5T_C_S1())
	T_FORTRAN_S1 *Datatype = NewDatatype(C._H5T_FORTRAN_S1())

	T_STD_I8BE  *Datatype = NewDatatype(C._H5T_STD_I8BE())
	T_STD_I8LE  *Datatype = NewDatatype(C._H5T_STD_I8LE())
	T_STD_I16BE *Datatype = NewDatatype(C._H5T_STD_I16BE())
	T_STD_I16LE *Datatype = NewDatatype(C._H5T_STD_I16LE())
	T_STD_I32BE *Datatype = NewDatatype(C._H5T_STD_I32BE())
	T_STD_I32LE *Datatype = NewDatatype(C._H5T_STD_I32LE())
	T_STD_I64BE *Datatype = NewDatatype(C._H5T_STD_I64BE())
	T_STD_I64LE *Datatype = NewDatatype(C._H5T_STD_I64LE())
	T_STD_U8BE  *Datatype = NewDatatype(C._H5T_STD_U8BE())
	T_STD_U8LE  *Datatype = NewDatatype(C._H5T_STD_U8LE())
	T_STD_U16BE *Datatype = NewDatatype(C._H5T_STD_U16BE())
	T_STD_U16LE *Datatype = NewDatatype(C._H5T_STD_U16LE())
	T_STD_U32BE *Datatype = NewDatatype(C._H5T_STD_U32BE())
	T_STD_U32LE *Datatype = NewDatatype(C._H5T_STD_U32LE())
	T_STD_U64BE *Datatype = NewDatatype(C._H5T_STD_U64BE())
	T_STD_U64LE *Datatype = NewDatatype(C._H5T_STD_U64LE())
	T_STD_B8BE  *Datatype = NewDatatype(C._H5T_STD_B8BE())
	T_STD_B8LE  *Datatype = NewDatatype(C._H5T_STD_B8LE())

	T_STD_B16BE       *Datatype = NewDatatype(C._H5T_STD_B16BE())
	T_STD_B16LE       *Datatype = NewDatatype(C._H5T_STD_B16LE())
	T_STD_B32BE       *Datatype = NewDatatype(C._H5T_STD_B32BE())
	T_STD_B32LE       *Datatype = NewDatatype(C._H5T_STD_B32LE())
	T_STD_B64BE       *Datatype = NewDatatype(C._H5T_STD_B64BE())
	T_STD_B64LE       *Datatype = NewDatatype(C._H5T_STD_B64LE())
	T_STD_REF_OBJ     *Datatype = NewDatatype(C._H5T_STD_REF_OBJ())
	T_STD_REF_DSETREG *Datatype = NewDatatype(C._H5T_STD_REF_DSETREG())

	T_IEEE_F32BE *Datatype = NewDatatype(C._H5T_IEEE_F32BE())
	T_IEEE_F32LE *Datatype = NewDatatype(C._H5T_IEEE_F32LE())
	T_IEEE_F64BE *Datatype = NewDatatype(C._H5T_IEEE_F64BE())
	T_IEEE_F64LE *Datatype = NewDatatype(C._H5T_IEEE_F64LE())

	T_UNIX_D32BE *Datatype = NewDatatype(C._H5T_UNIX_D32BE())
	T_UNIX_D32LE *Datatype = NewDatatype(C._H5T_UNIX_D32LE())
	T_UNIX_D64BE *Datatype = NewDatatype(C._H5T_UNIX_D64BE())
	T_UNIX_D64LE *Datatype = NewDatatype(C._H5T_UNIX_D64LE())

	T_INTEL_I8  *Datatype = NewDatatype(C._H5T_INTEL_I8())
	T_INTEL_I16 *Datatype = NewDatatype(C._H5T_INTEL_I16())
	T_INTEL_I32 *Datatype = NewDatatype(C._H5T_INTEL_I32())
	T_INTEL_I64 *Datatype = NewDatatype(C._H5T_INTEL_I64())
	T_INTEL_U8  *Datatype = NewDatatype(C._H5T_INTEL_U8())
	T_INTEL_U16 *Datatype = NewDatatype(C._H5T_INTEL_U16())
	T_INTEL_U32 *Datatype = NewDatatype(C._H5T_INTEL_U32())
	T_INTEL_U64 *Datatype = NewDatatype(C._H5T_INTEL_U64())
	T_INTEL_B8  *Datatype = NewDatatype(C._H5T_INTEL_B8())
	T_INTEL_B16 *Datatype = NewDatatype(C._H5T_INTEL_B16())
	T_INTEL_B32 *Datatype = NewDatatype(C._H5T_INTEL_B32())
	T_INTEL_B64 *Datatype = NewDatatype(C._H5T_INTEL_B64())
	T_INTEL_F32 *Datatype = NewDatatype(C._H5T_INTEL_F32())
	T_INTEL_F64 *Datatype = NewDatatype(C._H5T_INTEL_F64())

	T_ALPHA_I8  *Datatype = NewDatatype(C._H5T_ALPHA_I8())
	T_ALPHA_I16 *Datatype = NewDatatype(C._H5T_ALPHA_I16())
	T_ALPHA_I32 *Datatype = NewDatatype(C._H5T_ALPHA_I32())
	T_ALPHA_I64 *Datatype = NewDatatype(C._H5T_ALPHA_I64())
	T_ALPHA_U8  *Datatype = NewDatatype(C._H5T_ALPHA_U8())
	T_ALPHA_U16 *Datatype = NewDatatype(C._H5T_ALPHA_U16())
	T_ALPHA_U32 *Datatype = NewDatatype(C._H5T_ALPHA_U32())
	T_ALPHA_U64 *Datatype = NewDatatype(C._H5T_ALPHA_U64())
	T_ALPHA_B8  *Datatype = NewDatatype(C._H5T_ALPHA_B8())
	T_ALPHA_B16 *Datatype = NewDatatype(C._H5T_ALPHA_B16())
	T_ALPHA_B32 *Datatype = NewDatatype(C._H5T_ALPHA_B32())
	T_ALPHA_B64 *Datatype = NewDatatype(C._H5T_ALPHA_B64())
	T_ALPHA_F32 *Datatype = NewDatatype(C._H5T_ALPHA_F32())
	T_ALPHA_F64 *Datatype = NewDatatype(C._H5T_ALPHA_F64())

	T_MIPS_I8  *Datatype = NewDatatype(C._H5T_MIPS_I8())
	T_MIPS_I16 *Datatype = NewDatatype(C._H5T_MIPS_I16())
	T_MIPS_I32 *Datatype = NewDatatype(C._H5T_MIPS_I32())
	T_MIPS_I64 *Datatype = NewDatatype(C._H5T_MIPS_I64())
	T_MIPS_U8  *Datatype = NewDatatype(C._H5T_MIPS_U8())
	T_MIPS_U16 *Datatype = NewDatatype(C._H5T_MIPS_U16())
	T_MIPS_U32 *Datatype = NewDatatype(C._H5T_MIPS_U32())
	T_MIPS_U64 *Datatype = NewDatatype(C._H5T_MIPS_U64())
	T_MIPS_B8  *Datatype = NewDatatype(C._H5T_MIPS_B8())
	T_MIPS_B16 *Datatype = NewDatatype(C._H5T_MIPS_B16())
	T_MIPS_B32 *Datatype = NewDatatype(C._H5T_MIPS_B32())
	T_MIPS_B64 *Datatype = NewDatatype(C._H5T_MIPS_B64())
	T_MIPS_F32 *Datatype = NewDatatype(C._H5T_MIPS_F32())
	T_MIPS_F64 *Datatype = NewDatatype(C._H5T_MIPS_F64())

	T_NATIVE_CHAR   *Datatype = NewDatatype(C._H5T_NATIVE_CHAR())
	T_NATIVE_INT    *Datatype = NewDatatype(C._H5T_NATIVE_INT())
	T_NATIVE_FLOAT  *Datatype = NewDatatype(C._H5T_NATIVE_FLOAT())
	T_NATIVE_SCHAR  *Datatype = NewDatatype(C._H5T_NATIVE_SCHAR())
	T_NATIVE_UCHAR  *Datatype = NewDatatype(C._H5T_NATIVE_UCHAR())
	T_NATIVE_SHORT  *Datatype = NewDatatype(C._H5T_NATIVE_SHORT())
	T_NATIVE_USHORT *Datatype = NewDatatype(C._H5T_NATIVE_USHORT())
	T_NATIVE_UINT   *Datatype = NewDatatype(C._H5T_NATIVE_UINT())
	T_NATIVE_LONG   *Datatype = NewDatatype(C._H5T_NATIVE_LONG())
	T_NATIVE_ULONG  *Datatype = NewDatatype(C._H5T_NATIVE_ULONG())
	T_NATIVE_LLONG  *Datatype = NewDatatype(C._H5T_NATIVE_LLONG())
	T_NATIVE_ULLONG *Datatype = NewDatatype(C._H5T_NATIVE_ULLONG())
	T_NATIVE_DOUBLE *Datatype = NewDatatype(C._H5T_NATIVE_DOUBLE())
	//#if H5_SIZEOF_LONG_DOUBLE !=0
	T_NATIVE_LDOUBLE *Datatype = NewDatatype(C._H5T_NATIVE_LDOUBLE())
	//#endif
	T_NATIVE_B8     *Datatype = NewDatatype(C._H5T_NATIVE_B8())
	T_NATIVE_B16    *Datatype = NewDatatype(C._H5T_NATIVE_B16())
	T_NATIVE_B32    *Datatype = NewDatatype(C._H5T_NATIVE_B32())
	T_NATIVE_B64    *Datatype = NewDatatype(C._H5T_NATIVE_B64())
	T_NATIVE_OPAQUE *Datatype = NewDatatype(C._H5T_NATIVE_OPAQUE())
	T_NATIVE_HSIZE  *Datatype = NewDatatype(C._H5T_NATIVE_HSIZE())
	T_NATIVE_HSSIZE *Datatype = NewDatatype(C._H5T_NATIVE_HSSIZE())
	T_NATIVE_HERR   *Datatype = NewDatatype(C._H5T_NATIVE_HERR())
	T_NATIVE_HBOOL  *Datatype = NewDatatype(C._H5T_NATIVE_HBOOL())

	T_NATIVE_INT8   *Datatype = NewDatatype(C._H5T_NATIVE_INT8())
	T_NATIVE_UINT8  *Datatype = NewDatatype(C._H5T_NATIVE_UINT8())
	T_NATIVE_INT16  *Datatype = NewDatatype(C._H5T_NATIVE_INT16())
	T_NATIVE_UINT16 *Datatype = NewDatatype(C._H5T_NATIVE_UINT16())
	T_NATIVE_INT32  *Datatype = NewDatatype(C._H5T_NATIVE_INT32())
	T_NATIVE_UINT32 *Datatype = NewDatatype(C._H5T_NATIVE_UINT32())
	T_NATIVE_INT64  *Datatype = NewDatatype(C._H5T_NATIVE_INT64())
	T_NATIVE_UINT64 *Datatype = NewDatatype(C._H5T_NATIVE_UINT64())

	T_GO_STRING *Datatype = makeGoStringDatatype()
)

list of predefined hdf5 data types

func CreateDatatype

func CreateDatatype(class TypeClass, size int) (*Datatype, error)

CreateDatatype creates a new datatype. The value of class must be T_COMPOUND, T_OPAQUE, T_ENUM or T_STRING, and size is the size of the new datatype in bytes. The returned datatype must be closed by the user when it is no longer needed.

func NewDataTypeFromType

func NewDataTypeFromType(t reflect.Type) (*Datatype, error)

NewDatatypeFromType creates a new Datatype from a reflect.Type. The returned datatype must be closed by the user when it is no longer needed.

func NewDatatype

func NewDatatype(id C.hid_t) *Datatype

NewDatatype creates a Datatype from an hdf5 id.

func NewDatatypeFromValue

func NewDatatypeFromValue(v interface{}) (*Datatype, error)

NewDatatypeFromValue creates a datatype from a value in an interface. The returned datatype must be closed by the user when it is no longer needed.

func OpenDatatype

func OpenDatatype(c CommonFG, name string, tapl_id int) (*Datatype, error)

OpenDatatype opens a named datatype. The returned datastype must be closed by the user when it is no longer needed.

func (*Datatype) Class

func (t *Datatype) Class() TypeClass

Class returns the TypeClass of the DataType

func (*Datatype) Close

func (t *Datatype) Close() error

Close releases a datatype.

func (*Datatype) Committed

func (t *Datatype) Committed() bool

Committed determines whether a datatype is a named type or a transient type.

func (*Datatype) Copy

func (t *Datatype) Copy() (*Datatype, error)

Copy copies an existing datatype.

func (*Datatype) Equal

func (t *Datatype) Equal(o *Datatype) bool

Equal determines whether two datatype identifiers refer to the same datatype.

func (*Datatype) GoType

func (t *Datatype) GoType() reflect.Type

GoType returns the reflect.Type associated with the Datatype's TypeClass

func (*Datatype) IsVariableStr added in v0.0.2

func (t *Datatype) IsVariableStr() bool

IsVariableStr determines whether the VarLenType is a string.

func (*Datatype) Lock

func (t *Datatype) Lock() error

Lock locks a datatype.

func (*Datatype) SetSize

func (t *Datatype) SetSize(sz int) error

SetSize sets the total size of a Datatype.

func (*Datatype) Size

func (t *Datatype) Size() uint

Size returns the size of the Datatype.

type File

type File struct {
	CommonFG
}

a HDF5 file

func CreateFile

func CreateFile(name string, flags int) (*File, error)

Creates an HDF5 file.

func OpenFile

func OpenFile(name string, flags int) (*File, error)

Open opens and returns an an existing HDF5 file. The returned file must be closed by the user when it is no longer needed.

func (*File) Close

func (f *File) Close() error

Close closes the file.

func (*File) CreateTable

func (f *File) CreateTable(name string, dtype *Datatype, chunkSize, compression int) (*Table, error)

Creates a packet table to store fixed-length packets. The returned table must be closed by the user when it is no longer needed.

func (*File) CreateTableFrom

func (f *File) CreateTableFrom(name string, dtype interface{}, chunkSize, compression int) (*Table, error)

Creates a packet table to store fixed-length packets. The returned table must be closed by the user when it is no longer needed.

func (*File) FileName

func (f *File) FileName() string

FIXME Retrieves name of file to which object belongs.

func (*File) Flush

func (f *File) Flush(scope Scope) error

Flushes all buffers associated with a file to disk.

func (*File) OpenTable

func (f *File) OpenTable(name string) (*Table, error)

Opens an existing packet table. The returned table must be closed by the user when it is no longer needed.

func (*File) ReOpen

func (f *File) ReOpen() (*File, error)

ReOpen returns a new identifier for a previously-opened HDF5 file. The returned file must be closed by the user when it is no longer needed.

type GType

type GType int

GType describes the type of an object inside a Group or File.

const (
	H5G_UNKNOWN GType = C.H5G_UNKNOWN // Unknown object type
	H5G_GROUP   GType = C.H5G_GROUP   // Object is a group
	H5G_DATASET GType = C.H5G_DATASET // Object is a dataset
	H5G_TYPE    GType = C.H5G_TYPE    // Object is a named data type
	H5G_LINK    GType = C.H5G_LINK    // Object is a symbolic link
	H5G_UDLINK  GType = C.H5G_UDLINK  // Object is a user-defined link
)

func (GType) String

func (typ GType) String() string

type Group

type Group struct {
	CommonFG
}

Group is an HDF5 container object. It can contain any Location.

func (*Group) Close

func (g *Group) Close() error

Close closes the Group.

func (*Group) CreateAttribute

func (g *Group) CreateAttribute(name string, dtype *Datatype, dspace *Dataspace) (*Attribute, error)

CreateAttribute creates a new attribute at this location. The returned attribute must be closed by the user when it is no longer needed.

func (*Group) CreateAttributeWith

func (g *Group) CreateAttributeWith(name string, dtype *Datatype, dspace *Dataspace, acpl *PropList) (*Attribute, error)

CreateAttributeWith creates a new attribute at this location with a user-defined PropList. The returned dataset must be closed by the user when it is no longer needed.

func (*Group) CreateTable

func (g *Group) CreateTable(name string, dtype *Datatype, chunkSize, compression int) (*Table, error)

CreateTable creates a packet table to store fixed-length packets. The returned table must be closed by the user when it is no longer needed.

func (*Group) CreateTableFrom

func (g *Group) CreateTableFrom(name string, dtype interface{}, chunkSize, compression int) (*Table, error)

CreateTableFrom creates a packet table to store fixed-length packets. The returned table must be closed by the user when it is no longer needed.

func (*Group) NumAttributes added in v0.0.3

func (g *Group) NumAttributes() (uint, error)

NumAttributes returns the number of attributes in the group

func (*Group) OpenAttribute

func (g *Group) OpenAttribute(name string) (*Attribute, error)

Opens an existing attribute. The returned attribute must be closed by the user when it is no longer needed.

func (*Group) OpenTable

func (g *Group) OpenTable(name string) (*Table, error)

OpenTable opens an existing packet table. The returned table must be closed by the user when it is no longer needed.

type IType

type IType C.H5I_type_t
const (
	FILE      IType = C.H5I_FILE
	GROUP     IType = C.H5I_GROUP
	DATATYPE  IType = C.H5I_DATATYPE
	DATASPACE IType = C.H5I_DATASPACE
	DATASET   IType = C.H5I_DATASET
	ATTRIBUTE IType = C.H5I_ATTR
	BAD_ID    IType = C.H5I_BADID
)

func (IType) String

func (typ IType) String() string

type Identifier

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

Identifier is a simple wrapper around a C hid_t. It has basic methods which apply to every type in the go-hdf5 API.

func (Identifier) File

func (i Identifier) File() *File

File returns the file associated with this Identifier.

func (Identifier) ID

func (i Identifier) ID() int64

ID returns the integer value of an identifier.

func (Identifier) Name

func (i Identifier) Name() string

Name returns the full name of the Identifier

func (Identifier) Type

func (i Identifier) Type() IType

Type returns the type of the identifier.

type Object

type Object interface {
	Name() string
	Id() int
	File() *File
}

Object represents an hdf5 object.

type OpaqueDatatype

type OpaqueDatatype struct {
	Datatype
}

func (*OpaqueDatatype) SetTag

func (t *OpaqueDatatype) SetTag(tag string) error

SetTag tags an opaque datatype.

func (*OpaqueDatatype) Tag

func (t *OpaqueDatatype) Tag() string

Tag returns the tag associated with an opaque datatype.

type PropList

type PropList struct {
	Identifier
}

func NewPropList

func NewPropList(cls_id PropType) (*PropList, error)

NewPropList creates a new PropList as an instance of a property list class. The returned proplist must be closed by the user when it is no longer needed.

func (*PropList) Close

func (p *PropList) Close() error

Close terminates access to a PropList.

func (*PropList) Copy

func (p *PropList) Copy() (*PropList, error)

Copy copies an existing PropList to create a new PropList.

func (*PropList) GetChunk

func (p *PropList) GetChunk(ndims int) (dims []uint, err error)

GetChunk retrieves the size of chunks for the raw data of a chunked layout dataset. https://support.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-GetChunk

func (*PropList) GetChunkCache

func (p *PropList) GetChunkCache() (nslots, nbytes int, w0 float64, err error)

GetChunkCache retrieves the number of chunk slots in the raw data chunk cache hash table. https://support.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-GetChunkCache

func (*PropList) SetChunk

func (p *PropList) SetChunk(dims []uint) error

SetChunk sets the size of the chunks used to store a chunked layout dataset. https://support.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetChunk

func (*PropList) SetChunkCache

func (p *PropList) SetChunkCache(nslots, nbytes int, w0 float64) error

SetChunkCache sets the raw data chunk cache parameters. To reset them as default, use `D_CHUNK_CACHE_NSLOTS_DEFAULT`, `D_CHUNK_CACHE_NBYTES_DEFAULT` and `D_CHUNK_CACHE_W0_DEFAULT`. https://support.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetChunkCache

func (*PropList) SetDeflate

func (p *PropList) SetDeflate(level int) error

SetDeflate sets deflate (GNU gzip) compression method and compression level. If level is set as DefaultCompression, 6 will be used. https://support.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetDeflate

type PropType

type PropType C.hid_t

type Scope

type Scope C.H5F_scope_t

The difference between a single file and a set of mounted files.

const (
	F_SCOPE_LOCAL  Scope = 0 // specified file handle only.
	F_SCOPE_GLOBAL Scope = 1 // entire virtual file.
)

type SpaceClass

type SpaceClass C.H5S_class_t
const (
	S_NO_CLASS SpaceClass = -1 // error
	S_SCALAR   SpaceClass = 0  // scalar variable
	S_SIMPLE   SpaceClass = 1  // simple data space
	S_NULL     SpaceClass = 2  // null data space
)

type Table

type Table struct {
	Identifier
}

Table is an hdf5 packet-table.

func (*Table) Append

func (t *Table) Append(args ...interface{}) error

Append appends packets to the end of a packet table.

Struct values must only have exported fields, otherwise Append will panic.

func (*Table) Close

func (t *Table) Close() error

Close closes an open packet table.

func (*Table) CreateIndex

func (t *Table) CreateIndex() error

CreateIndex resets a packet table's index to the first packet.

func (*Table) IsValid

func (t *Table) IsValid() bool

IsValid returns whether or not an indentifier points to a packet table.

func (*Table) Next

func (t *Table) Next(data interface{}) error

Next reads packets from a packet table starting at the current index into the value pointed at by data. i.e. data is a pointer to an array or a slice.

func (*Table) NumPackets

func (t *Table) NumPackets() (int, error)

NumPackets returns the number of packets in a packet table.

func (*Table) ReadPackets

func (t *Table) ReadPackets(start, nrecords int, data interface{}) error

ReadPackets reads a number of packets from a packet table.

func (*Table) SetIndex

func (t *Table) SetIndex(index int) error

SetIndex sets a packet table's index.

func (*Table) Type

func (t *Table) Type() (*Datatype, error)

Type returns an identifier for a copy of the datatype for a dataset. The returned datatype must be closed by the user when it is no longer needed.

type TypeClass

type TypeClass C.H5T_class_t
const (
	T_NO_CLASS  TypeClass = -1 // Error
	T_INTEGER   TypeClass = 0  // integer types
	T_FLOAT     TypeClass = 1  // floating-point types
	T_TIME      TypeClass = 2  // date and time types
	T_STRING    TypeClass = 3  // character string types
	T_BITFIELD  TypeClass = 4  // bit field types
	T_OPAQUE    TypeClass = 5  // opaque types
	T_COMPOUND  TypeClass = 6  // compound types
	T_REFERENCE TypeClass = 7  // reference types
	T_ENUM      TypeClass = 8  // enumeration types
	T_VLEN      TypeClass = 9  // variable-length types
	T_ARRAY     TypeClass = 10 // array types
	T_NCLASSES  TypeClass = 11 // nbr of classes -- MUST BE LAST
)

type VarLenType

type VarLenType struct {
	Datatype
}

func NewVarLenType

func NewVarLenType(base_type *Datatype) (*VarLenType, error)

NewVarLenType creates a new VarLenType. the base_type specifies the element type of the VarLenType. The returned variable length type must be closed by the user when it is no longer needed.

type Version

type Version struct {
	Major   uint
	Minor   uint
	Release uint
}

Version represents the currently used hdf5 library version

func LibVersion

func LibVersion() (Version, error)

LibVersion returns version information for the HDF5 library.

func (Version) String

func (v Version) String() string

Directories

Path Synopsis
cmd
Package cmem provides helper functionality for accessing memory in a C compatible fashion.
Package cmem provides helper functionality for accessing memory in a C compatible fashion.

Jump to

Keyboard shortcuts

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