纯python和numpy中的根i/o。
uproot的Python项目详细描述
uproot(最初是μproot,用于“micro python root”)是ROOT file format的读者和作者,只使用python和numpy。与标准C++根实现不同,UPROT仅是I/O库,主要用于将数据流到Python中的机器学习库中。与PyROOT和RooToStudio不同,根除不依赖于C++根。相反,它使用numpy将根文件中的数据块转换为numpy数组。
python并不一定意味着慢。只要数据块(“筐”)大,这种“一次阵列”的方法甚至可以比“一次一次”的C++更快。下面,将数据读取到具有根除的数组的速率被显示为比C++根(左)和RooTyNoMyPy(右)快,只要筐是几十千兆字节或更大(对于不同物理样本集合中的每个事件的可变数量μ子,越高越好)。
根项目团队不维护uproot,因此这里的bug报告是GitHub issues,而不是在根论坛上。谢谢!
安装
像其他python包一样安装uproot:
pip install uproot # maybe with sudo or --user, or in virtualenv
或者使用conda:
安装conda config --add channels conda-forge # if you haven't added conda-forge already
conda install uproot
pip安装程序会自动安装严格的依赖项;conda安装程序还会安装可选的依赖项(熊猫除外)。
严格依赖:
- numpy(1.13.1+)
- awkward-array(0.12.0+)
- uproot-methods(0.7.0+)
- cachetools
教程
有关tutorial,请参见project homepage。
在活页夹上运行that tutorial。
教程内容:
- Introduction
- What is uproot?
- Exploring a file
- Reading arrays from a TTree
- Caching data
- Lazy arrays
- Iteration
- Changing the output container type
- Filling Pandas DataFrames
- Selecting and interpreting branches
- TBranch interpretations
- Reading data into a preexisting array
- Passing many new interpretations in one call
- Multiple values per event: fixed size arrays
- Multiple values per event: leaf-lists
- Multiple values per event: jagged arrays
- Jagged array performance
- Special physics objects: Lorentz vectors
- Variable-width values: strings
- Arbitrary objects in TTrees
- Doubly nested jagged arrays (i.e. std::vector<std::vector<T>>)
- Parallel array reading
- Histograms, TProfiles, TGraphs, and others
- Creating and writing data to ROOT files