Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
km3io
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
km3py
km3io
Merge requests
!21
Resolve "Reduce the amount of uproot.open (to one)"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "Reduce the amount of uproot.open (to one)"
36-reduce-the-amount-of-uproot-open-to-one
into
master
Overview
0
Commits
14
Pipelines
13
Changes
3
Merged
Tamas Gal
requested to merge
36-reduce-the-amount-of-uproot-open-to-one
into
master
5 years ago
Overview
0
Commits
14
Pipelines
13
Changes
3
Expand
Closes
#36 (closed)
Edited
5 years ago
by
Tamas Gal
0
0
Merge request reports
Viewing commit
e93a51e1
Prev
Next
Show latest version
3 files
+
1
−
382
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
e93a51e1
Remove obselete Reader class
· e93a51e1
Tamas Gal
authored
5 years ago
km3io/offline.py
+
0
−
65
Options
@@ -211,71 +211,6 @@ class OfflineKeys:
return
km3io
.
definitions
.
trigger
.
data
class
Reader
:
"""
Reader for one offline ROOT file
"""
def
__init__
(
self
,
file_path
):
"""
Reader class is an offline ROOT file reader. This class is a
"
very
"
low level I/O.
Parameters
----------
file_path : str or file-like object
The file of interest.
"""
self
.
_tree
=
uproot
.
open
(
file_path
)[
MAIN_TREE_NAME
]
self
.
_data
=
self
.
_tree
.
lazyarrays
(
basketcache
=
uproot
.
cache
.
ThreadSafeArrayCache
(
BASKET_CACHE_SIZE
))
self
.
_keys
=
None
def
__getitem__
(
self
,
key
):
"""
reads data stored in the branch of interest in an Evt tree.
Parameters
----------
key : str
name of the branch of interest in event data.
Returns
-------
lazyarray
Lazyarray of all data stored in the branch of interest. A lazyarray
is an array-like object that reads data on demand. Here, only the
first and last chunks of data are read in memory, and not all data
in the array. The output can be used with all `Numpy
'
s universal
functions <https://docs.scipy.org/doc/numpy/reference/ufuncs.html>`
.
Raises
------
KeyError
Some branches in an offline file structure are
"
fake branches
"
and
do not contain data. Therefore, the keys corresponding to these
fake branches are not read.
"""
keys
=
self
.
keys
.
valid_keys
if
key
not
in
keys
and
not
isinstance
(
key
,
int
):
raise
KeyError
(
"'
{}
'
is not a valid key or is a fake branch.
"
.
format
(
key
))
return
self
.
_data
[
key
]
def
__len__
(
self
):
return
len
(
self
.
_data
)
def
__repr__
(
self
):
return
"
<{}: {} entries>
"
.
format
(
self
.
__class__
.
__name__
,
len
(
self
))
@cached_property
def
keys
(
self
):
"""
wrapper for all keys in an offline file.
Returns
-------
Class
OfflineKeys.
"""
return
OfflineKeys
(
self
.
_tree
)
class
OfflineReader
:
"""
reader for offline ROOT files
"""
def
__init__
(
self
,
file_path
=
None
):
Loading