added parser DOS

parent e5b8e50d
import xml.sax
import logging
class DosHandler(xml.sax.handler.ContentHandler):
def __init__(self, backend):
self.backend = backend
self.dosSectionGIndex = -1
self.inDos = False
def endDocument(self):
def startElement(self, name, attrs):
if name == "dos":
self.dosSectionGIndex = self.backend.openSection("x_exciting_section_dos")
self.inDos = True
elif name == "point" and self.inDos:
# attrDict={}
# for name in attrs.getNames():
# attrDict[name] = attrs.getValue(name)
# logging.error("start element %s attr %s", name, attrDict)
def endElement(self, name):
if name == 'dos':
self.inDos = False
self.dosSectionGIndex = -1
# logging.error("end element %s", name)
def startElementNS(self, name, qname, attrs):
for name in attrs.getNames():
attrDict[name] = attrs.getValue(name)
logging.error("start element %s ns %s attr %s", name, qname, attrDict)
def endElementNS(self, name, qname):
logging.error("end element %s ns %s", name, qname)
def characters(self, content):
def parseDos(inF, backend):
handler = DosHandler(backend)
logging.error("will parse")
xml.sax.parse(inF, handler)
logging.error("did parse")
This diff is collapsed.
......@@ -4,7 +4,7 @@ import numpy as np
from nomadcore.simple_parser import mainFunction, AncillaryParser, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
import os, sys, json
import os, sys, json, elk_parser_dos
class ElkContext(object):
"""context for elk parser"""
......@@ -40,6 +40,16 @@ class ElkContext(object):
backend.addValue("x_elk_simulation_reciprocal_cell", recCell)
def onClose_section_single_configuration_calculation(self, backend, gIndex, section):
dirPath = os.path.dirname(
dosFile = os.path.join(dirPath, "TDOS.OUT")
if os.path.exists(dosFile):
with open(dosFile) as f:
elk_parser_dos.parseDos(f, backend)
def onClose_section_system(self, backend, gIndex, section):
backend.addArrayValues('configuration_periodic_dimensions', np.asarray([True, True, True]))
# description of the input
mainFileDescription = \
SM(name = "root matcher",
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