Code Monkey home page Code Monkey logo

hdf5.jl's Introduction

HDF5.jl

HDF5 interface for the Julia language

Stable Build Status Coverage

HDF5 is a file format and library for storing and accessing data, commonly used for scientific data. HDF5 files can be created and read by numerous programming languages. This package provides an interface to the HDF5 library for the Julia language.

Changelog

Please see HISTORY.md. Most changes have deprecation warnings and thus may not be listed in the changelog.

Installation

julia>]
pkg> add HDF5

For custom build instructions please refer to the documentation.

Quickstart

using HDF5

To read and write a variable to a file, one approach is to use the filename:

A = collect(reshape(1:120, 15, 8))
h5write("/tmp/test2.h5", "mygroup2/A", A)
data = h5read("/tmp/test2.h5", "mygroup2/A", (2:3:15, 3:5))

where the last line reads back just A[2:3:15, 3:5] from the dataset.

More fine-grained control can be obtained using functional syntax:

h5open("mydata.h5", "w") do file
    write(file, "A", A)  # alternatively, say "@write file A"
end

c = h5open("mydata.h5", "r") do file
    read(file, "A")
end

This allows you to add variables as they are generated to an open HDF5 file. You don't have to use the do syntax (file = h5open("mydata.h5", "w") works just fine), but an advantage is that it will automatically close the file (close(file)) for you, even in cases of error.

Julia's high-level wrapper, providing a dictionary-like interface, may also be of interest:

using HDF5

h5open("test.h5", "w") do file
    g = create_group(file, "mygroup") # create a group
    g["dset1"] = 3.2                  # create a scalar dataset inside the group
    attributes(g)["Description"] = "This group contains only a single dataset" # an attribute
end

Convenience functions for attributes attached to datasets are also provided:

A = Vector{Int}(1:10)
h5write("bar.h5", "foo", A)
h5writeattr("bar.h5", "foo", Dict("c"=>"value for metadata parameter c","d"=>"metadata d"))
h5readattr("bar.h5", "foo")

hdf5.jl's People

Contributors

abhijithch avatar adambrewster avatar ararslan avatar bicycle1885 avatar bjarthur avatar blakejohnson avatar carlobaldassi avatar cdsousa avatar eschnett avatar ggggggggg avatar github-actions[bot] avatar iamed2 avatar jeffbezanson avatar jipolanco avatar jmert avatar jtravs avatar keno avatar kleinhenz avatar mbauman avatar musm avatar nicoleepp avatar petercolberg avatar rened avatar simonster avatar staticfloat avatar stevengj avatar timholy avatar tkelman avatar tknopp avatar yuyichao avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.