4

我与ROOT进行了广泛的合作,它有自己的数据文件格式,但由于各种原因,我们想切换到HDF5文件。不幸的是,我们仍然需要一些在格式之间转换文件的方法。有谁知道这样做的任何现有图书馆?

4

3 回答 3

4

您可以查看 rootpy,它具有通过 PyTables 将 ROOT 文件转换为 HDF5 的功能: http ://www.rootpy.org/commands/root2hdf5.html

于 2012-05-18T20:46:45.000 回答
2

如果您仍然对这个问题感兴趣,最近对rootpyroot2hdf5脚本和root_numpy包(root2hdf5 用于将 TTrees 转换为 NumPy 结构化数组)进行了重大改进:

root2hdf5 -h
usage: root2hdf5 [-h] [-n ENTRIES] [-f] [--ext EXT] [-c {0,1,2,3,4,5,6,7,8,9}]
                 [-l {zlib,lzo,bzip2,blosc}] [--script SCRIPT] [-q]
                 files [files ...]

positional arguments:
  files

optional arguments:
  -h, --help            show this help message and exit
  -n ENTRIES, --entries ENTRIES
                        number of entries to read at once (default: 100000.0)
  -f, --force           overwrite existing output files (default: False)
  --ext EXT             output file extension (default: h5)
  -c {0,1,2,3,4,5,6,7,8,9}, --complevel {0,1,2,3,4,5,6,7,8,9}
                        compression level (default: 5)
  -l {zlib,lzo,bzip2,blosc}, --complib {zlib,lzo,bzip2,blosc}
                        compression algorithm (default: zlib)
  --script SCRIPT       Python script containing a function with the same name 
                        that will be called on each tree and must return a tree or 
                        list of trees that will be converted instead of the 
                        original tree (default: None)
  -q, --quiet           suppress all warnings (default: False)
于 2013-01-19T20:04:35.097 回答
0

截至我上次检查时(几个月前),root2hdf5 有一个限制,它无法处理数组的 TBranches。出于这个原因,我编写了一个 bash 脚本:root2hdf(对不起,非创意名称)。

它将一个 ROOT 文件和文件中 TTree 的路径作为输入参数,并生成源代码并编译为可以在 ROOT 文件上运行的可执行文件,将它们转换为 HDF5 数据集。

它也有一个限制,它不能处理复合 TBranch 类型,但我不知道 root2hdf5 也可以。

于 2014-02-10T06:30:49.337 回答