Skip to content

Commit

Permalink
Merge pull request #18 from FAIRmat-NFDI/customize_app
Browse files Browse the repository at this point in the history
add histogram to app with entry create time
  • Loading branch information
schumannj authored Jun 10, 2024
2 parents 83b4420 + bc647eb commit 004aae3
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 31 deletions.
94 changes: 93 additions & 1 deletion src/nomad_unisyscat/apps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,99 @@
'x': 6,
},
},
}
},
{
'type': 'histogram',
'showinput': 'true',
'autorange': 'true',
'nbins': 30,
'scale': 'linear',
'quantity': 'entry_create_time',
'layout': {
'xxl': {
'minH': 3,
'minW': 3,
'h': 6,
'w': 12,
'y': 5,
'x': 0,
},
'xl': {
'minH': 3,
'minW': 3,
'h': 5,
'w': 12,
'y': 5,
'x': 0,
},
'lg': {'minH': 3, 'minW': 3, 'h': 5, 'w': 12, 'y': 5, 'x': 0},
'md': {
'minH': 3,
'minW': 3,
'h': 5,
'w': 12,
'y': 8,
'x': 0,
},
'sm': {
'minH': 3,
'minW': 3,
'h': 5,
'w': 12,
'y': 8,
'x': 0,
},
},
},
# {
# 'type': 'scatterplot',
# 'autorange': 'true',
# 'size': 1000,
# 'scale': 'linear',
# 'y':
# 'quantity': 'data.results[0].frequency'
# '#nomad_unisyscat.schema_packages.mypackage.EPR',
# 'x':
# 'quantity': 'data.results[0].signal'
# '#nomad_unisyscat.schema_packages.mypackage.EPR',
# 'layout': {
# 'xxl': {
# 'minH': 3,
# 'minW': 3,
# 'h': 6,
# 'w': 12,
# 'y': 5,
# 'x': 12,
# },
# 'xl': {
# 'minH': 3,
# 'minW': 3,
# 'h': 5,
# 'w': 12,
# 'y': 5,
# 'x': 12,
# },
# 'lg': {
# 'minH': 3, 'minW': 3,
# 'h': 5, 'w': 12, 'y': 5, 'x': 12},
# 'md': {
# 'minH': 3,
# 'minW': 3,
# 'h': 6,
# 'w': 12,
# 'y': 10,
# 'x': 0,
# },
# 'sm': {
# 'minH': 3,
# 'minW': 3,
# 'h': 6,
# 'w': 12,
# 'y': 13,
# 'x': 0,
# },
# },
# }
],
}
),
Expand Down
65 changes: 35 additions & 30 deletions src/nomad_unisyscat/schema_packages/mypackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def normalize(self, archive, logger) -> None: # noqa: PLR0915

if self.dsc_file.endswith('_EPR_exp_raw.DSC'):
sample_name = self.dsc_file.split('_EPR')[0]
# self.method = 'experimental EPR spectroscopy'
self.method = 'experimental EPR spectroscopy'
if self.samples is None or self.samples == []:
sample = CompositeSystemReference()
sample.name = sample_name
Expand Down Expand Up @@ -363,7 +363,7 @@ class NRVSpectroscopy(Measurement, PlotSection, Schema):
description="""
name of the method
""",
default='NRVSpectroscopy',
default='Nuclear resonance vibrational spectroscopy (NRVS)',
a_eln=ELNAnnotation(
component='StringEditQuantity',
props=dict(
Expand Down Expand Up @@ -394,22 +394,16 @@ def normalize(self, archive, logger):

col_names = ['wavenumber, cm-1', '57Fe PVDOS']
data = pd.read_csv(f.name, header=None, names=col_names)
result = NRVSResult()
result.wavenumber = data['wavenumber, cm-1']
result.intensity = data['57Fe PVDOS']
results = []
results.append(result)
self.results = results

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='NRVS', figure=fig.to_plotly_json()))
result = NRVSResult()
result.wavenumber = data['wavenumber, cm-1']
result.intensity = data['57Fe PVDOS']
results = []
results.append(result)
self.results = results

if self.measurement_data_file.endswith('_NRVS_exp.dat'):
file_name = str(self.measurement_data_file)

sample_name = file_name.split('_NRVS')
if self.samples is None or self.samples == []:
sample = CompositeSystemReference()
Expand All @@ -423,19 +417,30 @@ def normalize(self, archive, logger):
samples = []
samples.append(sample)
self.samples = samples
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

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.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='NRVS', figure=fig.to_plotly_json()))


class IRResult(MeasurementResult):
Expand Down Expand Up @@ -482,9 +487,9 @@ class IRSpectroscopy(Measurement, PlotSection, Schema):
description="""
name of the method
""",
default='Infra-red (IR)',
a_eln=ELNAnnotation(
component='StringEditQuantity',
default='infra red vibrational spectroscopy',
props=dict(
suggestions=[
'experimental IR vibrational spectroscopy',
Expand Down Expand Up @@ -523,7 +528,7 @@ def normalize(self, archive, logger):

if self.data_file.endswith('_IR_exp.dat'):
sample_name = self.data_file.split('_IR')[0]
self.method = 'experimental IR vibrational spectroscopy'
self.method = 'experimental infra-red spectroscopy'
if self.samples is None or self.samples == []:
sample = CompositeSystemReference()
sample.name = sample_name
Expand Down

0 comments on commit 004aae3

Please sign in to comment.