How to measure size (in bytes) of a column read from a ROOT file? #1081
-
Hi, I would like to read a single column from a ROOT file using What is the best way to achieve this? I am currently using |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
After opening the file and selecting the TBranch like this: file = uproot.open("PATH/TO/FILE.root")
tree = file["TREE_NAME"]
branch = tree["BRANCH_NAME"] (replacing everything in UPPERCASE), you can get the compressed size on disk with branch.compressed_bytes, the uncompressed size with branch.uncompressed_bytes, and you can read the data into an array with array = branch.array() and then look at the array's number of bytes with If you pass If you don't pass anything or pass The size is affected by more than just compression. The TBranch data is stored in chunks called TBaskets, and each TBasket has a header, which is usually less than 100 bytes and some of it sits outside of the compressed part. The values returned by the |
Beta Was this translation helpful? Give feedback.
-
@jpivarski thanks a lot for such a detailed answer! I have a couple of follow-up questions:
|
Beta Was this translation helpful? Give feedback.
After opening the file and selecting the TBranch like this:
(replacing everything in UPPERCASE), you can get the compressed size on disk with branch.compressed_bytes, the uncompressed size with branch.uncompressed_bytes, and you can read the data into an array with array = branch.array() and then look at the array's number of bytes with
array.nbytes
.If you pass
library="np"
to thearray
function, it will be a NumPy array, for whichnbytes
counts the size of the single buffer in memory only (so if it's not numerical data and it gets materialized as Python objects in an array withdtype=object
, the…