h5

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: BSD-3-Clause Imports: 10 Imported by: 0

README

Gosl. io/h5. HDF5 wrapper

go.dev reference

More information is available in the documentation of this package.

This subpackage helps with reading and writing HDF5 files. HDF5 is a data model, library, and file format for storing and managing data. See more about HDF5 here.

Requirements

Requires: libhdf5-dev

TODO

  1. Remove dependency to io, since h5 should be inside io

Documentation

Overview

Package h5 wraps the HDF5 library. HDF5 is a data model, library, and file format for storing and managing data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

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

File represents a HDF5 file

func Create

func Create(dirOut, fnameKey string, useGob bool) (o *File)

Create creates a new file, deleting existent one

Input:
  dirOut   -- directory name that will be created if non-existent
              Note: dirOut may contain environment variables
  fnameKey -- filename key; e.g. without extension
  useGob   -- use Go's own format gob instead of HDF5

Output:
  returns a new File object where the filename will be:
    fnameKey + .h5   if useGob == false, or
    fnameKey + .gob  if useGob == true

func Open

func Open(dirIn, fnameKey string, useGob bool) (o *File)

Open opens an existent file for read only

Input:
  dirIn    -- directory name where the file is located
              Note: dirIn may contain environment variables
  fnameKey -- filename key; e.g. without extension
  useGob   -- use Go's own format gob instead of HDF5

Output:
  returns a new File object where the filename will be:
    fnameKey + .h5   if useGob == false, or
    fnameKey + .gob  if useGob == true

func (*File) AppendToArray

func (o *File) AppendToArray(path string, v []float64)

AppendToArray appends values to a variable array

func (*File) Close

func (o *File) Close()

Close closes file

func (File) Filename

func (o File) Filename() string

Filename returns the filename; i.e. fileNameKey + extension

func (File) Filepath

func (o File) Filepath() string

Filepath returns the full filepath, including directory name

func (*File) GetArray

func (o *File) GetArray(path string) (v []float64)

GetArray gets an array from file. Memory will be allocated

func (*File) GetDeep2

func (o *File) GetDeep2(path string) (a [][]float64)

GetDeep2 gets a Deep2 slice (that was serialized). Memory will be allocated

func (*File) GetDeep2raw

func (o *File) GetDeep2raw(path string) (m, n int, a []float64)

GetDeep2raw returns the serialized data corresponding to a Deep2 slice

func (*File) GetDeep3

func (o *File) GetDeep3(path string) (a [][][]float64)

GetDeep3 gets a deep slice with 3 levels from file. Memory will be allocated

func (*File) GetFloat64

func (o *File) GetFloat64(path string) float64

GetFloat64 gets one float64 from file

Note: this is a convenience function wrapping GetArray

func (*File) GetInt

func (o *File) GetInt(path string) int

GetInt gets one integer from file

Note: this is a convenience function wrapping GetInts

func (*File) GetIntAttribute

func (o *File) GetIntAttribute(path, key string) (val int)

GetIntAttribute gets int attribute

func (*File) GetInts

func (o *File) GetInts(path string) (v []int)

GetInts gets a slice of ints from file. Memory will be allocated

func (*File) GetIntsAttribute

func (o *File) GetIntsAttribute(path, key string) (vals []int)

GetIntsAttribute gets slice-of-ints attribute

func (*File) GetStringAttribute

func (o *File) GetStringAttribute(path, key string) (val string)

GetStringAttribute gets string attribute

func (*File) PutArray

func (o *File) PutArray(path string, v []float64)

PutArray puts an array with name described in path into HDF5 file

Input:
  path -- HDF5 path such as "/myvec" or "/group/myvec"
  v    -- slice of float64

func (*File) PutDeep2

func (o *File) PutDeep2(path string, a [][]float64)

PutDeep2 puts a Deep2 slice into file

Input:
  path -- HDF5 path such as "/myvec" or "/group/myvec"
  a    -- slice of slices of float64
Note: Slice will be serialized

func (*File) PutDeep3

func (o *File) PutDeep3(path string, a [][][]float64)

PutDeep3 puts a deep slice with 3 levels and name described in path into HDF5 file

Input:
  path -- HDF5 path such as "/myvec" or "/group/myvec"
  a    -- slice of slices of slices of float64
Note: Slice will be serialized

func (*File) PutFloat64

func (o *File) PutFloat64(path string, val float64)

PutFloat64 puts one float64 into file

Input:
  path -- HDF5 path such as "/myvec" or "/group/myvec"
  val  -- value
Note: this is a convenience function wrapping PutArray

func (*File) PutInt

func (o *File) PutInt(path string, val int)

PutInt puts one integer into file

Input:
  path -- HDF5 path such as "/myvec" or "/group/myvec"
  val  -- value
Note: this is a convenience function wrapping PutInts

func (*File) PutInts

func (o *File) PutInts(path string, v []int)

PutInts puts a slice of integers into file

Input:
  path -- HDF5 path such as "/myvec" or "/group/myvec"
  v    -- slice of integers

func (*File) PutVarArray

func (o *File) PutVarArray(path string, v []float64)

PutVarArray puts a variable array with name described in path into HDF5 file

Input:
  path -- HDF5 path such as "/myvec" or "/group/myvec"
  v    -- slice of float64

func (*File) ReadArray

func (o *File) ReadArray(v []float64, path string) (dims []int)

ReadArray reads an array from file into existent pre-allocated memory

Input:
  path -- HDF5 path such as "/myvec" or "/group/myvec"
Output:
  array -- values in pre-allocated array => must know dimension
  dims  -- dimensions (for confirmation)

func (*File) SetIntAttribute

func (o *File) SetIntAttribute(path, key string, val int)

SetIntAttribute sets int attibute

func (*File) SetIntsAttribute

func (o *File) SetIntsAttribute(path, key string, vals []int)

SetIntsAttribute sets slice-of-ints attibute

func (*File) SetStringAttribute

func (o *File) SetStringAttribute(path, key, val string)

SetStringAttribute sets a string attibute

Jump to

Keyboard shortcuts

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