From e8ecb2fc21f47dec75b6b366d19bfdad36229447 Mon Sep 17 00:00:00 2001 From: Julia Schumann <32182254+schumannj@users.noreply.github.com> Date: Tue, 28 May 2024 10:14:45 +0000 Subject: [PATCH] start nvrs schema --- .../schema_packages/mypackage.py | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/nomad_unisyscat/schema_packages/mypackage.py b/src/nomad_unisyscat/schema_packages/mypackage.py index 04995aa..5ad967e 100644 --- a/src/nomad_unisyscat/schema_packages/mypackage.py +++ b/src/nomad_unisyscat/schema_packages/mypackage.py @@ -2,6 +2,8 @@ TYPE_CHECKING, ) +import os + if TYPE_CHECKING: from nomad.datamodel.datamodel import ( EntryArchive, @@ -21,6 +23,58 @@ m_package = SchemaPackage() +class NVRSpectroscopy(Measurement, PlotSection, EntryData): + measurements_data_file = Quantity( + type=str, + description=""" + experimental tab data file + """, + a_eln=dict(component='FileEditQuantity'), + a_browser=dict(adaptor='RawFileAdaptor') + ) + + # simulation_data_file = Quantity( + # type=str, + # description=""" + # simulated tab data file + # """, + # a_eln=dict(component='FileEditQuantity'), + # a_browser=dict(adaptor='RawFileAdaptor') + # ) + + method = Quantity( + type=str, + description=""" + name of the method + """, + a_eln=dict(component='StringEditQuantity', + default= 'Nuclear resonance vibrational spectroscopy' + ) + ) + + def normalize(self, archive, logger): + super(NVRSpectroscopy, self).normalize(archive, logger) + if self.measurements_data_file is None: + return + + if (self.measurements_data_file is not None) and (os.path.splitext( + self.measurement_data_file)[-1] != ".dat"): + raise ValueError("Unsupported file format. Only .dat file") + + if self.measurement_data_file.endswith(".dat"): + with archive.m_context.raw_file(self.measurement_data_file) as f: + import pandas as pd + col_names=['wavenumber, cm-1','57Fe PVDOS'] + data = pd.read_csv(f.name, header=None, names=col_names) + + + self.figures = [] + fig = px.line(x=data['wavenumber, cm-1'], y=data['57Fe PVDOS']) + fig.update_xaxes(title_text=col_names[0]) + fig.update_yaxes(title_text=col_names[1]) + self.figures.append(PlotlyFigure( + label='NVPS', figure=fig.to_plotly_json())) + class MySchema(Schema): name = Quantity(