hdf5

package
v0.0.0-...-378c06b Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package hdf5 implements HDF5 for NetCDF

The specification for HDF5 is not comprehensive and leaves out many details. A lot of this code was determined from reverse-engineering various HDF5 data files. It's quite hacky for that reason. It will get cleaned up in the future.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBadMagic is returned when the file is not an HDF5 file
	ErrBadMagic = errors.New("bad magic number")

	// ErrUnsupportedFilter is returned when an unrecognized filter is encountered
	ErrUnsupportedFilter = errors.New("unsupported filter found")

	// ErrUnsupportedCompression is returned for unsupported copmression schemes
	ErrUnknownCompression = errors.New("unknown compression")

	// ErrInternal is an internal error not otherwise specified here
	ErrInternal = errors.New("internal error")

	// ErrNotFound is returned for items requested that don't exist
	ErrNotFound = errors.New("not found")

	// ErrFletcherChecksum is returned for corrupted data failing the checksum
	ErrFletcherChecksum = errors.New("fletcher checksum failure")

	// ErrVersion is returned when the particular HDF5 version is not supported
	ErrVersion = errors.New("hdf5 version not supported")

	// ErrLinkType is returned for an unrecognized or unsupported link type
	ErrLinkType = errors.New("link type not supported")

	// ErrVirtualStorage is returned when the unsupported virtual storage feature is encountered
	ErrVirtualStorage = errors.New("virtual storage not supported")

	// ErrTruncated is returned when the file has fewer bytes than the superblock says
	ErrTruncated = errors.New("file is too small, may be truncated")

	// ErrOffsetSize is returned when offsets other than 64-bit are indicated.
	// Only 64-bit is supported in this implementation.
	ErrOffsetSize = errors.New("only 64-bit offsets are supported")

	// ErrDimensionality is returned when invalid dimensions are specified
	ErrDimensionality = errors.New("invalid dimensionality")

	// ErrDataspaceVersion is returned for unsupported dataspace versions
	ErrDataspaceVersion = errors.New("dataspace version not supported")

	// ErrCorrupted is returned when file inconsistencies are found
	ErrCorrupted = errors.New("corrupted file")

	// ErrLayout is returned for unsupported data layouts
	ErrLayout = errors.New("data layout version not supported")

	// ErrSuperblock is returned for unsupported superblock versions
	ErrSuperblock = errors.New("superblock extension not supported")

	// ErrBitfield is returned when bitfields are encountered.
	// Bitfields are valid HDF5, but not valid NetCDF4.
	ErrBitfield = errors.New("bitfields not supported")

	// ErrExternal is returned when requests for external files are encountered, which is
	// not supported.
	ErrExternal = errors.New("external data files not supported")

	// ErrFloatingPoint is returned when non-standard floating point is encountered
	ErrFloatingPoint = errors.New("non-standard floating point not handled")

	// ErrFloatingPointis returned when non-standard integers are encountered
	ErrFixedPoint = errors.New("non-standard fixed-point not handled")

	// ErrReference is returned when references are encountered.
	// References are valid HDF, but not valid NetCDF4.
	ErrReference = errors.New("unsupported reference type")

	// ErrNonExportedField is returned when a value cannot be assigned to user-supplied
	// struct because it has non-exported fields.
	ErrNonExportedField = errors.New("can't assign to non-exported field")

	// ErrUnsupportedDataTypeVersion is returned when a unsupported datatype version
	// is encountered. Only versions 1-3 are supported.
	ErrUnsupportedDataTypeVersion = errors.New("unsupported data type version")

	// ErrUnsupportedReferenceVersion is returned a reference version other than 1
	// is encountered.
	ErrUnsupportedReferenceVersion = errors.New("unsupported reference version")
)

Functions

func New

func New(file api.ReadSeekerCloser) (nc api.Group, err error)

New is the implementation of the API netcdf.New. Using netcdf.New is preferred over using this directly.

func Open

func Open(fname string) (nc api.Group, err error)

Open is the implementation of the API netcdf.Open. Using netcdf.Open is preferred over using this directly.

func SetLogLevel

func SetLogLevel(level int) int

SetLogLevel sets the logging level to the given level, and returns the old level. This is for internal debugging use. The log messages are not expected to make much sense to anyone but the developers. The lowest level is 0 (no error logs at all) and the highest level is 3 (errors, warnings and debug messages).

Types

type HDF5

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

HDF5 implements api.Group for HDF5

func (*HDF5) Attributes

func (h5 *HDF5) Attributes() api.AttributeMap

Attributes returns the global attributes for this group.

func (*HDF5) Close

func (h5 *HDF5) Close()

Close closes this group and closes any underlying files if they are no longer being used by any other groups.

func (*HDF5) GetDimension

func (h5 *HDF5) GetDimension(name string) (uint64, bool)

GetDimension returns the size of the given dimension and sets the bool to true if found.

func (*HDF5) GetGoType

func (h5 *HDF5) GetGoType(typeName string) (string, bool)

GetGoType gets the Go description of the type and sets the bool to true if found.

func (*HDF5) GetGroup

func (h5 *HDF5) GetGroup(group string) (g api.Group, err error)

GetGroup gets the given group or returns an error if not found. The group can start with "/" for absolute names, or relative.

func (*HDF5) GetType

func (h5 *HDF5) GetType(typeName string) (string, bool)

GetType gets the CDL description of the type and sets the bool to true if found.

func (*HDF5) GetVarGetter

func (h5 *HDF5) GetVarGetter(varName string) (slicer api.VarGetter, err error)

GetVarGetter is an function that returns an interface that allows you to get smaller slices of a variable, in case the variable is very large and you want to reduce memory usage.

func (*HDF5) GetVariable

func (h5 *HDF5) GetVariable(varName string) (av *api.Variable, err error)

GetVariable returns the named variable or sets the error if not found.

func (*HDF5) ListDimensions

func (h5 *HDF5) ListDimensions() []string

ListDimensions lists the names of the dimensions in this group.

func (*HDF5) ListSubgroups

func (h5 *HDF5) ListSubgroups() []string

ListSubgroups returns the names of the subgroups of this group.

func (*HDF5) ListTypes

func (h5 *HDF5) ListTypes() []string

ListTypes returns the user-defined type names.

func (*HDF5) ListVariables

func (h5 *HDF5) ListVariables() []string

ListVariables lists the variables in this group.

Jump to

Keyboard shortcuts

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