Пример #1
0
def test_root2hdf5_chunked_selected():
    try:
        import tables
    except ImportError:
        raise SkipTest

    from rootpy.root2hdf5 import root2hdf5

    rfile = get_file('test_tree.root')
    hfilename = os.path.join(TEMPDIR, 'out.h5')
    root2hdf5(rfile, hfilename, entries=90, selection='i % 2 == 0')

    hfile = tables.openFile(hfilename)
    assert_equal(len(hfile.root.test), 500)
    hfile.close()
Пример #2
0
def test_root2hdf5():
    try:
        import tables
    except ImportError:
        raise SkipTest

    from rootpy.root2hdf5 import root2hdf5

    rfile = get_file('test_tree.root')
    hfilename = os.path.join(TEMPDIR, 'out.h5')
    root2hdf5(rfile, hfilename)

    hfile = tables.openFile(hfilename)
    assert_equal(len(hfile.root.test), 1000)
    hfile.close()
Пример #3
0
def test_root2hdf5_chunked_selected():
    try:
        import tables
    except ImportError:
        raise SkipTest

    from rootpy.root2hdf5 import root2hdf5

    rfile = get_file('test_tree.root')
    hfilename = os.path.join(TEMPDIR, 'out.h5')
    root2hdf5(rfile, hfilename, entries=90, selection='i % 2 == 0')

    hfile = tables.openFile(hfilename)
    assert_equal(len(hfile.root.test), 500)
    hfile.close()
Пример #4
0
def test_root2hdf5():
    try:
        import tables
    except ImportError:
        raise SkipTest

    from rootpy.root2hdf5 import root2hdf5

    rfile = get_file('test_tree.root')
    hfilename = os.path.join(TEMPDIR, 'out.h5')
    root2hdf5(rfile, hfilename)

    hfile = tables.openFile(hfilename)
    assert_equal(len(hfile.root.test), 1000)
    hfile.close()
Пример #5
0
def test_root2hdf5_chunked():
    try:
        import tables
    except ImportError:
        raise SkipTest

    from rootpy.root2hdf5 import root2hdf5, tables_open

    rfile = get_file("test_tree.root")
    hfilename = os.path.join(TEMPDIR, "out.h5")
    root2hdf5(rfile, hfilename, entries=10)

    hfile = tables_open(hfilename)
    assert_equal(len(hfile.root.test), 1000)
    hfile.close()
Пример #6
0
def main():

    root2hdf5.root2hdf5(
        "/user/hermanse/analysis/rootfiles_test/run2126-00.root",
        "/user/hermanse/analysis/rootfiles_test/run2126-00.h5")
Пример #7
0
from __future__ import print_function
import argparse

import pandas as pd
from rootpy.root2hdf5 import root2hdf5

parser = argparse.ArgumentParser(description='Convert ntuple from ROOT file to hdf5 store')
parser.add_argument('root_file', type=argparse.FileType(), help='Path to the ROOT file')
parser.add_argument('-i', '--input', help='Input tuple (default: %(default)s)', default='/ToolSvc.PatDebugTTTruthTool/DownstreamDebugTuple')
parser.add_argument('-o', '--output', help='Output table in hdf5 (default: %(default)s)', default='DownstreamDebugTuple')

args = parser.parse_args()

input_filename = args.root_file.name
output_filename = input_filename[:input_filename.rindex('.root')] + '.h5'

print('Converting {} to {}'.format(input_filename, output_filename))

rpath = ''
if '/' in args.input[1:]:
    rpath = args.input[:args.input.rindex('/')]

root2hdf5(input_filename, output_filename, rpath)

hdf = pd.HDFStore(output_filename)
table = hdf.get(args.input)
hdf.put(args.output, table, 'table')
hdf.remove(args.input)
hdf.close()
Пример #8
0
                    type=argparse.FileType(),
                    help='Path to the ROOT file')
parser.add_argument(
    '-i',
    '--input',
    help='Input tuple (default: %(default)s)',
    default='/ToolSvc.PatDebugTTTruthTool/DownstreamDebugTuple')
parser.add_argument('-o',
                    '--output',
                    help='Output table in hdf5 (default: %(default)s)',
                    default='DownstreamDebugTuple')

args = parser.parse_args()

input_filename = args.root_file.name
output_filename = input_filename[:input_filename.rindex('.root')] + '.h5'

print('Converting {} to {}'.format(input_filename, output_filename))

rpath = ''
if '/' in args.input[1:]:
    rpath = args.input[:args.input.rindex('/')]

root2hdf5(input_filename, output_filename, rpath)

hdf = pd.HDFStore(output_filename)
table = hdf.get(args.input)
hdf.put(args.output, table, 'table')
hdf.remove(args.input)
hdf.close()