Commit 97277a1d authored by Pardini, Lorenzo (lopa)'s avatar Pardini, Lorenzo (lopa)
Browse files

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):
pass
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:
self.backend.addValue("x_exciting_dos_value",float(attrs.getValue('dos')))
self.backend.addValue("x_exciting_dos_energy",float(attrs.getValue('e')))
# 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.backend.closeSection("x_exciting_section_dos",self.dosSectionGIndex)
self.dosSectionGIndex = -1
# logging.error("end element %s", name)
def startElementNS(self, name, qname, attrs):
attrDict={}
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):
pass
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):
[recLatticeX[2],recLatticeY[2],recLatticeZ[2]]]
backend.addValue("x_elk_simulation_reciprocal_cell", recCell)
def onClose_section_single_configuration_calculation(self, backend, gIndex, section):
dirPath = os.path.dirname(self.parser.fIn.name)
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