Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
KM3BUU
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
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
simulation
KM3BUU
Commits
3bea5798
Commit
3bea5798
authored
4 years ago
by
Johannes Schumann
Browse files
Options
Downloads
Patches
Plain Diff
Update to uproot4 and awkward1
parent
543aa381
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#14547
failed
4 years ago
Stage: test
Stage: coverage
Stage: doc
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
km3buu/output.py
+12
-34
12 additions, 34 deletions
km3buu/output.py
requirements.txt
+2
-2
2 additions, 2 deletions
requirements.txt
with
14 additions
and
36 deletions
km3buu/output.py
+
12
−
34
View file @
3bea5798
...
...
@@ -18,8 +18,8 @@ from io import StringIO
from
os
import
listdir
from
os.path
import
isfile
,
join
,
abspath
from
tempfile
import
TemporaryDirectory
import
awkward
import
uproot
import
awkward
1
import
uproot
4
from
scipy.interpolate
import
UnivariateSpline
from
scipy.spatial.transform
import
Rotation
...
...
@@ -168,43 +168,21 @@ class GiBUUOutput:
return
wgt
@property
def
particle_df
(
self
):
import
pandas
as
pd
def
df
(
self
):
df
=
None
for
fname
in
self
.
root_pert_files
:
fobj
=
uproot
.
open
(
join
(
self
.
_data_path
,
fname
))
file_df
=
None
for
col
in
PARTICLE_COLUMNS
:
tmp
=
awkward
.
topandas
(
fobj
[
"
RootTuple
"
][
col
].
array
(),
flatten
=
True
)
tmp
.
name
=
col
if
file_df
is
None
:
file_df
=
tmp
else
:
file_df
=
pd
.
concat
([
file_df
,
tmp
],
axis
=
1
)
fobj
=
uproot4
.
open
(
join
(
self
.
_data_path
,
fname
))
event_data
=
fobj
[
"
RootTuple
"
].
arrays
()
tmp_df
=
awkward1
.
to_pandas
(
event_data
)
if
df
is
None
:
df
=
file
_df
df
=
tmp
_df
else
:
new_indices
=
file
_df
.
index
.
levels
[
0
]
+
df
.
index
.
levels
[
0
].
max
(
new_indices
=
tmp
_df
.
index
.
levels
[
0
]
+
df
.
index
.
levels
[
0
].
max
(
)
+
1
file_df
.
index
=
file_df
.
index
.
set_levels
(
new_indices
,
level
=
0
)
df
=
df
.
append
(
file_df
)
fobj
.
close
()
return
df
@property
def
event_info_df
(
self
):
import
pandas
as
pd
df
=
None
for
fname
in
self
.
root_pert_files
:
fobj
=
uproot
.
open
(
join
(
self
.
_data_path
,
fname
))
event_data
=
fobj
[
"
RootTuple
"
]
dct
=
{
k
:
event_data
[
k
].
array
()
for
k
in
EVENTINFO_COLUMNS
}
if
df
is
None
:
df
=
pd
.
DataFrame
(
dct
)
else
:
df
=
df
.
append
(
pd
.
DataFrame
(
dct
),
ignore_index
=
True
)
df
[
"
By
"
]
=
1
-
df
.
lepOut_E
/
df
.
lepIn_E
tmp_df
.
index
=
tmp_df
.
index
.
set_levels
(
new_indices
,
level
=
0
)
df
=
df
.
append
(
tmp_df
)
df
.
columns
=
[
col
[
0
]
for
col
in
df
.
columns
]
df
[
"
By
"
]
=
1
-
df
.
lepOut_E
/
df
.
lepIn_E
return
df
...
...
This diff is collapsed.
Click to expand it.
requirements.txt
+
2
−
2
View file @
3bea5798
...
...
@@ -6,6 +6,6 @@ thepipe
particle
click
f90nml
uproot
awkward
uproot
4
awkward
1
pandas
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