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
e057837c
Commit
e057837c
authored
5 years ago
by
Johannes Schumann
Browse files
Options
Downloads
Patches
Plain Diff
GiBUU output parser
parent
5e453b7d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1
Merge python environment
Pipeline
#9340
passed
5 years ago
Stage: test
Stage: coverage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
km3buu/output.py
+83
-0
83 additions, 0 deletions
km3buu/output.py
requirements.txt
+1
-0
1 addition, 0 deletions
requirements.txt
with
84 additions
and
0 deletions
km3buu/output.py
0 → 100644
+
83
−
0
View file @
e057837c
# Filename: io.py
"""
IO for km3buu
"""
__author__
=
"
Johannes Schumann
"
__copyright__
=
"
Copyright 2020, Johannes Schumann and the KM3NeT collaboration.
"
__credits__
=
[]
__license__
=
"
MIT
"
__maintainer__
=
"
Johannes Schumann
"
__email__
=
"
jschumann@km3net.de
"
__status__
=
"
Development
"
import
mmap
import
numpy
as
np
from
io
import
StringIO
from
os
import
listdir
from
os.path
import
isfile
,
join
,
abspath
class
FinalEvents
:
def
__init__
(
self
,
filepath
):
self
.
_filepath
=
filepath
with
open
(
self
.
_filepath
,
"
r
"
)
as
f
:
self
.
_final_events_map
=
mmap
.
mmap
(
f
.
fileno
(),
0
,
prot
=
mmap
.
PROT_READ
)
self
.
_line_pos
=
self
.
_line_mapper
()
def
_line_mapper
(
self
):
self
.
_final_events_map
.
seek
(
0
)
line_pos
=
[]
while
True
:
next_pos
=
self
.
_final_events_map
.
find
(
b
'
\n
'
)
+
1
if
next_pos
==
0
:
break
line_pos
.
append
(
next_pos
)
self
.
_final_events_map
.
seek
(
line_pos
[
-
1
])
return
line_pos
def
__getitem__
(
self
,
i
):
if
isinstance
(
i
,
slice
):
pos
=
self
.
_line_pos
[
i
]
else
:
pos
=
[
self
.
_line_pos
[
i
]]
s
=
[]
for
p
in
pos
:
self
.
_final_events_map
.
seek
(
p
)
s
.
append
(
self
.
_final_events_map
.
readline
().
decode
(
'
utf-8
'
))
dt
=
np
.
dtype
([(
'
run
'
,
np
.
uint32
),
(
'
event
'
,
np
.
uint32
),
(
'
id
'
,
np
.
int32
),
(
'
charge
'
,
np
.
float64
),
(
'
perweight
'
,
np
.
float64
),
(
'
x
'
,
np
.
float64
),
(
'
y
'
,
np
.
float64
),
(
'
z
'
,
np
.
float64
),
(
'
p_x
'
,
np
.
float64
),
(
'
p_y
'
,
np
.
float64
),
(
'
p_z
'
,
np
.
float64
),
(
'
history
'
,
np
.
int32
),
(
'
pID
'
,
np
.
int32
),
(
'
energy
'
,
np
.
float64
)])
return
np
.
genfromtxt
(
StringIO
(
'
\n
'
.
join
(
s
)),
dtype
=
dt
)[::
1
]
def
__len__
(
self
):
return
len
(
self
.
_line_pos
)
OUTPUT_FILE_WRAPPERS
=
{
'
FinalEvents.dat
'
:
FinalEvents
}
class
GiBUUOutput
:
def
__init__
(
self
,
data_dir
):
"""
Class for parsing GiBUU output files
Parameters
----------
data_dir: str
"""
self
.
_data_dir
=
abspath
(
data_dir
)
self
.
output_files
=
[
f
for
f
in
listdir
(
self
.
_data_dir
)
if
isfile
(
join
(
self
.
_data_dir
,
f
))
]
if
"
FinalEvents.dat
"
in
self
.
output_files
:
setattr
(
self
,
"
events
"
,
FinalEvents
(
join
(
self
.
_data_dir
,
"
FinalEvents.dat
"
)))
This diff is collapsed.
Click to expand it.
requirements.txt
+
1
−
0
View file @
e057837c
setuptools_scm
numpy
spython
thepipe
click
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