Skip to content
Snippets Groups Projects
Commit bd6e8e14 authored by Daria M. Tomecka's avatar Daria M. Tomecka
Browse files

fixing prototype normalizer

parent 2c5db931
Branches
Tags
No related merge requests found
......@@ -30,8 +30,7 @@ import fractions
import setup_paths
### new updated location for the prototypes
from nomadcore.structure_types import \
structure_types_by_spacegroup as str_types_by_spg
from nomadcore.structure_types import structure_types_by_spacegroup as str_types_by_spg
from nomadcore.parse_streamed_dicts import ParseStreamedDicts
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
from nomadcore.parser_backend import JsonParseEventsWriterBackend
......@@ -210,17 +209,24 @@ def classify_by_norm_wyckoff(sectionSystem):
#as in the normalized version
cell = None
conf = sectionSystem
lab = conf.get("atom_labels", None)
if lab is None : return None
##periodicDirs = conf.get("configuration_periodic_dimensions", periodicDirs)
atomSpecies = [toAtomNr(l) for l in lab[0]['flatData']]
atomSpecies = [toAtomNr(l) for l in lab['flatData']]
#print (atomSpecies)
newCell = conf.get("simulation_cell")
if newCell is None : return None
if newCell:
cell = dictToNarray(newCell)
symm = None
#print("***full:",cell)
#acell = cell.reshape(3,3)
atomPos = dictToNarray(conf.get("atom_positions")[0])
atomPos = dictToNarray(conf.get("atom_positions"))
if atomPos is None : return None
symm = systemToSpg(cell, atomSpecies, atomPos)
wyckoffs = symm.get("wyckoffs")
......@@ -262,9 +268,18 @@ def main():
extraArgsHandling=InfoKindEl.ADD_EXTRA_ARGS,
uri=None)
backend = JsonParseEventsWriterBackend(metaInfoEnv)
#Start
calcContext=sys.argv[1]
backend.startedParsingSession(
calcContext,
parserInfo = {'name':'PrototypesNormalizer', 'version': '1.0'})
dictReader = ParseStreamedDicts(sys.stdin)
while True:
sectSys = dictReader.readNextDict()
try:
if sectSys is None:
break
label = classify_by_norm_wyckoff(sectSys)
......@@ -272,6 +287,14 @@ def main():
backend.openContext(sectSys['uri'])
backend.addValue("prototype_label", label)
backend.closeContext(sectSys['uri'])
sys.stdout.flush()
except:
logging.exception("exception trying to calculate prototype for %s",sectSys)
backend.finishedParsingSession("ParseSuccess", None)
sys.stdout.flush()
if __name__ == '__main__':
main()
......
......@@ -3,8 +3,8 @@
"name": "section_system",
"gIndex": 0,
"uri": "nmd://NcC8TDWGWCtQLhWeB2a1N8y9Q7y4r/CCDeb8diABbP4BgHPwHeKgmdzadEM/section_run/0c/section_system/0c",
"atom_labels": [{"flatData":["Sn","Sn"],"shape":[2]},{"flatData":["Sn","Sn"],"shape":[2]}],
"atom_positions": [{"flatData":[0.0,0.0,0.0,1.6415278E-10,-9.477365356213973E-11,2.724677455E-10],"shape":[2,3]},{"flatData":[0.0,0.0,0.0,1.6415278E-10,-9.477365356213973E-11,2.724677455E-10],"shape":[2,3]}],
"configuration_periodic_dimensions": [{"flatData":[true,true,true],"shape":[3]}],
"atom_labels": {"flatData":["Sn","Sn"],"shape":[2]},
"atom_positions": {"flatData":[0.0,0.0,0.0,1.6415278E-10,-9.477365356213973E-11,2.724677455E-10],"shape":[2,3]},
"configuration_periodic_dimensions": {"flatData":[true,true,true],"shape":[3]},
"simulation_cell": {"flatData":[1.6415278E-10,-2.84320955E-10,0.0,1.6415278E-10,2.84320955E-10,0.0,0.0,0.0,5.44935491E-10],"shape":[3,3]}
}
\ No newline at end of file
[{
"type": "nomad_section_2_0",
"name": "section_system",
"gIndex": 0,
"uri": "nmd://NcC8TDWGWCtQLhWeB2a1N8y9Q7y4r/C-EE2qc_XLeNhj4VC1vjZGV-JXVtx/section_run/0c/section_system/0c",
"atom_labels": {"flatData":["Cr"],"shape":[1]},
"atom_positions": {"flatData":[0.0,0.0,0.0],"shape":[1,3]},
"configuration_periodic_dimensions": [{"flatData":[true,true,true],"shape":[3]}],
"simulation_cell": {"flatData":[-1.3940056000000002E-10,1.3940056000000002E-10,1.3940056000000002E-10,1.3940056000000002E-10,-1.3940056000000002E-10,1.3940056000000002E-10,1.3940056000000002E-10,1.3940056000000002E-10,-1.3940056000000002E-10],"shape":[3,3]}
}
,{
"type": "nomad_section_2_0",
"name": "section_system",
"gIndex": 2,
"uri": "nmd://NcC8TDWGWCtQLhWeB2a1N8y9Q7y4r/C-EE2qc_XLeNhj4VC1vjZGV-JXVtx/section_run/0c/section_system/2c",
"atom_labels": {"flatData":["Cr"],"shape":[1]},
"atom_positions": {"flatData":[0.0,0.0,0.0],"shape":[1,3]},
"configuration_periodic_dimensions": [{"flatData":[true,true,true],"shape":[3]}],
"simulation_cell": {"flatData":[-1.3940056000000002E-10,1.3940056000000002E-10,1.3940056000000002E-10,1.3940056000000002E-10,-1.3940056000000002E-10,1.3940056000000002E-10,1.3940056000000002E-10,1.3940056000000002E-10,-1.3940056000000002E-10],"shape":[3,3]}
}
]
\ No newline at end of file
[{
"type": "nomad_section_2_0",
"name": "section_system",
"gIndex": 0,
"uri": "nmd://N0jqPXU7FP2SaaH8sMvXrW0DZsK0Z/CGivpJxhUx8d3FzFw7jHDjE51ZlOK/section_run/0c/section_system/0c",
"atom_labels": {"flatData":["Au","Au","Au","O","O","H"],"shape":[6]},
"atom_positions": {"flatData":[4.903707E-10,5.365501E-10,5.622263000000001E-10,7.491290000000001E-10,5.132975E-10,5.667301E-10,9.918509000000001E-10,5.750429E-10,5.194042E-10,1.1977479E-9,5.786581000000001E-10,5.245453000000001E-10,1.2591336E-9,5.101932E-10,4.114972E-10,1.2846226E-9,4.2635300000000006E-10,4.542142E-10],"shape":[6,3]}
}
]
......@@ -19,7 +19,7 @@ object PrototypesNormalizer extends ExternalNormalizerGenerator(
name = "PrototypesNormalizer",
info = jn.JObject(
("name" -> jn.JString("PrototypesNormalizer")) ::
("normalizerId" -> jn.JString("PrototypesNormalizer" + lab.PrototypesVersionInfo.version)) ::
("parserId" -> jn.JString("PrototypesNormalizer" + lab.PrototypesVersionInfo.version)) ::
("versionInfo" -> jn.JObject(
("nomadCoreVersion" -> jn.JObject(lab.NomadCoreVersionInfo.toMap.map {
case (k, v) => k -> jn.JString(v.toString)
......@@ -49,14 +49,14 @@ object PrototypesNormalizer extends ExternalNormalizerGenerator(
) ++ DefaultPythonInterpreter.commonDirMapping(),
metaInfoEnv = lab.meta.KnownMetaInfoEnvs.all
) {
val trace: Boolean = true
val trace: Boolean = false
override def stdInHandler(context: ResolvedRef)(wrapper: ExternalParserWrapper)(pIn: java.io.OutputStream): Unit = {
val out: java.io.Writer = if (trace)
new java.io.BufferedWriter(new java.io.OutputStreamWriter(pIn));
val out: java.io.Writer = new java.io.BufferedWriter(new java.io.OutputStreamWriter(pIn));
val stringBuilder = if (trace)
new StringBuilder
else
null
val stringBuilder = new StringBuilder
def writeOut(s: String): Unit = {
out.write(s)
if (trace) stringBuilder ++= s
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment