Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
nomad-FAIR
Commits
828ed9db
Commit
828ed9db
authored
Jul 30, 2020
by
Markus Scheidgen
Browse files
Further removed backend from normalization.
parent
8ea11000
Changes
4
Hide whitespace changes
Inline
Side-by-side
nomad/normalizing/__init__.py
View file @
828ed9db
...
...
@@ -46,7 +46,7 @@ from .encyclopedia.encyclopedia import EncyclopediaNormalizer
normalizers
:
Iterable
[
Type
[
Normalizer
]]
=
[
SystemNormalizer
,
OptimadeNormalizer
,
FhiAimsBaseNormalizer
,
#
FhiAimsBaseNormalizer,
DosNormalizer
,
BandStructureNormalizer
,
EncyclopediaNormalizer
,
...
...
nomad/normalizing/dos.py
View file @
828ed9db
...
...
@@ -132,8 +132,6 @@ class DosNormalizer(Normalizer):
idx
+=
1
# Add quantities to NOMAD's Metainfo
scc_url
=
'/section_run/0/section_single_configuration_calculation/%d/section_dos/0'
%
scc
.
m_parent_index
self
.
_backend
.
openContext
(
scc_url
)
dos
.
dos_values_normalized
=
dos_values_normalized
# Data for DOS fingerprint
...
...
@@ -155,4 +153,3 @@ class DosNormalizer(Normalizer):
sec_dos_fingerprint
.
stepsize
=
dos_fingerprint
.
stepsize
sec_dos_fingerprint
.
grid_id
=
dos_fingerprint
.
grid_id
sec_dos_fingerprint
.
filling_factor
=
dos_fingerprint
.
filling_factor
self
.
_backend
.
closeContext
(
scc_url
)
nomad/normalizing/fhiaims.py
View file @
828ed9db
...
...
@@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
glob
import
os.path
import
json
import
numpy
as
np
...
...
@@ -25,12 +24,9 @@ controlIn_nucleus = 'x_fhi_aims_controlIn_nucleus'
pure_types_json
=
dict
()
files
=
glob
.
glob
(
os
.
path
.
join
(
__file__
,
"data/*.json"
))
for
file
in
files
:
pure_types_str
=
os
.
path
.
basename
(
os
.
path
.
split
(
file
)[
-
1
])
with
open
(
file
)
as
data_file
:
json_data
=
json
.
load
(
data_file
)
for
pure_types_str
in
[
'light'
,
'really_tight'
,
'tight'
]:
with
open
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'data'
,
pure_types_str
+
'.json'
))
as
f
:
json_data
=
json
.
load
(
f
)
section_method
=
json_data
[
'sections'
][
'section_run-0'
][
'sections'
][
'section_method-0'
]
pure_types_json
[
pure_types_str
]
=
section_method
[
controlIn_basis_set
]
...
...
@@ -90,14 +86,13 @@ class FhiAimsBaseNormalizer(Normalizer):
def
normalize
(
self
,
logger
=
None
)
->
None
:
super
().
normalize
(
logger
)
if
not
self
.
section_run
or
self
.
section_run
.
program_name
!=
'FHI-aims'
:
return
for
index
in
self
.
_backend
.
get_sections
(
'section_method'
):
try
:
to_compare
=
self
.
_backend
.
get_value
(
controlIn_basis_set
,
index
)
if
to_compare
is
None
:
# not fhi aims data
continue
except
KeyError
:
for
method
in
self
.
section_run
.
section_method
:
to_compare
=
getattr
(
method
,
controlIn_basis_set
,
None
)
if
to_compare
is
None
:
# not fhi aims data
continue
matrix_hits_int
=
dict
.
fromkeys
(
pure_types_json
,
0
)
...
...
@@ -112,9 +107,6 @@ class FhiAimsBaseNormalizer(Normalizer):
# matrix_hits[key]=matrix_hits[key]+CompareToDefaults(val[AtomIndex],to_compare[i])
context_uri
=
'/section_run/0/section_method/%d'
%
index
self
.
_backend
.
openContext
(
context_uri
)
closest_base_int
=
min
(
matrix_hits_int
,
key
=
matrix_hits_int
.
get
)
if
(
matrix_hits_basis
[
min
(
matrix_hits_basis
,
key
=
matrix_hits_basis
.
get
)]
==
0
):
closest_base_base
=
''
...
...
@@ -122,18 +114,11 @@ class FhiAimsBaseNormalizer(Normalizer):
closest_base_base
=
'+'
if
(
matrix_hits_int
[
closest_base_int
]
==
0
):
# print(closest_base_int +closest_base_base)
self
.
_backend
.
addValue
(
'basis_set'
,
closest_base_int
+
closest_base_base
)
method
.
basis_set
=
closest_base_int
+
closest_base_base
elif
(
matrix_hits_int
[
closest_base_int
]
<=
5
):
# print('~'+closest_base_int+closest_base_base)
self
.
_backend
.
addValue
(
'basis_set'
,
'~'
+
closest_base_int
+
closest_base_base
)
method
.
basis_set
=
'~'
+
closest_base_int
+
closest_base_base
elif
(
matrix_hits_int
[
closest_base_int
]
>
5
):
self
.
_backend
.
addValue
(
'basis_set'
,
'custom-'
+
closest_base_int
)
# print('custom-'+closest_base_int)
self
.
_backend
.
closeContext
(
context_uri
)
self
.
_backend
.
finishedParsingSession
(
"ParseSuccess"
,
None
)
method
.
basis_set
=
'custom-'
+
closest_base_int
# import setup_paths
...
...
nomad/normalizing/normalizer.py
View file @
828ed9db
...
...
@@ -33,7 +33,6 @@ class Normalizer(metaclass=ABCMeta):
''' The domain this normalizer should be used in. Default for all normalizer is 'DFT'. '''
def
__init__
(
self
,
backend
:
Backend
)
->
None
:
self
.
_backend
=
backend
self
.
entry_archive
=
backend
.
entry_archive
try
:
self
.
section_run
=
backend
.
entry_archive
.
section_run
[
0
]
...
...
@@ -74,13 +73,7 @@ class SystemBasedNormalizer(Normalizer, metaclass=ABCMeta):
]
def
_normalize_system
(
self
,
system
,
is_representative
):
context
=
'/section_run/0/section_system/%d'
%
system
.
m_parent_index
self
.
_backend
.
openContext
(
context
)
try
:
return
self
.
normalize_system
(
system
,
is_representative
)
finally
:
self
.
_backend
.
closeContext
(
context
)
return
self
.
normalize_system
(
system
,
is_representative
)
@
abstractmethod
def
normalize_system
(
self
,
system
:
MSection
,
is_representative
:
bool
)
->
bool
:
...
...
@@ -194,6 +187,6 @@ class SystemBasedNormalizer(Normalizer, metaclass=ABCMeta):
# All the rest if requested
if
not
self
.
only_representatives
:
for
isys
,
system
in
enumerate
(
self
.
_backend
.
entry_archive
.
section_run
[
0
]
.
section_system
):
for
isys
,
system
in
enumerate
(
self
.
section_run
.
section_system
):
if
isys
!=
repr_sys_idx
:
self
.
__normalize_system
(
system
,
False
,
logger
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment