Skip to content

Commit

Permalink
unify datafile name (#25)
Browse files Browse the repository at this point in the history
* unify datafile name

* removed one more measurment_data_file
  • Loading branch information
schumannj authored Jun 18, 2024
1 parent 8986614 commit dce1508
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 25 deletions.
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

0 comments on commit dce1508

Please sign in to comment.