Skip to content

Commit

Permalink
start nvrs schema
Browse files Browse the repository at this point in the history
  • Loading branch information
schumannj committed May 28, 2024
1 parent b90723c commit e8ecb2f
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/nomad_unisyscat/schema_packages/mypackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
TYPE_CHECKING,
)

import os

if TYPE_CHECKING:
from nomad.datamodel.datamodel import (
EntryArchive,
Expand All @@ -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(
Expand Down

0 comments on commit e8ecb2f

Please sign in to comment.