Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unify datafile name #25

Merged
merged 3 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 23 additions & 24 deletions src/nomad_unisyscat/schema_packages/mypackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ class NRVSResult(MeasurementResult):


class NRVSpectroscopy(Measurement, PlotSection, Schema):
measurement_data_file = Quantity(
data_file = Quantity(
type=str,
description="""
experimental tab data file
Expand Down Expand Up @@ -443,16 +443,16 @@ class NRVSpectroscopy(Measurement, PlotSection, Schema):

def normalize(self, archive, logger):
super().normalize(archive, logger)
if self.measurement_data_file is None:
if self.data_file is None:
return

if (self.measurement_data_file is not None) and (
os.path.splitext(self.measurement_data_file)[-1] != '.dat'
if (self.data_file is not None) and (
os.path.splitext(self.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:
if self.data_file.endswith('.dat'):
with archive.m_context.raw_file(self.data_file) as f:
import pandas as pd

col_names = ['wavenumber, cm-1', '57Fe PVDOS']
Expand All @@ -465,8 +465,8 @@ def normalize(self, archive, logger):
results.append(result)
self.results = results

file_name = str(self.measurement_data_file)

if self.data_file.endswith('_NRVS_exp.dat'):
file_name = str(self.data_file)
sample_name = file_name.split('_NRVS')
if self.samples is None or self.samples == []:
sample = CompositeSystemReference()
Expand All @@ -481,22 +481,21 @@ def normalize(self, archive, logger):
samples.append(sample)
self.samples = samples

if self.measurement_data_file.endswith('_NRVS_exp.dat'):
self.method = 'experimental nuclear resonance vibrational spectroscopy'
if self.instruments is None or self.instruments == []:
instrument = InstrumentReference()
instrument.name = 'NRVS setup'
instrument.lab_id = 'NRVS-setup'
from nomad.datamodel.context import ClientContext
if isinstance(archive.m_context, ClientContext):
pass
else:
instrument.normalize(archive, logger)
instruments = []
instruments.append(instrument)
self.instruments = instruments
elif self.measurement_data_file.endswith('_NRVS_sim.dat'):
self.method = 'simulated nuclear resonance vibrational spectroscopy'
self.method = 'experimental nuclear resonance vibrational spectroscopy'
if self.instruments is None or self.instruments == []:
instrument = InstrumentReference()
instrument.name = 'NRVS setup'
instrument.lab_id = 'NRVS-setup'
from nomad.datamodel.context import ClientContext
if isinstance(archive.m_context, ClientContext):
pass
else:
instrument.normalize(archive, logger)
instruments = []
instruments.append(instrument)
self.instruments = instruments
elif self.data_file.endswith('_NRVS_sim.dat'):
self.method = 'simulated nuclear resonance vibrational spectroscopy'

self.figures = []

Expand Down
2 changes: 1 addition & 1 deletion tests/data/nrvs_test.archive.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
data:
m_def: nomad_unisyscat.schema_packages.mypackage.NRVSpectroscopy
measurement_data_file: ReRH_Nia-C_H_NRVS_exp.dat
data_file: ReRH_Nia-C_H_NRVS_exp.dat