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
f8c98ab4
Commit
f8c98ab4
authored
5 years ago
by
Johannes Schumann
Browse files
Options
Downloads
Patches
Plain Diff
Added object for parsing neutrino Xsection output
parent
2247a605
No related branches found
No related tags found
1 merge request
!1
Merge python environment
Pipeline
#9411
passed with warnings
5 years ago
Stage: test
Stage: coverage
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
km3buu/data/test-data/neutrino_absorption_cross_section_ALL.dat
+2
-0
2 additions, 0 deletions
.../data/test-data/neutrino_absorption_cross_section_ALL.dat
km3buu/output.py
+17
-0
17 additions, 0 deletions
km3buu/output.py
km3buu/tests/test_output.py
+13
-1
13 additions, 1 deletion
km3buu/tests/test_output.py
with
32 additions
and
1 deletion
km3buu/data/test-data/neutrino_absorption_cross_section_ALL.dat
0 → 100644
+
2
−
0
View file @
f8c98ab4
# 1:var 2:sum 3:QE 4:Delta 5:highRES 6:1pi 7:DIS 8:2p2h-QE 9:2p2h-Delta 10:2pi
1.0000 0.61548 0.0000 0.61537 0.10661E-03 0.0000 0.0000 0.0000 0.0000 0.0000
This diff is collapsed.
Click to expand it.
km3buu/output.py
+
17
−
0
View file @
f8c98ab4
...
...
@@ -12,12 +12,29 @@ __maintainer__ = "Johannes Schumann"
__email__
=
"
jschumann@km3net.de
"
__status__
=
"
Development
"
import
re
import
mmap
import
numpy
as
np
from
io
import
StringIO
from
os
import
listdir
from
os.path
import
isfile
,
join
,
abspath
EVENT_FILENAME
=
"
FinalEvents.dat
"
XSECTION_FILENAMES
=
{
"
all
"
:
"
neutrino_absorption_cross_section_ALL.dat
"
}
class
NeutrinoAbsorptionXSection
:
def
__init__
(
self
,
filepath
):
self
.
_filepath
=
filepath
with
open
(
self
.
_filepath
,
"
r
"
)
as
f
:
lines
=
f
.
readlines
()
header
=
re
.
sub
(
r
'
\d+:|#
'
,
''
,
lines
[
0
]).
split
()
values
=
map
(
float
,
lines
[
1
].
split
())
self
.
_xsections
=
dict
(
zip
(
header
,
values
))
def
__getitem__
(
self
,
key
):
return
self
.
_xsections
[
key
]
class
FinalEvents
:
def
__init__
(
self
,
filepath
):
...
...
This diff is collapsed.
Click to expand it.
km3buu/tests/test_output.py
+
13
−
1
View file @
f8c98ab4
...
...
@@ -19,9 +19,21 @@ from os.path import abspath, join, dirname
TESTDATA_DIR
=
abspath
(
join
(
dirname
(
__file__
),
"
../data/test-data/
"
))
class
TestXSection
(
unittest
.
TestCase
):
def
test_xsection_all
(
self
):
filename
=
join
(
TESTDATA_DIR
,
XSECTION_FILENAMES
[
"
all
"
])
xsection
=
NeutrinoAbsorptionXSection
(
filename
)
self
.
assertAlmostEqual
(
xsection
[
'
var
'
],
1.0
)
self
.
assertAlmostEqual
(
xsection
[
'
sum
'
],
0.61548
)
self
.
assertAlmostEqual
(
xsection
[
'
Delta
'
],
0.61537
)
self
.
assertAlmostEqual
(
xsection
[
'
highRES
'
],
1.0661e-4
)
self
.
assertAlmostEqual
(
xsection
[
'
Delta
'
],
0.61537
)
class
TestFinalEvents
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
filename
=
join
(
TESTDATA_DIR
,
"
FinalEvents.dat
"
)
self
.
filename
=
join
(
TESTDATA_DIR
,
EVENT_FILENAME
)
self
.
final_events
=
FinalEvents
(
self
.
filename
)
def
test_values
(
self
):
...
...
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