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
10ff31b7
Commit
10ff31b7
authored
4 years ago
by
Johannes Schumann
Browse files
Options
Downloads
Patches
Plain Diff
Changed xsection object to ndarray
parent
ae1cfd38
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1
Merge python environment
Checking pipeline status
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
km3buu/output.py
+31
-11
31 additions, 11 deletions
km3buu/output.py
with
31 additions
and
11 deletions
km3buu/output.py
+
31
−
11
View file @
10ff31b7
...
...
@@ -20,21 +20,29 @@ from os import listdir
from
os.path
import
isfile
,
join
,
abspath
from
tempfile
import
TemporaryDirectory
from
.jobcard
import
Jobcard
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
read_nu_abs_xsection
(
filepath
):
"""
Read the crosssections calculated by GiBUU
Parameters
----------
filepath: str
Filepath to the GiBUU output file with neutrino absorption cross-section
(neutrino_absorption_cross_section_*.dat)
def
__getitem__
(
self
,
key
):
return
self
.
_xsections
[
key
]
"""
with
open
(
filepath
,
"
r
"
)
as
f
:
lines
=
f
.
readlines
()
header
=
re
.
sub
(
r
'
\d+:|#
'
,
''
,
lines
[
0
]).
split
()
dt
=
np
.
dtype
([(
field
,
np
.
float64
)
for
field
in
header
])
values
=
np
.
genfromtxt
(
StringIO
(
lines
[
-
1
]),
dtype
=
dt
)
return
values
class
FinalEvents
:
...
...
@@ -113,5 +121,17 @@ class GiBUUOutput:
if
XSECTION_FILENAMES
[
"
all
"
]
in
self
.
output_files
:
setattr
(
self
,
"
xsection
"
,
NeutrinoAbsorptionXS
ection
(
read_nu_abs_xs
ection
(
join
(
self
.
_data_path
,
XSECTION_FILENAMES
[
"
all
"
])))
self
.
_jobcard
=
None
def
associate_jobcard
(
self
,
jobcard
):
"""
Append a jobcard to the wrapped output directory
Parameters
----------
jobcard: Jobcard
Jobcard object instance
"""
self
.
_jobcard
=
jobcard
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