diff --git a/src/nomad_unisyscat/schema_packages/mypackage.py b/src/nomad_unisyscat/schema_packages/mypackage.py index b3f2ef0..b6e14ad 100644 --- a/src/nomad_unisyscat/schema_packages/mypackage.py +++ b/src/nomad_unisyscat/schema_packages/mypackage.py @@ -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 @@ -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'] @@ -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() @@ -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 = [] diff --git a/tests/data/nrvs_test.archive.yaml b/tests/data/nrvs_test.archive.yaml index 578af86..1a029dd 100644 --- a/tests/data/nrvs_test.archive.yaml +++ b/tests/data/nrvs_test.archive.yaml @@ -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