Skip to content

scigolib/hdf5

Repository files navigation

HDF5 Go Library

Pure Go implementation of the HDF5 file format - No CGo required

Go Version License Status Progress

A modern, pure Go library for reading HDF5 files without CGo dependencies. ~98% production-ready for common scientific datasets!


✨ Features

  • Pure Go - No CGo, no C dependencies, cross-platform
  • Modern Design - Built with Go 1.25+ best practices
  • HDF5 Compatibility - Supports superblock versions 0, 2, 3
  • Full Dataset Reading - Compact, contiguous, chunked layouts with GZIP
  • Rich Datatypes - Integers, floats, strings (fixed/variable), compounds
  • Memory Efficient - Buffer pooling and smart memory management
  • Production Ready - ~98% complete for common scientific HDF5 files
  • 📖 Read-Only - Write support planned for future versions

🚀 Quick Start

Installation

go get github.com/scigolib/hdf5

Basic Usage

package main

import (
    "fmt"
    "log"
    "github.com/scigolib/hdf5"
)

func main() {
    // Open HDF5 file
    file, err := hdf5.Open("data.h5")
    if err != nil {
        log.Fatal(err)
    }
    defer file.Close()

    // Walk through file structure
    file.Walk(func(path string, obj hdf5.Object) {
        switch v := obj.(type) {
        case *hdf5.Group:
            fmt.Printf("📁 %s (%d children)\n", path, len(v.Children()))
        case *hdf5.Dataset:
            fmt.Printf("📊 %s\n", path)
        }
    })
}

Output:

📁 / (2 children)
📊 /temperature
📁 /experiments/ (3 children)

More examples →


📚 Documentation


🎯 Current Status

Production Readiness: ~98% for reading common HDF5 scientific datasets! 🎉

✅ Fully Implemented

  • File Structure:

    • Superblock parsing (v0, v2, v3)
    • Object headers (v2 with continuations)
    • Groups (traditional symbol tables + modern object headers)
    • B-trees (leaf + non-leaf nodes for large files)
    • Local heaps (string storage)
    • Global Heap (variable-length data)
  • Dataset Reading:

    • Compact layout
    • Contiguous layout
    • Chunked layout with B-tree indexing
    • GZIP/Deflate compression
  • Datatypes:

    • Fixed-point (int32, int64)
    • Floating-point (float32, float64)
    • Fixed-length strings (null/space/null-padded)
    • Variable-length strings (via Global Heap)
    • Compound types (struct-like with nested members)
  • Navigation: Full file tree traversal via Walk()

❌ Not Implemented

  • Object header v1 (legacy format)
  • Fractal heap (modern attribute storage)
  • Full attribute reading
  • Other compression (SZIP, LZF, BZIP2)
  • Advanced datatypes (arrays, enums, references, opaque, time)
  • Virtual datasets / external files
  • Write support (read-only by design)

🔧 Development

Requirements

  • Go 1.25 or later
  • No external dependencies for the library
  • Testing requires: Python 3 with h5py (for generating test files)

Building

# Clone repository
git clone https://github.com/scigolib/hdf5.git
cd hdf5

# Run tests
go test ./...

# Build examples
go build ./examples/...

# Build tools
go build ./cmd/...

Testing

# Run all tests
go test ./...

# Run with race detector
go test -race ./...

# Run with coverage
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out

🤝 Contributing

Contributions are welcome! This is an early-stage project and we'd love your help.

Before contributing:

  1. Read CONTRIBUTING.md - Git workflow and development guidelines
  2. Check open issues
  3. Review the Architecture Overview

Ways to contribute:

  • 🐛 Report bugs
  • 💡 Suggest features
  • 📝 Improve documentation
  • 🔧 Submit pull requests
  • ⭐ Star the project

🗺️ Comparison with Other Libraries

Feature This Library gonum/hdf5 go-hdf5/hdf5
Pure Go ✅ Yes ❌ CGo wrapper ✅ Yes
Reading ✅ Partial ✅ Full ❌ Limited
Writing 📋 Planned ✅ Full ❌ No
HDF5 1.8+ ✅ Yes ⚠️ Limited ❌ No
Maintained ✅ Active ⚠️ Slow ❌ Inactive
Thread-safe 📋 Planned ⚠️ Conditional ❌ No

📖 HDF5 Resources


📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


🙏 Acknowledgments

  • The HDF Group for the HDF5 format specification
  • gonum/hdf5 for inspiration
  • All contributors to this project

Special Thanks

Professor Ancha Baranova - This project would not have been possible without her invaluable help and support. Her assistance was crucial in bringing this library to life.


📞 Support


Status: Beta - ~98% production-ready for reading Version: 0.9.0-beta (near 1.0 release!) Last Updated: 2025-10-17


Built with ❤️ by the HDF5 Go community

Packages

No packages published

Contributors 2

  •  
  •