|
|
|
|
@@ -98,71 +98,52 @@ def chain_layer_to_target(layer_object):
|
|
|
|
|
material_object = call_material_from_elabid(target_elabid)
|
|
|
|
|
return material_object
|
|
|
|
|
|
|
|
|
|
#sample_object = call_entrypoint_from_elabid(elabid)
|
|
|
|
|
#from_entrypoint_to_material(sample_object)
|
|
|
|
|
|
|
|
|
|
def make_nexus_schema_dictionary(substrate_object, layers):
|
|
|
|
|
pld_fabrication = {
|
|
|
|
|
"sample": {
|
|
|
|
|
"substrate": {
|
|
|
|
|
"name": substrate_object.name,
|
|
|
|
|
"chemical_formula" : substrate_object.get_compound_formula(apikey),
|
|
|
|
|
"orientation" : substrate_object.orientation,
|
|
|
|
|
"miscut_angle" : substrate_object.miscut_angle,
|
|
|
|
|
"miscut_direction" : substrate_object.miscut_direction,
|
|
|
|
|
"thickness" : substrate_object.thickness,
|
|
|
|
|
"dimensions" : substrate_object.dimensions,
|
|
|
|
|
"surface_treatment" : substrate_object.surface_treatment,
|
|
|
|
|
"manufacturer" : substrate_object.manufacturer,
|
|
|
|
|
"batch_id" : substrate_object.batch_id,
|
|
|
|
|
},
|
|
|
|
|
"multilayer": {},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
multilayer = pld_fabrication["sample"]["multilayer"]
|
|
|
|
|
for layer in layers:
|
|
|
|
|
name = "layer_" + layer.layer_number
|
|
|
|
|
target_object = chain_layer_to_target(layer)
|
|
|
|
|
target_dict = {
|
|
|
|
|
"name": target_object.name,
|
|
|
|
|
"chemical_formula" : target_object.get_compound_formula(apikey),
|
|
|
|
|
"description" : target_object.description,
|
|
|
|
|
"shape" : target_object.shape,
|
|
|
|
|
"dimensions" : target_object.dimensions,
|
|
|
|
|
"thickness" : target_object.thickness,
|
|
|
|
|
"solid_form" : target_object.solid_form,
|
|
|
|
|
"manufacturer" : target_object.manufacturer,
|
|
|
|
|
# TO-DO: currently not available:
|
|
|
|
|
# "batch_id" : target_object.batch_id,
|
|
|
|
|
}
|
|
|
|
|
multilayer[name] = {
|
|
|
|
|
"target": target_dict
|
|
|
|
|
}
|
|
|
|
|
return json.dumps(pld_fabrication, indent=2)
|
|
|
|
|
|
|
|
|
|
if __name__=="__main__":
|
|
|
|
|
print(f"=======================\n===== DEBUG MODE! =====\n=======================\n")
|
|
|
|
|
# TO-DO: place the API base URL somewhere else.
|
|
|
|
|
ELABFTW_API_URL = "https://elabftw.fisica.unina.it/api/v2"
|
|
|
|
|
apikey = getpass("Paste API key here: ")
|
|
|
|
|
elabid = input("Enter elabid of your starting sample [default= 1111]: ") or 1111
|
|
|
|
|
data = APIHandler(apikey).get_entry_from_elabid(elabid)
|
|
|
|
|
sample = Entrypoint(data)
|
|
|
|
|
batch = chain_entrypoint_to_batch(sample) # Material-class object
|
|
|
|
|
bd = batch.__dict__
|
|
|
|
|
bd.pop("extra")
|
|
|
|
|
substrate_object = chain_entrypoint_to_batch(sample) # Substrate-class object
|
|
|
|
|
layers = chain_entrypoint_to_layers(sample) # list of Layer-class objects
|
|
|
|
|
print(f"Sample name:\n{sample.name}\n")
|
|
|
|
|
print(f"Substrate data:\n{bd}\n")
|
|
|
|
|
print(f"Layers data:")
|
|
|
|
|
for layer in layers:
|
|
|
|
|
ld = layer.__dict__
|
|
|
|
|
ld.pop("extra")
|
|
|
|
|
tgt = chain_layer_to_target(layer)
|
|
|
|
|
td = tgt.__dict__
|
|
|
|
|
td.pop("extra")
|
|
|
|
|
print(ld)
|
|
|
|
|
print(td)
|
|
|
|
|
print()
|
|
|
|
|
|
|
|
|
|
# entryType = None
|
|
|
|
|
# while entryType not in ["items", "experiments"]:
|
|
|
|
|
# eT = input("Enter a valid entry type [items, experiments]: ")
|
|
|
|
|
# # This allows for a shortcut: instead of prompting the type before and the elabid after I can just prompt both at the same time - e.g. e51 is exp. 51, i1108 is item 1108...
|
|
|
|
|
# if eT[0] in ["e", "i"] and eT[-1].isnumeric():
|
|
|
|
|
# try:
|
|
|
|
|
# elabid = int(eT[1:])
|
|
|
|
|
# eT = eT[0]
|
|
|
|
|
# except Exception:
|
|
|
|
|
# print("Usage: i|item|items|i[ELABID] for items, e|experiment|experiments|e[ELABID] for experiments.")
|
|
|
|
|
# continue
|
|
|
|
|
# match eT:
|
|
|
|
|
# case "items" | "i" | "item":
|
|
|
|
|
# entryType = "items"
|
|
|
|
|
# case "experiments" | "e" | "exp" | "experiment":
|
|
|
|
|
# entryType = "experiments"
|
|
|
|
|
# case _:
|
|
|
|
|
# continue
|
|
|
|
|
# # This will probably be reworked in production
|
|
|
|
|
# try:
|
|
|
|
|
# elabid = elabid
|
|
|
|
|
# except NameError:
|
|
|
|
|
# elabid = input("Input elabid here [default = 1111]: ") or 1111
|
|
|
|
|
# data = APIHandler(apikey).get_entry_from_elabid(elabid, entryType)
|
|
|
|
|
# if entryType == "experiments":
|
|
|
|
|
# layer = Layer(data)
|
|
|
|
|
# result = layer.__dict__
|
|
|
|
|
# result.pop("extra")
|
|
|
|
|
# print(result)
|
|
|
|
|
# elif entryType == "items":
|
|
|
|
|
# if data.get("category_title") == "Sample":
|
|
|
|
|
# item = Entrypoint(data)
|
|
|
|
|
# elif data.get("category_title") in ["PLD Target", "Substrate"]:
|
|
|
|
|
# item = Material(data)
|
|
|
|
|
# print(item.get_compound_formula(apikey))
|
|
|
|
|
# else:
|
|
|
|
|
# raise Exception("The selected item or experiment is not in one of the following categories: [Sample, PLD Target, Substrate, PLD Deposition].")
|
|
|
|
|
# result = item.__dict__
|
|
|
|
|
# result.pop("extra")
|
|
|
|
|
# print(result)
|
|
|
|
|
print(make_nexus_schema_dictionary(substrate_object, layers)) # debug
|
|
|
|
|
|