2012-04-12 81 views
4

我已經與ROOT廣泛合作,它有自己的數據文件格式,但由於各種原因,我們希望切換到HDF5文件。不幸的是,我們仍然需要一些在格式之間翻譯文件的方法。有沒有人知道任何現有的圖書館這樣做?HDF5與ROOT框架的集成

回答

4

你可能會檢查出rootpy,這對於通過PyTables轉換ROOT文件到HDF5設施:如果這個問題仍然是你的興趣http://www.rootpy.org/commands/root2hdf5.html

+0

也發現這個獨立(這是我找到的)。 – Shep 2012-05-19 05:57:26

+0

現在還有其他一些: - https://github.com/havoc-io/root2hdf5 - https://github.com/diana-hep/rootconverter/blob/master/root2hdf5/src/root2hdf5.cpp – DragonTux 2016-04-20 07:55:49

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) 
0

,當我最後一次檢查的(幾個月前)root2hdf5有一個限制,即它無法處理它是陣列TBranches。出於這個原因,我寫了一個bash腳本:root2hdf(對於非創意名稱感到抱歉)。

它將ROOT文件和文件中TTree的路徑作爲輸入參數並生成源代碼&編譯爲可在ROOT文件上運行的可執行文件,將它們轉換爲HDF5數據集。

它也有一個限制,它不能處理化合物TBranch類型,但我不知道root2hdf5也沒有。

+0

我被你的TH3Danim分心了。這很酷,但[它泄漏內存](https://github.com/ghollisjr/TH3Danim/blob/master/TH3Danim.hh#L62)。 – Shep 2014-02-10 12:53:27

+0

啊是的TH3Danim有點灰塵;我真的只在ROOT會話中使用它,所以它沒有抱怨在第一次使用時試圖釋放內存。我會修補它。 – ghollisjr 2014-02-11 20:24:44

+0

很確定,仍然沒有這樣做:你在一個指針數組上調用數組析構函數,它只會刪除指向這些對象的所有指針,而不會觸及這些對象。 – Shep 2014-02-12 23:10:50