hdf5
is a pure Go implementation of the HDF5 file format.
hdf5
is released under the BSD-3
license.
Documentation for hdf5
is served by GoDoc.
Pure Go implementation of the HDF5 file format
License: BSD 3-Clause "New" or "Revised" License
Running what I believe is the test code:
import (
"fmt"
"gonum.org/v1/hdf5"
)
const (
fname string = "SDScompound.h5"
dsname string = "ArrayOfStructures"
mbr1 string = "A_name"
mbr2 string = "B_name"
mbr3 string = "C_name"
length uint = 10
rank int = 1
)
type s1Type struct {
a int
b float32
c float64
d [3]int
e string
}
type s2Type struct {
c float64
a int
}
func main() {
// initialize data
// s1 := make([]s1_t, LENGTH)
// for i:=0; i<LENGTH; i++ {
// s1[i] = s1_t{a:i, b:float32(i*i), c:1./(float64(i)+1)}
// }
// fmt.Printf(":: data: %v\n", s1)
s1 := [length]s1Type{}
for i := 0; i < int(length); i++ {
s1[i] = s1Type{
a: i,
b: float32(i * i),
c: 1. / (float64(i) + 1),
d: [...]int{i, i * 2, i * 3},
e: fmt.Sprintf("--%d--", i),
}
//s1[i].d = []float64{float64(i), float64(2*i), 3.*i}}
}
fmt.Printf(":: data: %v\n", s1)
// create data space
dims := []uint{length}
space, err := hdf5.CreateSimpleDataspace(dims, nil)
if err != nil {
panic(err)
}
// create the file
f, err := hdf5.CreateFile(fname, hdf5.F_ACC_TRUNC)
if err != nil {
panic(err)
}
defer f.Close()
// create the memory data type
dtype, err := hdf5.NewDatatypeFromValue(s1[0])
if err != nil {
panic("could not create a dtype")
}
// create the dataset
dset, err := f.CreateDataset(dsname, dtype, space)
if err != nil {
panic(err)
}
// write data to the dataset
fmt.Printf(":: dset.Write...\n")
err = dset.Write(&s1)
if err != nil {
panic(err)
}
fmt.Printf(":: dset.Write... [ok]\n")
// release resources
dset.Close()
f.Close()
// open the file and the dataset
f, err = hdf5.OpenFile(fname, hdf5.F_ACC_RDONLY)
if err != nil {
panic(err)
}
dset, err = f.OpenDataset(dsname)
if err != nil {
panic(err)
}
// read it back into a new slice
s2 := make([]s1Type, length)
err = dset.Read(&s2)
if err != nil {
panic(err)
}
// display the fields
fmt.Printf(":: data: %v\n", s2)
// release resources
dset.Close()
f.Close()
}
I experience this crash:
% go run test.go
:: data: [{0 0 1 [0 0 0] --0--} {1 1 0.5 [1 2 3] --1--} {2 4 0.3333333333333333 [2 4 6] --2--} {3 9 0.25 [3 6 9] --3--} {4 16 0.2 [4 8 12] --4--} {5 25 0.16666666666666666 [5 10 15] --5--} {6 36 0.14285714285714285 [6 12 18] --6--} {7 49 0.125 [7 14 21] --7--} {8 64 0.1111111111111111 [8 16 24] --8--} {9 81 0.1 [9 18 27] --9--}]
:: dset.Write...
panic: runtime error: cgo argument has Go pointer to Go pointer
goroutine 1 [running]:
gonum.org/v1/hdf5.(*Dataset).WriteSubset.func1(0x500000000000000, 0x300000000000143, 0x0, 0x0, 0x0, 0xc000090000, 0x11)
/Users/nick/atsu/atsui/src/gonum.org/v1/hdf5/h5d_dataset.go:147 +0x4c
gonum.org/v1/hdf5.(*Dataset).WriteSubset(0xc0000101f0, 0x40b02a0, 0xc000090000, 0x0, 0x0, 0x0, 0x0)
/Users/nick/atsu/atsui/src/gonum.org/v1/hdf5/h5d_dataset.go:147 +0x1b2
gonum.org/v1/hdf5.(*Dataset).Write(0xc0000101f0, 0x40b02a0, 0xc000090000, 0x0, 0x0)
/Users/nick/atsu/atsui/src/gonum.org/v1/hdf5/h5d_dataset.go:154 +0x47
main.main()
/Users/nick/.tmp/hdf/test.go:81 +0x481
exit status 2
% go version
go version go1.11.1 darwin/amd64
Hi @sbinet
Is this repo still active (planned to continue development) or is the https://github.com/gonum/hdf5 the recommended way?
best regards
disk format level 0 (specs: file metadata)
disk format level 1 (specs: file infrastructure)
disk format level 2 (specs: data objects)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.