Skip to content

Commit

Permalink
normalize function
Browse files Browse the repository at this point in the history
  • Loading branch information
PauloGitHB committed Sep 20, 2024
1 parent b7f9d14 commit faf97e7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/nomad_plugin_sintering/schema_packages/sintering.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
super().normalize(archive, logger)


from nomad.units import ureg
import pandas as pd


class Sintering(Process, EntryData, ArchiveSection):
'''
Class autogenerated from yaml schema.
Expand All @@ -101,8 +105,15 @@ class Sintering(Process, EntryData, ArchiveSection):
section_def=TemperatureRamp,
repeats=True,
)
data_file = Quantity(
type=str,
description='The recipe file for the sintering process.',
a_eln={
"component": "FileEditQuantity",
},
)

def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
def normalize(self, archive, logger: BoundLogger) -> None:
'''
The normalizer for the `Sintering` class.
Expand All @@ -111,7 +122,20 @@ def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
normalized.
logger (BoundLogger): A structlog logger.
'''
super().normalize(archive, logger)

super(Sintering, self).normalize(archive, logger)
if self.data_file:
with archive.m_context.raw_file(self.data_file) as file:
df = pd.read_csv(file)
steps = []
for i, row in df.iterrows():
step = TemperatureRamp()
step.name = row['step name']
step.duration = ureg.Quantity(float(row['duration [min]']), 'minutes')
step.initial_temperature = ureg.Quantity(row['initial temperature [C]'], 'celsius')
step.final_temperature = ureg.Quantity(row['final temperature [C]'], 'celsius')
steps.append(step)
self.steps = steps


m_package.__init_metainfo__()
4 changes: 4 additions & 0 deletions tests/data/data_sintering.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
step name,duration [min],initial temperature [C],final temperature [C]
heating, 30, 25, 300
hold, 60, 300, 300
cooling, 30, 300, 25

0 comments on commit faf97e7

Please sign in to comment.