Compare commits

..

3 Commits

3 changed files with 42 additions and 19 deletions

View File

@@ -1,3 +1,5 @@
# parser-eLabFTW-2-NeXus
# parser-eLabFTW-jupyter
Parser for eLabFTW to convert JSON data from the experiments to NeXus-compliant HDF5 files.
Jupyter notebook collection to develop a parser for eLabFTW which is supposed to convert JSON data from the experiments to NeXus files for PLD depositions.
Previously this repo was dedicated to the entire project. That is now: [emanuele/parser-eLabFTW-NFFA-DI](https://gitea.damico.ing/emanuele/parser-eLabFTW-NFFA-DI).

View File

@@ -37,7 +37,7 @@
"7. Make an HTTP request to fetch the **compound's data**.\n",
"8. Parse the JSON to FINALLY get the value of the <u>compound's chemical formula</u>.\n",
"\n",
"> The chemical formula of the substrate is required by the NeXus standard for PLD depositions.\n",
"> The chemical formula of the substrate is required by the NeXus standard for PLD depositions.\n",
"\n",
"The information we want to get is nested behind three additional HTTP requests. Every additional request required, other than the initial one made to fetch the experiment's data, shall be referred to as a **level of nesting** (or depth). If a piece of information is immediately available in the experiment's data, it means the information is not nested and is at zero levels of depth.\n",
"\n",
@@ -147,15 +147,15 @@
"source": [
"### Fetch any experiment related to a certain sample\n",
"Another easy task is fetching every experiment entry related to a given sample. \\\n",
"Let's start with the sample of elabid equal to *1077* - which at the time I'm writing this is named \"Na-26-001 LMNO LAO\". The related experiments are Experiment 48 (layer 1) and Experiment 49 (layer 2). From these experiments we will only fetch *deposition time* and *repetition rate* to keep the present notebook clean.\n",
"Let's start with the sample of elabid equal to *1108* - which at the time I'm writing this is named \"Na-26-005\". The related experiments are Experiment 48 (layer 1) and Experiment 49 (layer 2). From these experiments we will only fetch *deposition time* and *repetition rate* to keep the present notebook clean.\n",
"\n",
"#### How linked experiments are managed by eLabFTW\n",
"Linked experiments are similar to linked items: you can reference an eLabFTW experiment into a resource, but when you download the data of the latter from the API endpoint you only get the elabid and **very few additional data** - like the experiment's title - of the former. In this situation the experiments linked to a sample contain information about its layers, which is at least level-1 nested since it requires at least an additional HTTP request."
"Linked experiments are similar to linked items: you can reference an eLabFTW experiment into a resource, but when you download the data of the latter from the API endpoint you only get the elabid and **very few additional data** - like the experiment's category - of the former. In this situation the experiments linked to a sample contain information about its layers, which is at least level-1 nested since it requires at least an additional HTTP request."
]
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 8,
"id": "504c6eec-967b-4886-8770-67b5df3ed5ef",
"metadata": {},
"outputs": [
@@ -169,11 +169,19 @@
{
"data": {
"text/plain": [
"[{'deposition_time': '65', 'repetition_rate': '1'},\n",
" {'deposition_time': '56', 'repetition_rate': '1'}]"
"[{'title': 'Na-26-005',\n",
" 'layer_number': '1',\n",
" 'category': 'PLD Deposition',\n",
" 'deposition_time': '100',\n",
" 'repetition_rate': '1'},\n",
" {'title': 'Na-26-005 I',\n",
" 'layer_number': '2',\n",
" 'category': 'PLD Deposition',\n",
" 'deposition_time': '30',\n",
" 'repetition_rate': '1'}]"
]
},
"execution_count": 18,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
@@ -202,21 +210,37 @@
" ).json()\n",
" extra = experiment_data[\"metadata_decoded\"][\"extra_fields\"]\n",
" result.append(\n",
" {\"deposition_time\": extra.get(\"Duration\").get(\"value\"),\n",
" {\"title\": exp.get(\"title\"),\n",
" \"layer_number\": extra.get(\"Layer Progressive Number\").get(\"value\"),\n",
" \"category\": exp.get(\"category_title\"),\n",
" \"deposition_time\": extra.get(\"Duration\").get(\"value\"),\n",
" \"repetition_rate\": extra.get(\"Repetition rate\").get(\"value\")}\n",
" )\n",
" return result\n",
"\n",
"apikey = getpass(\"Paste API key here: \")\n",
"get_sample_layers_data(1077)"
"get_sample_layers_data(1108)"
]
},
{
"cell_type": "code",
"execution_count": null,
"cell_type": "markdown",
"id": "046f7383-5830-462b-9ac0-2026e46c5697",
"metadata": {},
"outputs": [],
"source": [
"The variables in the previous code can be best summarized as follows.\n",
"\n",
"* `related_experiments` (dict) only contains all of the linked experiments' elabid's, categories and titles.\n",
"* `experiment_data` (dict) contains ALL data related to one experiment at a time.\n",
"* `extra` (dict) is a sub-dictionary of `experiment_data` only containing the extra fields' values.\n",
"* The N-th item of `result` (list) contains cherrypicked data on the N-th layer.\n",
"\n",
"> ⚠️ The index of a layer in the `result` list does not necessarily equate the layer's progressive number."
]
},
{
"cell_type": "markdown",
"id": "2ca38bf4-ac33-481f-9ee2-99ec4db1686c",
"metadata": {},
"source": []
}
],
@@ -236,7 +260,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
"version": "3.12.12"
}
},
"nbformat": 4,

View File

@@ -1,4 +1 @@
numpy
h5py>=3.15.1
h5json>=1.1.3
six
notebook