From c4903a536b54025fcb98273cae49763bffef446170cd8f71784c9015bb382815 Mon Sep 17 00:00:00 2001 From: PioApocalypse Date: Thu, 12 Feb 2026 15:53:44 +0100 Subject: [PATCH] [untested] creates child classes of Material for Substrates and Targets --- src/classes.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/classes.py b/src/classes.py index 02c20d6..642c3f1 100644 --- a/src/classes.py +++ b/src/classes.py @@ -108,8 +108,10 @@ class Material: ''' def __init__(self, material_data): try: + self.name = material_data["title"] # required self.extra = material_data["metadata_decoded"]["extra_fields"] self.compound_elabid = self.extra["Compound"]["value"] + self.dimensions = self.extra["Size"]["value"] except KeyError as k: # Some keys are not required and can be called through the .get() method - which is permissive and allows null values; # Other keys are required so if they can't be called (invalid or null) raise error and stop execution of the program: @@ -130,6 +132,32 @@ class Material: formula = self.get_compound_data(apikey).get("chemical_formula") return formula +class Substrate(Material): + def __init__(self, material_data): + super().__init__(material_data) + try: + self.orientation = self.extra["Orientation"]["value"] + self.miscut_angle = self.extra["Miscut Angle"]["value"] + self.miscut_direction = self.extra["Miscut Direction"]["value"] + # Not present (yet) on eLabFTW for Substrates: + self.thickness = None #self.extra["Thickness"]["value"] + self.surface_treatment = self.extra["Surface treatment"]["value"] + self.manufacturer = self.extra["Supplier"]["value"] + self.batch_id = self.extra["Batch ID"]["value"] + except KeyError as k: + raise KeyError(f"The provided dictionary lacks a \"{k}\" key - which is specific for substrates. Check the {self.name} substrate entry on eLabFTW and make sure you used the correct Resource template.") + +class Target(Material): + def __init__(self, material_data): + super().__init__(material_data) + try: + self.thickness = self.extra["Thickness"]["value"] + self.shape = self.extra["shape"]["value"] + self.solid_form = self.extra["Solid form"]["value"] + self.manufacturer = self.extra["Supplier"]["value"] + except KeyError as k: + raise KeyError(f"The provided dictionary lacks a \"{k}\" key - which is specific for PLD targets. Check the {self.name} target entry on eLabFTW and make sure you used the correct Resource template.") + if __name__=="__main__":