HDF5.jl icon indicating copy to clipboard operation
HDF5.jl copied to clipboard

It seems h5info is not implemented: is there an alternative?

Open PetrKryslUCSD opened this issue 4 years ago • 7 comments

It seems h5info is not implemented: is there an alternative? Similarly h5disp ... I do appreciate this package: it is very useful!

PetrKryslUCSD avatar Feb 11 '21 23:02 PetrKryslUCSD

h5info as in the matlab function https://www.mathworks.com/help/matlab/ref/h5info.html ?

musm avatar Feb 12 '21 15:02 musm

Sorry: I made an incorrect assumption that h5info available in Matlab is a built-in function of HDF5. So, is there something like this available in this package?

PetrKryslUCSD avatar Feb 12 '21 16:02 PetrKryslUCSD

Does HDF5.show_tree satisfy your needs?

From test/plain.jl


# Make an interesting file tree
hfile = h5open(fn, "w")
# file level
hfile["version"] = 1.0
attributes(hfile)["creator"] = "HDF5.jl"
# group level
create_group(hfile, "inner")
attributes(hfile["inner"])["dirty"] = true
# dataset level
hfile["inner/data"] = collect(-5:5)
attributes(hfile["inner/data"])["mode"] = 1
# non-trivial committed datatype
# TODO: print more datatype information
tmeta = HDF5.Datatype(HDF5.h5t_create(HDF5.H5T_COMPOUND, sizeof(Int) + sizeof(Float64)))
HDF5.h5t_insert(tmeta, "scale", 0, HDF5.hdf5_type_id(Int))
HDF5.h5t_insert(tmeta, "bias", sizeof(Int), HDF5.hdf5_type_id(Float64))
tstr = datatype("fixed")
t = HDF5.Datatype(HDF5.h5t_create(HDF5.H5T_COMPOUND, sizeof(tmeta) + sizeof(tstr)))
HDF5.h5t_insert(t, "meta", 0, tmeta)
HDF5.h5t_insert(t, "type", sizeof(tmeta), tstr)
commit_datatype(hfile, "dtype", t)


# Example run

julia> HDF5.show_tree(hfile)
🗂️ HDF5.File: (read-write) C:\Users\Mus\AppData\Local\Temp\jl_TU1f7TtXWt
├─ 🏷️ creator
├─ 📄 dtype
├─ 📂 inner
│  ├─ 🏷️ dirty
│  └─ 🔢 data
│     └─ 🏷️ mode
└─ 🔢 version

musm avatar Feb 12 '21 16:02 musm

I am like a child in a candy store! This is fantastic. This function should be well documented, it could well be a selling point that will seal the deal for someone who's interested in this package. At the moment I can't find it in the documentation.

PetrKryslUCSD avatar Feb 12 '21 17:02 PetrKryslUCSD

Good point, we should definitely advertise this more and document it. At the same time this is the default method for show so it should show up transparently.

musm avatar Feb 12 '21 17:02 musm

HDF5.show_tree is the implementation for the default 3-argument show method since v0.14. (#725)

jmert avatar Feb 12 '21 17:02 jmert

That being said, a summary function like h5info that returns a Dict or NamedTuple data structure could still be useful and should be implementable.

jmert avatar Feb 12 '21 17:02 jmert

I think the default show addresses most of the relevant issues. If tweaks are required, please open another issue.

simonbyrne avatar Jan 21 '23 06:01 simonbyrne