Commit f5be159e authored by Daniel Speckhard's avatar Daniel Speckhard
Browse files

Made two parsers for diff gpaw files.

parent cbd073af
from gpawparser.parser import GpawParserWrapper
from gpawparser.parser import GPAWParserWrapper
from gpawparser.parser2 import GPAWParser2Wrapper
......@@ -41,13 +41,6 @@ def c(value, unit=None):
parser_info = {"name": "parser_gpaw", "version": "1.0"}
path = '../../../../nomad-meta-info/meta_info/nomad_meta_info/' +\
'gpaw.nomadmetainfo.json'
# metaInfoPath = os.path.normpath(
# os.path.join(os.path.dirname(os.path.abspath(__file__)), path))
# metaInfoEnv, warns = loadJsonFile(filePath=metaInfoPath,
# dependencyLoader=None,
# extraArgsHandling=InfoKindEl.ADD_EXTRA_ARGS,
# uri=None)
import nomad_meta_info
metaInfoPath = os.path.normpath(
......@@ -57,14 +50,14 @@ metaInfoEnv, warnings = loadJsonFile(
filePath = metaInfoPath, dependencyLoader = None,
extraArgsHandling = InfoKindEl.ADD_EXTRA_ARGS, uri = None)
class GpawParserWrapper():
class GPAWParserWrapper():
""" A proper class envolop for running this parser using Noamd-FAIRD infra. """
def __init__(self, backend, **kwargs):
self.backend_factory = backend
def parse(self, mainfile):
from unittest.mock import patch
logging.info('lib-atoms parser started')
logging.info('GPAW parser started')
logging.getLogger('nomadcore').setLevel(logging.WARNING)
backend = self.backend_factory(metaInfoEnv)
backend = parse_without_class(mainfile, backend)
......
......@@ -16,6 +16,7 @@ from __future__ import division
import os
from contextlib import contextmanager
import numpy as np
import logging
from ase import units
from ase.data import chemical_symbols
from ase.io.ulm import ulmopen
......@@ -23,12 +24,11 @@ from ase.utils import basestring
#from ase.io.trajectory import read_atoms
from ase.data import atomic_masses
from ase.units import Rydberg
import setup_paths
from nomadcore.unit_conversion.unit_conversion import convert_unit as cu
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
from nomadcore.parser_backend import JsonParseEventsWriterBackend
from libxc_names import get_libxc_name
from default_parameters import parameters as parms
from gpawparser.libxc_names import get_libxc_name
from gpawparser.default_parameters import parameters as parms
@contextmanager
......@@ -46,13 +46,7 @@ def c(value, unit=None):
parser_info = {"name": "parser2_gpaw", "version": "1.0"}
path = '../../../../nomad-meta-info/meta_info/nomad_meta_info/' +\
'gpaw.nomadmetainfo.json'
# metaInfoPath = os.path.normpath(
# os.path.join(os.path.dirname(os.path.abspath(__file__)), path))
# metaInfoEnv, warns = loadJsonFile(filePath=metaInfoPath,
# dependencyLoader=None,
# extraArgsHandling=InfoKindEl.ADD_EXTRA_ARGS,
# uri=None)
import nomad_meta_info
metaInfoPath = os.path.normpath(
os.path.join(os.path.dirname(os.path.abspath(nomad_meta_info.__file__)),
......@@ -61,8 +55,23 @@ metaInfoEnv, warnings = loadJsonFile(
filePath = metaInfoPath, dependencyLoader = None,
extraArgsHandling = InfoKindEl.ADD_EXTRA_ARGS, uri = None)
def parse(filename):
p = JsonParseEventsWriterBackend(metaInfoEnv)
class GPAWParser2Wrapper():
""" A proper class envolop for running this parser using Noamd-FAIRD infra. """
def __init__(self, backend, **kwargs):
self.backend_factory = backend
def parse(self, mainfile):
from unittest.mock import patch
logging.info('GPAW parser 2 (note the 2) started')
logging.getLogger('nomadcore').setLevel(logging.WARNING)
backend = self.backend_factory(metaInfoEnv)
backend = parse_without_class(mainfile, backend)
return backend
def parse_without_class(filename, backend):
p = backend
# p = JsonParseEventsWriterBackend(metaInfoEnv)
o = open_section
r = ulmopen(filename) # Reader(filename)
p.startedParsingSession(filename, parser_info)
......@@ -225,6 +234,7 @@ def parse(filename):
p.finishedParsingSession("ParseSuccess", None)
return p
if __name__ == '__main__':
import sys
......
Markdown is supported
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