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
Commits
af2d04e4
Commit
af2d04e4
authored
4 years ago
by
Tamas Gal
Browse files
Options
Downloads
Patches
Plain Diff
Add option to auto-convert keys to awkward
parent
39ccf4d3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#10544
failed
4 years ago
Stage: test
Stage: coverage
Stage: doc
Stage: release
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
km3io/offline.py
+2
-1
2 additions, 1 deletion
km3io/offline.py
km3io/tools.py
+9
-1
9 additions, 1 deletion
km3io/tools.py
with
11 additions
and
2 deletions
km3io/offline.py
+
2
−
1
View file @
af2d04e4
...
...
@@ -38,7 +38,8 @@ SUBBRANCH_MAPS = [
exclude
=
EXCLUDE_KEYS
+
[
'
trks.usr_data
'
,
'
trks.usr
'
,
'
trks.fUniqueID
'
,
'
trks.fBits
'
],
attrparser
=
_nested_mapper
,
flat
=
False
),
flat
=
False
,
toawkward
=
[
'
fitinf
'
,
'
rec_stages
'
]),
BranchMapper
(
name
=
"
mc_tracks
"
,
key
=
"
mc_trks
"
,
exclude
=
EXCLUDE_KEYS
+
[
...
...
This diff is collapsed.
Click to expand it.
km3io/tools.py
+
9
−
1
View file @
af2d04e4
#!/usr/bin/env python3
from
collections
import
namedtuple
import
numpy
as
np
import
awkward1
as
ak
import
uproot
# 110 MB based on the size of the largest basket found so far in km3net
BASKET_CACHE_SIZE
=
110
*
1024
**
2
...
...
@@ -44,7 +45,8 @@ class BranchMapper:
update
=
None
,
attrparser
=
None
,
flat
=
True
,
interpretations
=
None
):
interpretations
=
None
,
toawkward
=
None
):
"""
Mapper helper for keys in a ROOT branch.
...
...
@@ -68,6 +70,9 @@ class BranchMapper:
The function to be used to create attribute names. This is only
needed if unsupported characters are present, like ``.``, which
would prevent setting valid Python attribute names.
toawkward: ``None``, ``list(str)``
List of keys to convert to awkward arrays (recommended for
doubly ragged arrays)
"""
self
.
name
=
name
self
.
key
=
key
...
...
@@ -78,6 +83,7 @@ class BranchMapper:
self
.
attrparser
=
(
lambda
x
:
x
)
if
attrparser
is
None
else
attrparser
self
.
flat
=
flat
self
.
interpretations
=
{}
if
interpretations
is
None
else
interpretations
self
.
toawkward
=
[]
if
toawkward
is
None
else
toawkward
class
Branch
:
...
...
@@ -145,6 +151,8 @@ class Branch:
out
=
self
.
_branch
[
self
.
_keymap
[
key
]].
lazyarray
(
interpretation
=
self
.
_mapper
.
interpretations
.
get
(
key
),
basketcache
=
BASKET_CACHE
)
if
self
.
_index_chain
is
not
None
and
key
in
self
.
_mapper
.
toawkward
:
out
=
ak
.
from_iter
(
out
)
return
_unfold_indices
(
out
,
self
.
_index_chain
)
def
__getitem__
(
self
,
item
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment