Compare commits
3 Commits
main
...
fc150be724
| Author | SHA256 | Date | |
|---|---|---|---|
| fc150be724 | |||
| aa3bf531f9 | |||
| 3f97ccee25 |
@@ -1,62 +0,0 @@
|
|||||||
"""
|
|
||||||
Currently unused!
|
|
||||||
"""
|
|
||||||
import json, requests
|
|
||||||
from APIHandler import APIHandler
|
|
||||||
|
|
||||||
def get_entry_from_elabid(elabid, entryType="items"):
|
|
||||||
'''
|
|
||||||
Function which returns entrypoint data (as dictionary) from its elabid.
|
|
||||||
'''
|
|
||||||
header = APIHandler(apikey).dump
|
|
||||||
response = requests.get(
|
|
||||||
headers = header,
|
|
||||||
url = f"{ELABFTW_API_URL}/{entryType}/{elabid}",
|
|
||||||
verify=True
|
|
||||||
)
|
|
||||||
if response.status_code // 100 in [2,3]:
|
|
||||||
entry_data = response.json()
|
|
||||||
return entry_data
|
|
||||||
else:
|
|
||||||
raise ConnectionError(f"HTTP request failed with status code: {response.status_code}.")
|
|
||||||
|
|
||||||
def get_sample_layers_data(elabid):
|
|
||||||
'''
|
|
||||||
Return the following data from every eLabFTW experiment linked
|
|
||||||
to a certain sample, identified by elabid.
|
|
||||||
|
|
||||||
- Title of the experiment
|
|
||||||
- Category (should check it's "PLD Deposition")
|
|
||||||
- Layer number - if present (PLD depositions)
|
|
||||||
- Deposition time - returns error if not present
|
|
||||||
- Repetition rate - returns error if not present
|
|
||||||
'''
|
|
||||||
# header = {
|
|
||||||
# "Authorization": apikey,
|
|
||||||
# "Content-Type": "application/json"
|
|
||||||
# }
|
|
||||||
sample_data = requests.get(
|
|
||||||
headers = header,
|
|
||||||
url = f"https://elabftw.fisica.unina.it/api/v2/items/{elabid}",
|
|
||||||
verify=True
|
|
||||||
).json()
|
|
||||||
related_experiments = sample_data["related_experiments_links"]
|
|
||||||
result = []
|
|
||||||
for exp in related_experiments:
|
|
||||||
experiment_data = requests.get(
|
|
||||||
headers = header,
|
|
||||||
url = f"https://elabftw.fisica.unina.it/api/v2/experiments/{exp.get("entityid")}",
|
|
||||||
verify=True
|
|
||||||
).json()
|
|
||||||
extra = experiment_data["metadata_decoded"]["extra_fields"]
|
|
||||||
result.append(
|
|
||||||
{"title": exp.get("title"),
|
|
||||||
"layer_number": extra.get("Layer Progressive Number").get("value"),
|
|
||||||
"category": exp.get("category_title"),
|
|
||||||
"deposition_time": extra.get("Duration").get("value"),
|
|
||||||
"repetition_rate": extra.get("Repetition rate").get("value")}
|
|
||||||
)
|
|
||||||
return result
|
|
||||||
|
|
||||||
if __name__=="__main__":
|
|
||||||
print("Warning: you're not supposed to be running this as the main program.")
|
|
||||||
10
src/main.py
10
src/main.py
@@ -1,4 +1,5 @@
|
|||||||
import os, json, requests, h5py
|
import os, json, requests, h5py
|
||||||
|
import numpy as np
|
||||||
from getpass import getpass
|
from getpass import getpass
|
||||||
from APIHandler import APIHandler
|
from APIHandler import APIHandler
|
||||||
from classes import *
|
from classes import *
|
||||||
@@ -301,7 +302,7 @@ def make_nexus_schema_dictionary(substrate_object, layers):
|
|||||||
}
|
}
|
||||||
return pld_fabrication
|
return pld_fabrication
|
||||||
|
|
||||||
def build_nexus_file(pld_fabrication, output_path):
|
def build_nexus_file(pld_fabrication, output_path, rheed_osc=None):
|
||||||
# NOTE: look at the mail attachment from Emiliano...
|
# NOTE: look at the mail attachment from Emiliano...
|
||||||
with h5py.File(output_path, "w") as f:
|
with h5py.File(output_path, "w") as f:
|
||||||
nx_pld_entry = f.create_group("pld_fabrication")
|
nx_pld_entry = f.create_group("pld_fabrication")
|
||||||
@@ -439,6 +440,9 @@ def build_nexus_file(pld_fabrication, output_path):
|
|||||||
nx_instruments.create_dataset("rheed_system", data = instruments_dict["rheed_system"])
|
nx_instruments.create_dataset("rheed_system", data = instruments_dict["rheed_system"])
|
||||||
except TypeError as te:
|
except TypeError as te:
|
||||||
raise TypeError(te)
|
raise TypeError(te)
|
||||||
|
nx_rheed = nx_pld_entry.create_group("rheed_data")
|
||||||
|
nx_rheed.attrs["NX_class"] = "NXdata"
|
||||||
|
nx_rheed.create_dataset("intensity", data=rheed_osc)
|
||||||
return
|
return
|
||||||
|
|
||||||
if __name__=="__main__":
|
if __name__=="__main__":
|
||||||
@@ -455,4 +459,6 @@ if __name__=="__main__":
|
|||||||
# print(make_nexus_schema_dictionary(substrate_object, layers)) # debug
|
# print(make_nexus_schema_dictionary(substrate_object, layers)) # debug
|
||||||
with open (f"output/sample-{sample_name}.json", "w") as f:
|
with open (f"output/sample-{sample_name}.json", "w") as f:
|
||||||
json.dump(result, f, indent=3)
|
json.dump(result, f, indent=3)
|
||||||
build_nexus_file(result, output_path=f"output/sample-{sample_name}-nexus.h5")
|
with open(f"tests/Realtime_Window_Analysis.txt", "r") as o:
|
||||||
|
osc = np.loadtxt(o)
|
||||||
|
build_nexus_file(result, output_path=f"output/sample-{sample_name}-nexus.h5", rheed_osc=osc)
|
||||||
|
|||||||
37931
tests/Realtime_Window_Analysis.txt
Normal file
37931
tests/Realtime_Window_Analysis.txt
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user