diff --git a/nomad/parsing/file_parser/text_parser.py b/nomad/parsing/file_parser/text_parser.py index aa151d726523e7ec66c9bfc812ed845b68ec2faf..9124a3661262d31e3403eae97654e4fce679612b 100644 --- a/nomad/parsing/file_parser/text_parser.py +++ b/nomad/parsing/file_parser/text_parser.py @@ -605,7 +605,7 @@ class DataTextParser(TextParser): data = np.loadtxt(self.mainfile) else: if not self._mainfile_contents and self.mainfile_obj: - with self.mainfile_obj as mainfile_obj: + with self.open_mainfile_obj() as mainfile_obj: self._mainfile_contents = mainfile_obj.read() if self._mainfile_contents: buffer = self._mainfile_contents diff --git a/nomad/parsing/file_parser/vasp_parser.py b/nomad/parsing/file_parser/vasp_parser.py deleted file mode 100644 index adae8590087bdade00b55a0a8620b27a048afb4f..0000000000000000000000000000000000000000 --- a/nomad/parsing/file_parser/vasp_parser.py +++ /dev/null @@ -1,85 +0,0 @@ -import numpy as np - -import runschema -from nomad.parsing.file_parser.mapping_parser import MappingAnnotationModel, XMLParser - - -class Program(runschema.run.Program): - version = runschema.run.Program.version - version.m_annotations = dict( - xml=MappingAnnotationModel( - # path=[".i[?_name=='version']"], - operator=( - 'get_version', - [ - ".i[?_name=='version']", - ".i[?_name=='subversion']", - ".i[?_name=='platform']", - ], - ), - ) - ) - - # compilation_datetime = runschema.run.Program.compilation_datetime - # compilation_datetime.m_annotations = dict( - # xml=XMLAnnotation(operator=[('get_compilation_datetime', ["i[?_name=='']"])]) - # ) - - -class BandEnergies(runschema.calculation.BandEnergies): - n_spin_channels = runschema.calculation.BandEnergies.n_spin_channels - n_spin_channels.m_annotations = dict( - xml=MappingAnnotationModel(path='length(.array.set.set)') - ) - - n_kpoints = runschema.calculation.BandEnergies.n_kpoints - n_kpoints.m_annotations = dict( - xml=MappingAnnotationModel(path='length(.array.set.set[0].set)') - ) - - energies = runschema.calculation.BandEnergies.energies - energies.m_annotations = dict( - xml=MappingAnnotationModel( - operator=( - 'get_eigenvalues_energies', - [ - '.array.set.set[].set[].r', - 'length(.array.set.set)', - 'length(.array.set.set[0].set)', - ], - ), - ) - ) - - -class Calculation(runschema.calculation.Calculation): - eigenvalues = runschema.calculation.Calculation.eigenvalues - eigenvalues.m_annotations = dict(xml=MappingAnnotationModel(path='.eigenvalues')) - - -class Run(runschema.run.Run): - program = runschema.run.Run.program - program.m_annotations = dict(xml=MappingAnnotationModel(path='.generator')) - - calculation = runschema.run.Run.calculation - calculation.m_annotations = dict(xml=MappingAnnotationModel(path='.calculation')) - - -runschema.run.Run.m_def.m_annotations = dict( - xml=MappingAnnotationModel(path='modeling') -) - - -class VASPXMLParser(XMLParser): - @staticmethod - def get_eigenvalues_energies(value, n_spin, n_kpoints): - array = np.transpose(value)[0].T - return np.reshape(array, (n_spin, n_kpoints, len(array[0]))) - - @staticmethod - def get_version(version, sub_version, platform): - return ' '.join([' '.join(s.split()) for s in [version, sub_version, platform]]) - - @staticmethod - def slice(value): - return np.array(value)[2:]