Commit bd6e8e14 authored by Daria M. Tomecka's avatar Daria M. Tomecka
Browse files

fixing prototype normalizer

parent 2c5db931
...@@ -30,8 +30,7 @@ import fractions ...@@ -30,8 +30,7 @@ import fractions
import setup_paths import setup_paths
### new updated location for the prototypes ### new updated location for the prototypes
from nomadcore.structure_types import \ from nomadcore.structure_types import structure_types_by_spacegroup as str_types_by_spg
structure_types_by_spacegroup as str_types_by_spg
from nomadcore.parse_streamed_dicts import ParseStreamedDicts from nomadcore.parse_streamed_dicts import ParseStreamedDicts
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
from nomadcore.parser_backend import JsonParseEventsWriterBackend from nomadcore.parser_backend import JsonParseEventsWriterBackend
...@@ -210,18 +209,25 @@ def classify_by_norm_wyckoff(sectionSystem): ...@@ -210,18 +209,25 @@ def classify_by_norm_wyckoff(sectionSystem):
#as in the normalized version #as in the normalized version
cell = None cell = None
conf = sectionSystem conf = sectionSystem
lab = conf.get("atom_labels", None) lab = conf.get("atom_labels", None)
if lab is None : return None
##periodicDirs = conf.get("configuration_periodic_dimensions", periodicDirs) ##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) #print (atomSpecies)
newCell = conf.get("simulation_cell") newCell = conf.get("simulation_cell")
if newCell is None : return None
if newCell: if newCell:
cell = dictToNarray(newCell) cell = dictToNarray(newCell)
symm = None symm = None
#print("***full:",cell) #print("***full:",cell)
#acell = cell.reshape(3,3) #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) symm = systemToSpg(cell, atomSpecies, atomPos)
wyckoffs = symm.get("wyckoffs") wyckoffs = symm.get("wyckoffs")
spg_nr = symm.get("number") spg_nr = symm.get("number")
...@@ -262,16 +268,33 @@ def main(): ...@@ -262,16 +268,33 @@ def main():
extraArgsHandling=InfoKindEl.ADD_EXTRA_ARGS, extraArgsHandling=InfoKindEl.ADD_EXTRA_ARGS,
uri=None) uri=None)
backend = JsonParseEventsWriterBackend(metaInfoEnv) backend = JsonParseEventsWriterBackend(metaInfoEnv)
#Start
calcContext=sys.argv[1]
backend.startedParsingSession(
calcContext,
parserInfo = {'name':'PrototypesNormalizer', 'version': '1.0'})
dictReader = ParseStreamedDicts(sys.stdin) dictReader = ParseStreamedDicts(sys.stdin)
while True: while True:
sectSys = dictReader.readNextDict() sectSys = dictReader.readNextDict()
if sectSys is None: try:
break if sectSys is None:
label = classify_by_norm_wyckoff(sectSys) break
if label: label = classify_by_norm_wyckoff(sectSys)
backend.openContext(sectSys['uri']) if label:
backend.addValue("prototype_label", label) backend.openContext(sectSys['uri'])
backend.closeContext(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__': if __name__ == '__main__':
main() main()
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
"name": "section_system", "name": "section_system",
"gIndex": 0, "gIndex": 0,
"uri": "nmd://NcC8TDWGWCtQLhWeB2a1N8y9Q7y4r/CCDeb8diABbP4BgHPwHeKgmdzadEM/section_run/0c/section_system/0c", "uri": "nmd://NcC8TDWGWCtQLhWeB2a1N8y9Q7y4r/CCDeb8diABbP4BgHPwHeKgmdzadEM/section_run/0c/section_system/0c",
"atom_labels": [{"flatData":["Sn","Sn"],"shape":[2]},{"flatData":["Sn","Sn"],"shape":[2]}], "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]},{"flatData":[0.0,0.0,0.0,1.6415278E-10,-9.477365356213973E-11,2.724677455E-10],"shape":[2,3]}], "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]}], "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]} "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( ...@@ -19,7 +19,7 @@ object PrototypesNormalizer extends ExternalNormalizerGenerator(
name = "PrototypesNormalizer", name = "PrototypesNormalizer",
info = jn.JObject( info = jn.JObject(
("name" -> jn.JString("PrototypesNormalizer")) :: ("name" -> jn.JString("PrototypesNormalizer")) ::
("normalizerId" -> jn.JString("PrototypesNormalizer" + lab.PrototypesVersionInfo.version)) :: ("parserId" -> jn.JString("PrototypesNormalizer" + lab.PrototypesVersionInfo.version)) ::
("versionInfo" -> jn.JObject( ("versionInfo" -> jn.JObject(
("nomadCoreVersion" -> jn.JObject(lab.NomadCoreVersionInfo.toMap.map { ("nomadCoreVersion" -> jn.JObject(lab.NomadCoreVersionInfo.toMap.map {
case (k, v) => k -> jn.JString(v.toString) case (k, v) => k -> jn.JString(v.toString)
...@@ -49,14 +49,14 @@ object PrototypesNormalizer extends ExternalNormalizerGenerator( ...@@ -49,14 +49,14 @@ object PrototypesNormalizer extends ExternalNormalizerGenerator(
) ++ DefaultPythonInterpreter.commonDirMapping(), ) ++ DefaultPythonInterpreter.commonDirMapping(),
metaInfoEnv = lab.meta.KnownMetaInfoEnvs.all 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 = { override def stdInHandler(context: ResolvedRef)(wrapper: ExternalParserWrapper)(pIn: java.io.OutputStream): Unit = {
val out: java.io.Writer = if (trace) val out: java.io.Writer = new java.io.BufferedWriter(new java.io.OutputStreamWriter(pIn));
new java.io.BufferedWriter(new java.io.OutputStreamWriter(pIn)); val stringBuilder = if (trace)
new StringBuilder
else else
null null
val stringBuilder = new StringBuilder
def writeOut(s: String): Unit = { def writeOut(s: String): Unit = {
out.write(s) out.write(s)
if (trace) stringBuilder ++= s if (trace) stringBuilder ++= s
......
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