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
1f53cedb
Commit
1f53cedb
authored
4 years ago
by
Johannes Schumann
Browse files
Options
Downloads
Patches
Plain Diff
Use f90nml package for jobcard
parent
f3bdb933
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1
Merge python environment
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
km3buu/jobcard.py
+19
-22
19 additions, 22 deletions
km3buu/jobcard.py
with
19 additions
and
22 deletions
km3buu/jobcard.py
+
19
−
22
View file @
1f53cedb
...
...
@@ -13,6 +13,10 @@ __email__ = "jschumann@km3net.de"
__status__
=
"
Development
"
import
f90nml
try
:
from
StringIO
import
StringIO
except
ImportError
:
from
io
import
StringIO
INPUT_PATH
=
"
/opt/buuinput2019/
"
...
...
@@ -48,8 +52,8 @@ class Jobcard(object):
The input path pointing to the GiBUU lookup data which should be used
"""
def
__init__
(
self
,
input_path
=
INPUT_PATH
):
self
.
input_path
=
"
'
%s
'
"
%
input_path
self
.
_
groups
=
f90nml
.
Namelist
()
self
.
input_path
=
"
%s
"
%
input_path
self
.
_
nml
=
f90nml
.
Namelist
()
self
.
set_property
(
"
input
"
,
"
path_to_input
"
,
self
.
input_path
)
def
set_property
(
self
,
group
,
name
,
value
):
...
...
@@ -64,36 +68,29 @@ class Jobcard(object):
value:
The property value
"""
if
group
not
in
self
.
_
groups
.
keys
():
self
.
_
groups
[
group
]
=
{}
self
.
_
groups
[
group
][
name
]
=
value
if
group
not
in
self
.
_
nml
.
keys
():
self
.
_
nml
[
group
]
=
{}
self
.
_
nml
[
group
][
name
]
=
value
def
remove_property
(
self
,
group
,
name
):
del
self
.
_
groups
[
group
][
name
]
if
len
(
self
.
_
groups
[
group
])
==
0
:
del
self
.
_
groups
[
group
]
del
self
.
_
nml
[
group
][
name
]
if
len
(
self
.
_
nml
[
group
])
==
0
:
del
self
.
_
nml
[
group
]
def
__str__
(
self
):
retval
=
""
for
group
,
attrs
in
self
.
_groups
.
items
():
retval
+=
"
&%s
\n
"
%
group
for
attr
,
value
in
attrs
.
items
():
if
type
(
value
)
is
bool
:
retval
+=
"
\t
%s = .%s.
\n
"
%
(
attr
,
str
(
value
).
lower
())
else
:
retval
+=
"
\t
%s = %s
\n
"
%
(
attr
,
value
)
retval
+=
"
/
\n\n
"
return
retval
stream
=
StringIO
()
self
.
_nml
.
write
(
stream
)
return
stream
.
getvalue
()
def
__getitem__
(
self
,
key
):
if
isinstance
(
key
,
str
):
if
'
/
'
in
key
:
k
=
key
.
split
(
'
/
'
)
return
self
.
_
groups
[
k
[
0
]][
k
[
1
]]
return
self
.
_
nml
[
k
[
0
]][
k
[
1
]]
else
:
return
self
.
_
groups
[
key
]
return
self
.
_
nml
[
key
]
elif
isinstance
(
key
,
tuple
)
and
len
(
key
)
==
2
:
return
self
.
_
groups
[
key
[
0
]][
key
[
1
]]
return
self
.
_
nml
[
key
[
0
]][
key
[
1
]]
else
:
raise
IndexError
(
"
Invalid access to Jobcard
"
)
...
...
@@ -107,7 +104,7 @@ def read_jobcard(fpath):
Filepath of the jobcard
"""
jc
=
Jobcard
()
jc
.
_
groups
=
f90nml
.
read
(
fpath
)
jc
.
_
nml
=
f90nml
.
read
(
fpath
)
return
jc
...
...
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