Skip to main content

An interface between ROOT and NumPy

Project description

https://travis-ci.org/rootpy/root_numpy.png https://pypip.in/v/root_numpy/badge.png https://pypip.in/d/root_numpy/badge.png

root_numpy is a Python extension for converting ROOT TTrees into NumPy recarrays or structured arrays as well as converting NumPy arrays back into ROOT TTrees. With the core internals written in C++, root_numpy can efficiently handle large amounts of data (limited only by the available memory). Now that your ROOT data is in NumPy form, you can make use of the many powerful scientific Python packages or perform quick exploratory data analysis in interactive environments like IPython (especially IPython’s popular notebook feature).

root_numpy currently supports basic types such as bool, int, float, double, etc. and arrays of basic types (both variable and fixed-length). Vectors of basic types are also supported.

See the root2hdf5 script in the rootpy package that uses root_numpy and PyTables to convert all TTrees in a ROOT file into the HDF5 format.

import ROOT
from root_numpy import root2array, root2rec, tree2rec

# convert into a numpy structured array
# treename is always optional if there is only one tree in the file
arr = root2array('a.root', 'treename')

# convert into a numpy record array
rec = root2rec('a.root', 'treename')

# or directly convert a tree
rfile = ROOT.TFile('a.root')
tree = rfile.Get('treename')
rec = tree2rec(tree)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

root_numpy-3.0.1.tar.gz (269.7 kB view details)

Uploaded Source

File details

Details for the file root_numpy-3.0.1.tar.gz.

File metadata

  • Download URL: root_numpy-3.0.1.tar.gz
  • Upload date:
  • Size: 269.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for root_numpy-3.0.1.tar.gz
Algorithm Hash digest
SHA256 55ef4f1e2fe085070b3d5e8cf4b3714b360e058f9e69907026d6c1632444584b
MD5 f8da7d9ef45ee89a000ee3c03b0bf4c8
BLAKE2b-256 ffc7dc08ec9400e46c5758698c8a5905567e074613e31f518f27a40dccb4a7c3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page