Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
parser-atk
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This project is archived. Its data is
read-only
.
Show more breadcrumbs
nomad-lab
parser-atk
Commits
19ca5f00
Commit
19ca5f00
authored
Sep 28, 2016
by
Mikkel Strange
Browse files
Options
Downloads
Patches
Plain Diff
some polishing
parent
855572a1
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
parser/parser-atk/atkio.py
+28
-11
28 additions, 11 deletions
parser/parser-atk/atkio.py
with
28 additions
and
11 deletions
parser/parser-atk/atkio.py
+
28
−
11
View file @
19ca5f00
from
scipy.io.netcdf
import
netcdf_file
from
configurations
import
conf_types
from
parser_configurations2
import
parse_configuration
from
parser_calculator
import
parse_calculator
import
re
class
Reader
:
def
__init__
(
self
,
fname
):
self
.
atoms_x
=
{}
# like {'gID0001': Atoms('H2')}
self
.
calculator_x
=
{}
# like {'gID0001': LCAOCalculator}
self
.
f
=
netcdf_file
(
fname
,
'
r
'
,
mmap
=
True
)
self
.
initialize
()
gids
=
self
.
calc_names
.
keys
()
for
gid
in
gids
:
conf_name
=
self
.
conf_names
[
gid
]
calc_name
=
self
.
calc_names
[
gid
]
fpt
=
self
.
finger_print_table
[
gid
]
self
.
atoms_x
[
gid
]
=
parse_configuration
(
self
.
f
,
conf_name
)
self
.
calculator_x
[
gid
]
=
parse_calculator
(
self
.
f
,
calc_name
)
def
initialize
(
self
):
self
.
conf_names
=
self
.
get
_configuration_names
()
self
.
calc_names
=
self
.
get
_calculator_names
()
self
.
finger_print_table
=
self
.
get
_finger_print_table
()
self
.
conf_names
=
self
.
_read
_configuration_names
()
self
.
calc_names
=
self
.
_read
_calculator_names
()
self
.
finger_print_table
=
self
.
_read
_finger_print_table
()
def
get_configuration_names
(
self
):
def
_read_configuration_names
(
self
):
"""
find the configuration names in the nc files,
i.e. {
'
gID001
'
:
'
BulkConfiguration_gID001
'
}
"""
d
=
self
.
f
.
dimensions
conf_names
=
{}
for
k
in
d
.
keys
():
...
...
@@ -25,7 +38,7 @@ class Reader:
conf_names
[
g
[
1
:]]
=
conf_type
+
g
return
conf_names
def
get
_calculator_names
(
self
):
def
_read
_calculator_names
(
self
):
d
=
self
.
f
.
dimensions
calc_names
=
{}
for
k
in
d
.
keys
():
...
...
@@ -38,10 +51,10 @@ class Reader:
calc_names
[
g
[
1
:]]
=
conf_type
+
g
+
'
_calculator
'
return
calc_names
def
get
_finger_print_table
(
self
):
def
_read
_finger_print_table
(
self
):
table
=
{}
if
hasattr
(
self
.
f
,
'
fingerprint_table
'
):
fpt
=
f
d
.
fingerprint_table
fpt
=
self
.
f
.
fingerprint_table
.
decode
(
'
utf-8
'
)
for
fpg
in
fpt
.
split
(
'
#
'
)[:
-
1
]:
fp
,
g
=
fpg
.
split
(
'
:
'
)[:
2
]
table
[
g
]
=
fp
...
...
@@ -50,9 +63,13 @@ class Reader:
def
get_number_of_configurations
(
self
):
return
len
(
self
.
conf_names
)
def
get_atoms
(
self
):
def
get_atoms
(
self
,
n
=-
1
):
key
=
[
key
for
key
in
sorted
(
self
.
atoms_x
.
keys
(),
reverse
=
True
)][
n
]
return
self
.
atoms_x
[
key
]
if
__name__
==
'
__main__
'
:
r
=
Reader
(
'
h2.nc
'
)
print
(
r
.
get_configuration_names
())
print
(
r
.
get_finger_print_table
())
import
sys
r
=
Reader
(
sys
.
argv
[
1
])
for
key
,
value
in
r
.
atoms_x
.
items
():
print
(
key
,
value
)
print
(
r
.
get_atoms
(
0
))
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
sign in
to comment