Commit 0b7f4fd5 authored by Daria M. Tomecka's avatar Daria M. Tomecka

cleaning up the code (classify4me_prototypes.py)

parent 4b12e0c8
......@@ -13,7 +13,7 @@ __author__ = "Daria M. Tomecka and Fawzi Mohamed"
__copyright__ = "Copyright 2017, The NOMAD Project"
__maintainer__ = "Daria M. Tomecka"
__email__ = "tomeckadm@gmail.com;"
__date__ = "18/05/17"
__date__ = "12/07/17"
import sys
import ase.io
......@@ -28,13 +28,8 @@ import functools
import fractions
import setup_paths
#from nomad_sim.wrappers import get_json_list
#from nomad_sim.wrappers import plot, logger
#from nomad_sim.utils_crystals import get_spacegroup
#from nomad_sim.utils_crystals import create_supercell
#from nomad_sim.wrappers import get_json_list
#from nomad_sim.nomad_structures import NOMADStructure
###
### new updated location for the prototypes
from nomadcore.structure_types import \
structure_types_by_spacegroup as str_types_by_spg
from nomadcore.parse_streamed_dicts import ParseStreamedDicts
......@@ -43,24 +38,20 @@ from nomadcore.parser_backend import JsonParseEventsWriterBackend
#prototypes_file = os.path.normpath("/nomad-lab-base/analysis-tools/structural-similarity/python-modules/nomad_sim/structure_types.py")
#Classification of json calculartion using encyclopedia preprocessor
import sys
#print(sys.path)
sys.path.append('/home/beaker/py3k/lib/python3.5/')
import spglib
#import Nomad
import logging
#from Nomad.Preprocessing.System import structure, preprocessormaterial3d
#from Nomad import ProcessingEngine
#LOGGER = logging.getLogger(__name__)
#logging.basicConfig(level=logging.ERROR)
#json_list = beaker.json_list
atomSpecies = None
#atomSpecies = atom_species
cell = None
def get_normalized_wyckoff(atomic_number, wyckoff):
......@@ -145,17 +136,9 @@ def get_structure_type(space_group, norm_wyckoff):
"""Returns the information on the prototype.
"""
structure_type_info = {}
#wyckoff_letters_compact = "".join(sorted(set(wyckoff_letters)))
#print("Wyckoff1", norm_wyckoff)#_compact)
#print("Space Gr", space_group)
for type_description in str_types_by_spg.get((space_group), []):
#current_bravais_lattice = type_description['Pearsons Symbol'][0:2]
#current_wyckoffs = type_description['Wyckoff Positions']
#if current_bravais_lattice == bravais_lattice \
# and current_wyckoffs == wyckoff_letters_compact: current_norm_wyckoffs = type_description.get('normalized_wyckoff')
current_norm_wyckoffs = type_description.get("normalized_wyckoff_spg")
if current_norm_wyckoffs and current_norm_wyckoffs == norm_wyckoff:
structure_type_info = type_description
......@@ -167,14 +150,13 @@ def get_structure_type(space_group, norm_wyckoff):
#from preprocessor
def _structure_type_info(self):
"""Known structure types"""
return get_structure_type(
self.space_group,
self.normalized_wyckoff)
def toAtomNr(string):
"returns the atom number of the given symbol"
baseStr = string[:3].title()
......@@ -188,6 +170,7 @@ def toAtomNr(string):
return 0
def dictToNarray(dictValue):
"""function that gets the dictionary with flat data ans shape and give the array"""
v=dictValue['flatData']
return np.reshape(np.asarray(v), dictValue['shape'])
......@@ -217,21 +200,11 @@ def systemToSpg(cell, atomSpecies, atomPos):
symm = spglib.get_symmetry_dataset((acell, np.dot(atomPos,cellInv), atomSpecies),
0.002, -1) # use m instead of Angstrom?
#symm = spglib.get_symmetry_dataset(filename)
# sym = spglib.get_symmetry_dataset((number,wyckoff, pearsons_symbol)
return symm
def classify_by_norm_wyckoff(sectionSystem):
try:
#try:
# simulation_cell = json_file_name.get('lattice_vectors')
# labels = json_file_name.get('atom_labels')
# atom_pos = json_file_name.get('atom_positions')
# if not simulation_cell or not labels or not atom_pos:
# raise Exception("Parsed invalid geometry for space group %d, %s" % (spaceGroupNr, protoDict))
# proc = ProcessingEngine(mode="debug")
#results = proc.process(json_file_name)
###
#atomic_number = atom_species
#as in the normalized version
......@@ -252,17 +225,8 @@ def classify_by_norm_wyckoff(sectionSystem):
symm = systemToSpg(cell, atomSpecies, atomPos)
wyckoffs = symm.get("wyckoffs")
spg_nr = symm.get("number")
#norm_wyckoff = get_normalized_wyckoff
# preprocessor = list(results.values())
# if len(preprocessor) == 1:
# preprocessor = preprocessor[0]
# spg_nr = preprocessor["space_group"]
# norm_wyckoff = preprocessor["normalized_wyckoff"]
###
# pearson - symm.get("xxx")
#space_group = symmetry_dataset["number"]
### adds recalculated wyckoff positions
updatePrototypesWyckoff(str_types_by_spg)
###
......
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