Commit 828ed9db authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Further removed backend from normalization.

parent 8ea11000
...@@ -46,7 +46,7 @@ from .encyclopedia.encyclopedia import EncyclopediaNormalizer ...@@ -46,7 +46,7 @@ from .encyclopedia.encyclopedia import EncyclopediaNormalizer
normalizers: Iterable[Type[Normalizer]] = [ normalizers: Iterable[Type[Normalizer]] = [
SystemNormalizer, SystemNormalizer,
OptimadeNormalizer, OptimadeNormalizer,
FhiAimsBaseNormalizer, # FhiAimsBaseNormalizer,
DosNormalizer, DosNormalizer,
BandStructureNormalizer, BandStructureNormalizer,
EncyclopediaNormalizer, EncyclopediaNormalizer,
......
...@@ -132,8 +132,6 @@ class DosNormalizer(Normalizer): ...@@ -132,8 +132,6 @@ class DosNormalizer(Normalizer):
idx += 1 idx += 1
# Add quantities to NOMAD's Metainfo # 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 dos.dos_values_normalized = dos_values_normalized
# Data for DOS fingerprint # Data for DOS fingerprint
...@@ -155,4 +153,3 @@ class DosNormalizer(Normalizer): ...@@ -155,4 +153,3 @@ class DosNormalizer(Normalizer):
sec_dos_fingerprint.stepsize = dos_fingerprint.stepsize sec_dos_fingerprint.stepsize = dos_fingerprint.stepsize
sec_dos_fingerprint.grid_id = dos_fingerprint.grid_id sec_dos_fingerprint.grid_id = dos_fingerprint.grid_id
sec_dos_fingerprint.filling_factor = dos_fingerprint.filling_factor sec_dos_fingerprint.filling_factor = dos_fingerprint.filling_factor
self._backend.closeContext(scc_url)
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import glob
import os.path import os.path
import json import json
import numpy as np import numpy as np
...@@ -25,12 +24,9 @@ controlIn_nucleus = 'x_fhi_aims_controlIn_nucleus' ...@@ -25,12 +24,9 @@ controlIn_nucleus = 'x_fhi_aims_controlIn_nucleus'
pure_types_json = dict() pure_types_json = dict()
files = glob.glob(os.path.join(__file__, "data/*.json")) for pure_types_str in ['light', 'really_tight', 'tight']:
for file in files: with open(os.path.join(os.path.dirname(__file__), 'data', pure_types_str + '.json')) as f:
pure_types_str = os.path.basename(os.path.split(file)[-1]) json_data = json.load(f)
with open(file) as data_file:
json_data = json.load(data_file)
section_method = json_data['sections']['section_run-0']['sections']['section_method-0'] section_method = json_data['sections']['section_run-0']['sections']['section_method-0']
pure_types_json[pure_types_str] = section_method[controlIn_basis_set] pure_types_json[pure_types_str] = section_method[controlIn_basis_set]
...@@ -90,15 +86,14 @@ class FhiAimsBaseNormalizer(Normalizer): ...@@ -90,15 +86,14 @@ class FhiAimsBaseNormalizer(Normalizer):
def normalize(self, logger=None) -> None: def normalize(self, logger=None) -> None:
super().normalize(logger) 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'): for method in self.section_run.section_method:
try: to_compare = getattr(method, controlIn_basis_set, None)
to_compare = self._backend.get_value(controlIn_basis_set, index)
if to_compare is None: if to_compare is None:
# not fhi aims data # not fhi aims data
continue continue
except KeyError:
continue
matrix_hits_int = dict.fromkeys(pure_types_json, 0) matrix_hits_int = dict.fromkeys(pure_types_json, 0)
matrix_hits_basis = dict.fromkeys(pure_types_json, 0) matrix_hits_basis = dict.fromkeys(pure_types_json, 0)
...@@ -112,9 +107,6 @@ class FhiAimsBaseNormalizer(Normalizer): ...@@ -112,9 +107,6 @@ class FhiAimsBaseNormalizer(Normalizer):
# matrix_hits[key]=matrix_hits[key]+CompareToDefaults(val[AtomIndex],to_compare[i]) # 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) 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): if (matrix_hits_basis[min(matrix_hits_basis, key=matrix_hits_basis.get)] == 0):
closest_base_base = '' closest_base_base = ''
...@@ -122,18 +114,11 @@ class FhiAimsBaseNormalizer(Normalizer): ...@@ -122,18 +114,11 @@ class FhiAimsBaseNormalizer(Normalizer):
closest_base_base = '+' closest_base_base = '+'
if (matrix_hits_int[closest_base_int] == 0): if (matrix_hits_int[closest_base_int] == 0):
# print(closest_base_int +closest_base_base) method.basis_set = closest_base_int + closest_base_base
self._backend.addValue('basis_set', closest_base_int + closest_base_base)
elif(matrix_hits_int[closest_base_int] <= 5): elif(matrix_hits_int[closest_base_int] <= 5):
# print('~'+closest_base_int+closest_base_base) method.basis_set = '~' + closest_base_int + closest_base_base
self._backend.addValue('basis_set', '~' + closest_base_int + closest_base_base)
elif(matrix_hits_int[closest_base_int] > 5): elif(matrix_hits_int[closest_base_int] > 5):
self._backend.addValue('basis_set', 'custom-' + closest_base_int) method.basis_set = 'custom-' + closest_base_int
# print('custom-'+closest_base_int)
self._backend.closeContext(context_uri)
self._backend.finishedParsingSession("ParseSuccess", None)
# import setup_paths # import setup_paths
......
...@@ -33,7 +33,6 @@ class Normalizer(metaclass=ABCMeta): ...@@ -33,7 +33,6 @@ class Normalizer(metaclass=ABCMeta):
''' The domain this normalizer should be used in. Default for all normalizer is 'DFT'. ''' ''' The domain this normalizer should be used in. Default for all normalizer is 'DFT'. '''
def __init__(self, backend: Backend) -> None: def __init__(self, backend: Backend) -> None:
self._backend = backend
self.entry_archive = backend.entry_archive self.entry_archive = backend.entry_archive
try: try:
self.section_run = backend.entry_archive.section_run[0] self.section_run = backend.entry_archive.section_run[0]
...@@ -74,13 +73,7 @@ class SystemBasedNormalizer(Normalizer, metaclass=ABCMeta): ...@@ -74,13 +73,7 @@ class SystemBasedNormalizer(Normalizer, metaclass=ABCMeta):
] ]
def _normalize_system(self, system, is_representative): 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) return self.normalize_system(system, is_representative)
finally:
self._backend.closeContext(context)
@abstractmethod @abstractmethod
def normalize_system(self, system: MSection, is_representative: bool) -> bool: def normalize_system(self, system: MSection, is_representative: bool) -> bool:
...@@ -194,6 +187,6 @@ class SystemBasedNormalizer(Normalizer, metaclass=ABCMeta): ...@@ -194,6 +187,6 @@ class SystemBasedNormalizer(Normalizer, metaclass=ABCMeta):
# All the rest if requested # All the rest if requested
if not self.only_representatives: 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: if isys != repr_sys_idx:
self.__normalize_system(system, False, logger) self.__normalize_system(system, False, logger)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment