reworks how instruments are recorded in the nx file according to new ver

the instruments_used group is still present outside the multilayer group
but currently a new instruments_used sub-group is created in the
layer-specific group

instruments used to deposit a single layer are in
/sample/multilayer/layer_N/instruments_used and there's only one value
for each category (rheed, laser, chamber)
in /instruments_used (root) for each category there's a list of every
(unique) instrument involved in the full deposition process
This commit is contained in:
2026-03-13 15:11:53 +01:00
parent bab5e958cb
commit 10c68bf260

View File

@@ -115,19 +115,19 @@ def deduplicate_instruments_from_layers(layers):
chambers.append(instruments["deposition_chamber"])
rheeds.append(instruments["rheed_system"])
elegant_dict[f"layer_{lyr.layer_number}"] = {
"Laser Systems": instruments["laser_system"],
"Deposition Chamber": instruments["deposition_chamber"],
"RHEED Systems": instruments["rheed_system"],
"laser_system": instruments["laser_system"],
"deposition_chamber": instruments["deposition_chamber"],
"rheed_system": instruments["rheed_system"],
}
ded_lasers = list( set( lasers ) )
ded_chambers = list( set( chambers ) )
ded_rheeds = list( set( rheeds ) )
elegant_dict["multilayer"] = {
# Keep key names human readable since they're used in the messages of the following errors
"Laser Systems": ", ".join(ded_lasers),
"Deposition Chamber": ", ".join(ded_chambers),
"RHEED Systems": ", ".join(ded_rheeds)
} # dictionary's name's a joke
"laser_system": ", ".join(ded_lasers),
"deposition_chamber": ", ".join(ded_chambers),
"rheed_system": ", ".join(ded_rheeds)
} # dictionary's name is a joke
# updated_dict = {} # use this for containing the final dataset
# for ded in elegant_dict:
# if len(elegant_dict[ded]) == 0:
@@ -183,6 +183,7 @@ def make_nexus_schema_dictionary(substrate_object, layers):
'''
Main function, takes all the other functions to reconstruct the full dataset. Takes a Substrate-class object (output of the chain_entrypoint_to_batch() function) and a list of Layer-class objects (output of the chain_entrypoint_to_layers() function), returns dictionary with the same schema as the NeXus standard for PLD fabrications.
'''
instruments = deduplicate_instruments_from_layers(layers)
pld_fabrication = {
"sample": {
"substrate": {
@@ -205,7 +206,7 @@ def make_nexus_schema_dictionary(substrate_object, layers):
},
"multilayer": {},
},
"instruments_used": deduplicate_instruments_from_layers(layers),
"instruments_used": instruments["multilayer"],
}
multilayer = pld_fabrication["sample"]["multilayer"]
for layer in layers:
@@ -305,6 +306,7 @@ def make_nexus_schema_dictionary(substrate_object, layers):
"units": layer.post_annealing_duration_unit,
},
},
"instruments_used": instruments[name],
}
return pld_fabrication
@@ -365,6 +367,9 @@ def build_nexus_file(pld_fabrication, output_path, rheed_osc=None):
nx_post_annealing = nx_layer.create_group("post_annealing")
nx_post_annealing.attrs["NX_class"] = "NXprocess"
post_ann_dict = layer_dict["post_annealing"]
nx_layer_instruments = nx_layer.create_group("instruments_used")
nx_layer_instruments.attrs["NX_class"] = "NXinstrument"
layer_instruments_dict = layer_dict["instruments_used"]
## Target metadata
try:
@@ -435,6 +440,12 @@ def build_nexus_file(pld_fabrication, output_path, rheed_osc=None):
nx_post_annealing["duration"].attrs["units"] = post_ann_dict["duration"]["units"]
except TypeError as te:
raise TypeError(te)
try:
nx_layer_instruments.create_dataset("laser_system", data = layer_instruments_dict["laser_system"])
nx_layer_instruments.create_dataset("deposition_chamber", data = layer_instruments_dict["deposition_chamber"])
nx_layer_instruments.create_dataset("rheed_system", data = layer_instruments_dict["rheed_system"])
except TypeError as te:
raise TypeError(te)
# Instruments used section
nx_instruments = nx_pld_entry.create_group("instruments_used")