Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
schumannj committed May 28, 2024
1 parent e8ecb2f commit 17a9f4f
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/nomad_unisyscat/schema_packages/mypackage.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import os
from typing import (
TYPE_CHECKING,
)

import os

if TYPE_CHECKING:
from nomad.datamodel.datamodel import (
EntryArchive,
Expand All @@ -23,14 +22,15 @@

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')
a_browser=dict(adaptor='RawFileAdaptor'),
)

# simulation_data_file = Quantity(
Expand All @@ -47,33 +47,34 @@ class NVRSpectroscopy(Measurement, PlotSection, EntryData):
description="""
name of the method
""",
a_eln=dict(component='StringEditQuantity',
default= 'Nuclear resonance vibrational spectroscopy'
)
a_eln=dict(
component='StringEditQuantity',
default='Nuclear resonance vibrational spectroscopy',
),
)

def normalize(self, archive, logger):
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.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"):
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)

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()))
self.figures.append(PlotlyFigure(label='NVPS', figure=fig.to_plotly_json()))


class MySchema(Schema):
Expand Down

0 comments on commit 17a9f4f

Please sign in to comment.