Skip to content

Commit

Permalink
update parser
Browse files Browse the repository at this point in the history
  • Loading branch information
budschi committed Jul 15, 2024
1 parent 2eba99a commit bd66816
Show file tree
Hide file tree
Showing 4 changed files with 383 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/nomad_ikz_raman/parsers/ramanparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,42 @@ class RawFileRamanData(EntryData):


class RamanParser(MatchingParser):
def parse(
def parse(
self,
mainfile: str,
archive: 'EntryArchive',
logger: 'BoundLogger',
child_archives: dict[str, 'EntryArchive'] = None,
) -> None:
logger.info('RamanParser.parse', parameter=configuration.parameter)
# archive.results = Results(material=Material(elements=['H', 'O']))

data_file = mainfile.split('/')[-1]
entry = Ramanspectroscopy.m_from_dict(Ramanspectroscopy.m_def) # .a_template)
entry = Ramanspectroscopy() #.m_from_dict(Ramanspectroscopy.m_def.a_template)
entry.data_file = data_file
entry.name = "".join(data_file.split(".")[:-1])
file_name = f'{"".join(data_file.split(".")[:-1])}.archive.json'
archive.data = RawFileRamanData(
measurement=create_archive(entry, archive, file_name)
)
archive.metadata.entry_name = f'{data_file} data file'
# def parse(
# self,
# mainfile: str,
# archive: 'EntryArchive',
# logger: 'BoundLogger',
# child_archives: dict[str, 'EntryArchive'] = None,
# ) -> None:
# logger.info('RamanParser.parse', parameter=configuration.parameter)
# data_file = mainfile.split('/')[-1]
# # entry = Ramanspectroscopy.m_from_dict(
# # Ramanspectroscopy.m_def.a_template
# # ) # .a_template)
# entry = Ramanspectroscopy()
# entry.data_file = data_file
# file_name = f'{"".join(data_file.split(".")[:-1])}.archive.json'
# archive.data = RawFileRamanData(
# measurement=create_archive(entry, archive, file_name)
# )
# archive.metadata.entry_name = f'{data_file} data file'


# if self.data_file is not None:
Expand Down
1 change: 1 addition & 0 deletions src/nomad_ikz_raman/schema_packages/raman.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
raman_dict = read_function(file.name)
# raman_dict = read_function(file.name) # , logger)
# write_function(raman_dict, archive, logger)
self.name = file.name.split('/')[-1].split('.xml')[0]
self.title = raman_dict.get(
'Title',
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def parse_raman_xml(file_path):
get_text(root.find(".//LSX[@ID='0x6D746164']/LSX[@ID='0x7D6C61DB']")),
date_format,
),
#'Sample':
'AcquisitionDate': # datetime.strptime(
get_text(root.find(".//LSX[@ID='0x7CECDBD7']/LSX/LSX[@ID='0x7D6C61DB']")),
# date_format,
Expand Down
Loading

0 comments on commit bd66816

Please sign in to comment.