Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
parser-elk
Commits
97277a1d
Commit
97277a1d
authored
Aug 04, 2016
by
Pardini, Lorenzo (lopa)
Browse files
added parser DOS
parent
e5b8e50d
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
parser/parser-elk/elk_parser_dos.py
0 → 100644
View file @
97277a1d
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"
)
parser/parser-elk/out
0 → 100644
View file @
97277a1d
This diff is collapsed.
Click to expand it.
parser/parser-elk/parser_elk.py
View file @
97277a1d
...
...
@@ -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"
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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