From ca2cdbfded8167420ade4ab37c2d5585d32ff6f2d2eb54a7d20346dcfe26f7e5 Mon Sep 17 00:00:00 2001 From: PioApocalypse Date: Mon, 16 Feb 2026 11:28:17 +0100 Subject: [PATCH] adds units of measurement in Layer class plus moves around fullname/operator, created_at and description/body so that operator is required while the others aren't --- src/classes.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/classes.py b/src/classes.py index 0001cec..13be47f 100644 --- a/src/classes.py +++ b/src/classes.py @@ -13,17 +13,17 @@ class Layer: ''' def __init__(self, layer_data): try: + self.operator = layer_data["fullname"] self.extra = layer_data["metadata_decoded"]["extra_fields"] self.layer_number = self.extra["Layer Progressive Number"]["value"] # integer self.target_elabid = self.extra["Target"]["value"] # elabid self.laser_system_elabid = self.extra["Laser System"]["value"] # elabid self.chamber_elabid = self.extra["Chamber"]["value"] # elabid self.rheed_system_elabid = self.extra["RHEED System"]["value"] # elabid - self.start_time = layer_data.get("created_at") - self.operator = layer_data.get("fullname") - self.description = layer_data.get("body") self.deposition_time = self.extra["Duration"]["value"] + self.deposition_time_unit = self.extra["Duration"]["unit"] self.repetition_rate = self.extra["Repetition rate"]["value"] + self.repetition_rate_unit = self.extra["Repetition rate"]["unit"] try: self.number_of_pulses = (float(self.deposition_time) * float(self.repetition_rate)).__floor__() except ValueError: @@ -34,15 +34,22 @@ class Layer: Please edit your eLabFTW entry and retry. """) self.temperature = self.extra["Heater temperature"]["value"] # Note: this field used to have a trailing space in its name + self.temperature_unit = self.extra["Heater temperature"]["unit"] self.process_pressure = self.extra["Process pressure"]["value"] # Note: this field used to have a trailing space in its name + self.process_pressure_unit = self.extra["Process pressure"]["unit"] self.heating_method = self.extra["Heating Method"]["value"] self.layer_thickness = self.extra["Thickness"]["value"] + self.layer_thickness_unit = self.extra["Thickness"]["unit"] self.buffer_gas = self.extra["Buffer gas"]["value"] self.heater_target_distance = self.extra["Heater-target distance"]["value"] + self.heater_target_distance_unit = self.extra["Heater-target distance"]["unit"] self.laser_fluence = self.extra["Laser Intensity"]["value"] # here fluence = intensity + self.laser_fluence_unit = "J/(s cm^2)" self.laser_spot_area = self.extra["Spot Area"]["value"] + self.laser_spot_area_unit = "mm^2" try: - self.laser_energy = (float(self.laser_fluence) * float(self.laser_spot_area)).__round__(3) + self.laser_energy = ( float(self.laser_fluence) * float(self.laser_spot_area) / 100 ).__round__(3) + self.laser_energy_unit = "J/s" except ValueError: # Since laser_energy is NOT required, if it can't be calculated warn user but allow the software to continue execution: print(""" @@ -61,17 +68,27 @@ class Layer: self.pre_annealing_pressure = self.extra["Process pressure Pre"]["value"] self.pre_annealing_temperature = self.extra["Heater temperature Pre"]["value"] self.pre_annealing_duration = self.extra["Duration Pre"]["value"] + self.pre_annealing_pressure_unit = self.extra["Process pressure Pre"]["unit"] + self.pre_annealing_temperature_unit = self.extra["Heater temperature Pre"]["unit"] + self.pre_annealing_duration_unit = self.extra["Duration Pre"]["unit"] # Post annealing section self.post_annealing_ambient_gas = self.extra["Buffer gas PA"]["value"] self.post_annealing_pressure = self.extra["Process pressure PA"]["value"] self.post_annealing_temperature = self.extra["Heater temperature PA"]["value"] self.post_annealing_duration = self.extra["Duration PA"]["value"] + self.post_annealing_pressure_unit = self.extra["Process pressure PA"]["unit"] + self.post_annealing_temperature_unit = self.extra["Heater temperature PA"]["unit"] + self.post_annealing_duration_unit = self.extra["Duration PA"]["unit"] + # Rejected but suggested by the NeXus standard: #self.laser_rastering_coefficients = None 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: raise KeyError(f"The provided dictionary lacks a \"{k}\" key. Check the deposition layer entry on eLabFTW and make sure you used the correct Experiment template.") + # Optional + self.start_time = layer_data.get("created_at") or None + self.description = layer_data.get("body") or None def get_instruments(self, apikey): raw_lasersys_data = APIHandler(apikey).get_entry_from_elabid(self.laser_system_elabid, entryType="items") raw_chamber_data = APIHandler(apikey).get_entry_from_elabid(self.chamber_elabid, entryType="items")