hdf5

package module
v0.0.0-...-1e70d79 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2017 License: MIT Imports: 4 Imported by: 1

README

HDF5 Build Status

The package provides a reader and writer of HDF5 files.

Documentation

Installation

Fetch the package:

go get -d github.com/ready-steady/hdf5

Go to the directory of the package:

cd $GOPATH/src/github.com/ready-steady/hdf5

Install the package:

make install

Usage

package main

import (
	"fmt"

	"github.com/ready-steady/hdf5"
)

func main() {
	put("data.h5")
	get("data.h5")
}

func put(path string) {
	file, _ := hdf5.Create(path)
	defer file.Close()

	A := 42
	file.Put("A", A)

	B := []float64{1, 2, 3}
	file.Put("B", B)

	C := struct {
		D int
		E []float64
	}{
		D: 42,
		E: []float64{1, 2, 3},
	}
	file.Put("C", C)
}

func get(path string) {
	file, _ := hdf5.Open(path)
	defer file.Close()

	A := 0
	file.Get("A", &A)
	fmt.Println(A)

	B := []float64{}
	file.Get("B", &B)
	fmt.Println(B)

	C := struct {
		D int
		E []float64
	}{}
	file.Get("C", &C)
	fmt.Println(C)
}

Contribution

  1. Fork the project.
  2. Implement your idea.
  3. Open a pull request.

Documentation

Overview

Package hdf5 provides a reader and writer of HDF5 files.

https://en.wikipedia.org/wiki/Hierarchical_Data_Format

Index

Examples

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

Example
put := func(path string) {
	file, _ := Create(path)
	defer file.Close()

	A := 42
	file.Put("A", A)

	B := []float64{1, 2, 3}
	file.Put("B", B)

	C := struct {
		D int
		E []float64
	}{
		D: 42,
		E: []float64{1, 2, 3},
	}
	file.Put("C", C)
}

get := func(path string) {
	file, _ := Open(path)
	defer file.Close()

	A := 0
	file.Get("A", &A)
	fmt.Println(A)

	B := []float64{}
	file.Get("B", &B)
	fmt.Println(B)

	C := struct {
		D int
		E []float64
	}{}
	file.Get("C", &C)
	fmt.Println(C)
}

path := fixture.MakeFile()
defer os.Remove(path)

put(path)
get(path)
Output:

42
[1 2 3]
{42 [1 2 3]}

func Create

func Create(path string) (*File, error)

Create creates a new file.

func Open

func Open(path string) (*File, error)

Open opens an existing file.

func (*File) Close

func (f *File) Close() error

Close closes the file.

func (*File) Get

func (f *File) Get(name string, something interface{}) error

Get reads data from the file.

func (*File) Put

func (f *File) Put(name string, something interface{}, dimensions ...uint) error

Put writes data into the file.

Jump to

Keyboard shortcuts

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