Skip to content

Commit

Permalink
Refactor parsing of Cleaning and add CleaningStep class
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianschoeppach committed Nov 7, 2024
1 parent f67b73b commit f025c6c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 35 deletions.
44 changes: 27 additions & 17 deletions src/perovskite_tandem_database/parsers/tandemparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
ChalcopyriteAlkaliMetalDoping,
ChalcopyriteLayer,
Cleaning,
CleaningStep,
GasPhaseSynthesis,
General,
Ion,
Expand Down Expand Up @@ -285,6 +286,25 @@ def exact_get(data, label, default=None, default_unit=None):
return default


def extract_cleaning(data_frame):
"""
Extracts the cleaning steps from the data subframe.
"""

df_cleaning = data_frame[data_frame.index.str.contains('Cleaning')]
if df_cleaning.empty:
return None
else:
df_cleaning = split_data(df_cleaning, delimiter='|') # probably not necessary
df_cleaning = split_data(df_cleaning, delimiter='>>')
cleaning_steps = []
for syn_step in df_cleaning.columns:
cleaning_steps.append(
CleaningStep(name=partial_get(df_cleaning[syn_step], 'procedure'))
)
return Cleaning(steps=cleaning_steps)


def extract_additives(data_frame):
"""
Extracts the additives from the data subframe.
Expand Down Expand Up @@ -521,17 +541,7 @@ def extract_layer_stack(data_frame):
continue

# Cleaning
cleaning_steps = []
df_cleaning = df_layer[df_layer.index.str.contains('Cleaning')]
if not df_cleaning.empty:
df_cleaning = split_data(
df_cleaning, delimiter='|'
) # probably not necessary
df_cleaning = split_data(df_cleaning, delimiter='>>')
for syn_step in df_cleaning.columns:
cleaning_steps.append(
Cleaning(procedure=partial_get(df_cleaning[syn_step], 'Procedure'))
)
cleaning = extract_cleaning(df_layer)

# Deposition
df_sublayers = split_data(df_layer, delimiter='|')
Expand Down Expand Up @@ -611,7 +621,7 @@ def extract_layer_stack(data_frame):
layer_stack.append(
Substrate(
**sublayer_properties,
cleaning=cleaning_steps,
cleaning=cleaning,
synthesis=synthesis,
storage=storage,
)
Expand All @@ -620,7 +630,7 @@ def extract_layer_stack(data_frame):
layer_stack.append(
NonAbsorbingLayer(
**sublayer_properties,
cleaning=cleaning_steps,
cleaning=cleaning,
synthesis=synthesis,
storage=storage,
additives=additives,
Expand Down Expand Up @@ -667,7 +677,7 @@ def extract_layer_stack(data_frame):
**sublayer_properties,
**perovskite_properties,
composition=extract_perovskite_composition(df_sublayer),
cleaning=cleaning_steps,
cleaning=cleaning,
synthesis=synthesis,
storage=storage,
additives=additives,
Expand All @@ -685,7 +695,7 @@ def extract_layer_stack(data_frame):
**sublayer_properties,
**silicon_properties,
perovskite_inspired=None,
cleaning=cleaning_steps,
cleaning=cleaning,
synthesis=synthesis,
storage=storage,
additives=additives,
Expand All @@ -698,7 +708,7 @@ def extract_layer_stack(data_frame):
composition=extract_chalcopyrite_composition(df_sublayer),
alkali_metal_doping=extract_alkali_doping(df_sublayer),
perovskite_inspired=None,
cleaning=cleaning_steps,
cleaning=cleaning,
synthesis=synthesis,
storage=storage,
additives=additives,
Expand All @@ -709,7 +719,7 @@ def extract_layer_stack(data_frame):
PhotoAbsorber(
**sublayer_properties,
perovskite_inspired=None,
cleaning=cleaning_steps,
cleaning=cleaning,
synthesis=synthesis,
storage=storage,
additives=additives,
Expand Down
36 changes: 18 additions & 18 deletions src/perovskite_tandem_database/schema_packages/tandem.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from nomad.datamodel.metainfo.annotations import ELNAnnotation
from nomad.datamodel.metainfo.basesections import (
Activity,
ActivityStep,
ElementalComposition,
Process,
)
Expand Down Expand Up @@ -250,26 +251,25 @@ class SynthesisStep(Activity, ArchiveSection):
)


class Cleaning(Activity, ArchiveSection):
class CleaningStep(ActivityStep):
"""
A section describing a cleaning step. Typically before a subsequent synthesis step.
A cleaning procedure step.
"""

# TODO: Make repeatable if possible
procedure = Quantity(
type=Enum(
[
'Soap',
'Ultrasonic Bath',
'Ethanol',
'Acetone',
'UV-ozone',
'Piranha solutionion',
'Unknown',
]
),
description='',
shape=[],
pass


class Cleaning(Activity):
"""
A section describing a cleaning procedure. Typically before a subsequent synthesis step.
"""

steps = SubSection(
section_def=CleaningStep,
description="""
An ordered list of all the cleaning steps that make up this activity.
""",
repeats=True,
)


Expand Down Expand Up @@ -410,7 +410,7 @@ class Layer(ArchiveSection):
shape=[],
description='The specific brand name of a commercially purchased layer',
)
cleaning = SubSection(section_def=Cleaning, repeats=True)
cleaning = SubSection(section_def=Cleaning)
synthesis = SubSection(section_def=Synthesis)

# Storage
Expand Down

0 comments on commit f025c6c

Please sign in to comment.