-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve quality of examples, add one
- Loading branch information
Showing
4 changed files
with
56 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
|
||
dofile('LuaHDF5.lua') | ||
dofile('run.lua') | ||
|
||
|
||
|
||
dofile('array.lua') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
-------------------------------------------------------------------------------- | ||
-- Demonstrate the simplest use of the high-level HDF5 Lua bindings. Create an | ||
-- HDF5 file with the following layout: | ||
-- | ||
-- outfile.h5/ | ||
-- | ||
-- the_dataset (double array [16,32,64]) | ||
-- | ||
-- the_group/ | ||
-- | ||
-- the_message (string: "here is the message") | ||
-- | ||
-------------------------------------------------------------------------------- | ||
|
||
local hdf5 = require 'LuaHDF5' | ||
local buffer = require 'buffer' | ||
local array = require 'array' | ||
|
||
local the_array = array.array({16,32,64}, 'double') | ||
local the_h5file = hdf5.File("outfile.h5", "w") | ||
local the_group = the_h5file:require_group("the_group") | ||
the_group["the_message"] = "here is the message" | ||
the_h5file["the_dataset"] = the_array | ||
the_h5file:close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,31 @@ | ||
|
||
-------------------------------------------------------------------------------- | ||
-- Prints all the data sets and groups at the top level of a file | ||
-------------------------------------------------------------------------------- | ||
|
||
local hdf5 = require 'LuaHDF5' | ||
|
||
local function iterate_group(grp, indent) | ||
local indent = indent or '' | ||
for k,v in pairs(grp) do | ||
if v:class() == 'data set' then | ||
if v:get_type():type_class() == 'string' then | ||
print(indent..'Dataset: '..indent..k, v) | ||
elseif v:get_type():type_class() == 'float' then | ||
print(indent..'Dataset: '..indent..k, v) | ||
end | ||
elseif v:class() == 'group' then | ||
print(indent..'Group: '..v:name()) | ||
iterate_group(v, indent..'\t') | ||
end | ||
end | ||
end | ||
|
||
local fname = arg[2] | ||
local h5f = hdf5.File(fname, 'r') | ||
|
||
for k,v in pairs(h5f) do | ||
print(k, v:value()) | ||
if not arg[2] then | ||
print("usage: h5ls.lua infile.h5") | ||
else | ||
iterate_group(h5f) | ||
end |