From 0b8e7598ec95b611c2f2a6e33b03c7e03bb4aab6 Mon Sep 17 00:00:00 2001 From: ahmedk <karim.ahmed@xfel.eu> Date: Thu, 30 May 2024 11:27:48 +0200 Subject: [PATCH] fix(AGIPD)(CORRECT): Account for a modified file list if skipping correcting any modules. --- .../AGIPD/AGIPD_Correct_and_Verify.ipynb | 69 ++++++++++--------- 1 file changed, 36 insertions(+), 33 deletions(-) diff --git a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb index e401e18e0..8172dcbd0 100644 --- a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb +++ b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb @@ -414,37 +414,6 @@ " train_ids = None" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# set everything up filewise\n", - "mapped_files, _, total_sequences, _, _ = map_modules_from_folder(\n", - " str(in_folder), run, path_template, karabo_da, sequences\n", - ")\n", - "file_list = []\n", - "\n", - "# ToDo: Split table over pages\n", - "print(f\"Processing a total of {total_sequences} sequence files in chunks of {n_cores_files}\")\n", - "table = []\n", - "ti = 0\n", - "for k, files in mapped_files.items():\n", - " i = 0\n", - " for f in list(files.queue):\n", - " file_list.append(f)\n", - " if i == 0:\n", - " table.append((ti, k, i, f))\n", - " else:\n", - " table.append((ti, \"\", i, f))\n", - " i += 1\n", - " ti += 1\n", - "md = display(Latex(tabulate.tabulate(table, tablefmt='latex',\n", - " headers=[\"#\", \"module\", \"# module\", \"file\"])))\n", - "file_list = sorted(file_list, key=lambda name: name[-10:])" - ] - }, { "cell_type": "code", "execution_count": null, @@ -786,7 +755,6 @@ " if error_missing_constants:\n", " warning(f\"Offset constant is not available to correct {da}.\")\n", " # Remove module from files to process.\n", - " del mapped_files[module_index_to_qm(mod)]\n", " karabo_da.remove(da)\n", " modules.remove(mod)\n", "\n", @@ -796,7 +764,9 @@ " if warn_missing_constants:\n", " warning(f\"Constants {warn_missing_constants} were not retrieved for {da}.\")\n", "\n", - "if not mapped_files: # Offsets are missing for all modules.\n", + "# Skip das not available in CALCAT and with no constants.\n", + "karabo_da = [da for da in karabo_da if da in agipd_metadata.keys()]\n", + "if not da: # Offsets are missing for all modules.\n", " raise Exception(\"Could not find offset constants for any modules, will not correct data.\")" ] }, @@ -813,6 +783,39 @@ " caldb_root=agipd_cal.caldb_root)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Set everything up filewise\n", + "# This cell needs to be after getting and validating CCVs and\n", + "# after modifying `karabo_da` in case of missing required constants.\n", + "mapped_files, _, total_sequences, _, _ = map_modules_from_folder(\n", + " str(in_folder), run, path_template, karabo_da, sequences\n", + ")\n", + "file_list = []\n", + "\n", + "# ToDo: Split table over pages\n", + "print(f\"Processing a total of {total_sequences} sequence files in chunks of {n_cores_files}\")\n", + "table = []\n", + "ti = 0\n", + "for k, files in mapped_files.items():\n", + " i = 0\n", + " for f in list(files.queue):\n", + " file_list.append(f)\n", + " if i == 0:\n", + " table.append((ti, k, i, f))\n", + " else:\n", + " table.append((ti, \"\", i, f))\n", + " i += 1\n", + " ti += 1\n", + "md = display(Latex(tabulate.tabulate(table, tablefmt='latex',\n", + " headers=[\"#\", \"module\", \"# module\", \"file\"])))\n", + "file_list = sorted(file_list, key=lambda name: name[-10:])" + ] + }, { "cell_type": "code", "execution_count": null, -- GitLab