rootpy provides the command root2hdf5 for converting ROOT files containing TTrees into HDF5 files containing HDF5 tables.


To use this command you must have HDF5, PyTables, NumPy and root_numpy installed.

Run with the help option to see a full list of available options:

$ root2hdf5 -h
[?1034husage: root2hdf5 [-h] [--version] [-n ENTRIES] [-f] [-u] [--ext EXT]
                 [-c {0,1,2,3,4,5,6,7,8,9}] [-l {zlib,lzo,bzip2,blosc}] [-s SELECTION]
                 [--script SCRIPT] [-q] [--no-progress-bar]
                 files [files ...]

Convert ROOT files containing TTrees into HDF5 files containing HDF5 tables

positional arguments:

optional arguments:
  -h, --help            show this help message and exit
  --version             show the version number and exit
  -n ENTRIES, --entries ENTRIES
                        number of entries to read at once (default: 100000)
  -f, --force           overwrite existing output files (default: False)
  -u, --update          update 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)
  -s SELECTION, --selection SELECTION
                        apply a selection on each tree with a cut expression (default: None)
  --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)
  --no-progress-bar     do not show the progress bar (default: False)

Typical output will look like this:

$ root2hdf5 ../rootpy/testdata/test_tree.root
INFO:rootpy.root2hdf5] Converting ../rootpy/testdata/test_tree.root ...
INFO:rootpy.root2hdf5] Will convert 1 tree in this directory
INFO:rootpy.root2hdf5] Converting tree 'test' with 1000 entries ...
INFO:rootpy.root2hdf5] Created ../rootpy/testdata/test_tree.h5

When run interactively you will also see a progress bar fill from left to right as each tree is converted. The progress bar can be disabled with the --no-progress-bar option.


Also see rootpy’s rootpy.root2hdf5.root2hdf5() function for direct access to the underlying conversion function for use in your own applications.

Previous topic


Next topic

NumPy Interface

This Page