列出julia中hdf5文件的字段

时间:2017-11-06 13:17:35

标签: julia hdf5

在julia中是否有一种方法可以在不加载数据集的情况下列出hdf5文件的字段(包括结构,组,维度)?我没有在HDF5包中找到与h5ls -r -f类似的东西。感谢。

2 个答案:

答案 0 :(得分:3)

这是非常粗略的要点h5_get_structure.jl 对于提供以下输出的HDF5文件结构映射:

/Users/TM/Temp/test.h5: HDF5.HDF5File (length 10)
 AcquisitionLog: HDF5.HDF5Group (length 0)
 AddTraces: HDF5.HDF5Group (length 5)
    PTR-Instrument: HDF5.HDF5Group (length 0)
    PTR-Misc: HDF5.HDF5Group (length 0)
    PTR-Reaction: HDF5.HDF5Group (length 0)
    TOFSupply: HDF5.HDF5Group (length 0)
    TofSupply: HDF5.HDF5Group (length 2)
       TwData: HDF5Dataset () 
       TwInfo: HDF5Dataset (28, 2) 
 FullSpectra: HDF5.HDF5Group (length 3)
    MassAxis: HDF5Dataset (100239,) 
    SumSpectrum: HDF5Dataset (100239, 1) 
    TofData: HDF5Dataset (100239, 1, 1, 6000) 
 PTR-Concentration: HDF5.HDF5Group (length 0)
 PTR-Peaktable: HDF5.HDF5Group (length 2)
    Data: HDF5Dataset (317, 8) Float64
    Info: HDF5Dataset (317,) 
 PTR-PrimaryIonSettings: HDF5.HDF5Group (length 0)
 PTR-Transmission: HDF5.HDF5Group (length 0)
 PeakData: HDF5.HDF5Group (length 2)
    PeakData: HDF5Dataset (317, 1, 1, 6000) 
    PeakTable: HDF5Dataset (4, 317) Float64
 RawData: HDF5.HDF5Group (length 1)
    HPTDC: HDF5.HDF5Group (length 0)
 TimingData: HDF5.HDF5Group (length 1)
    BufTimes: HDF5Dataset (6000,) 

答案 1 :(得分:2)

使用printnames不是100%的要求,但缺少哪些信息?

e.g。

# make hdf5 file & add two datasets
A = Vector{Int}(1:10)
h5write("bar.h5", "foo", A)
h5write("bar.h5", "2foo", 2A)

i = h5open("bar.h5", "r") # Open it
names(i) 
# 2-element Array{String,1}:
#  "2foo"
#  "foo"
[println(a) for a in i]
# HDF5 dataset: /2foo (file: bar.h5)
# HDF5 dataset: /foo (file: bar.h5)

## Run h5ls
;h5ls "bar.h5"
# 2foo                     Dataset {10}
# foo                      Dataset {10}