diff --git a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb index 509b8d9bba0aa8592339245f69a5d4c8a870da49..7005c32caaa800729e4e22c6cf63a5155b51bc3d 100644 --- a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb +++ b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb @@ -334,18 +334,21 @@ "metadata": {}, "outputs": [], "source": [ - "# Before proceeding, verify the availability of trains\n", - "# in AGIPD detector modules at INSTRUMENT group.\n", - "try:\n", - " for m in modules: # channels\n", - " train_ids = dc.select(instrument_src.format(m), require_all=True).train_ids\n", - " if len(train_ids) > 0:\n", - " break # Found a module with trains.\n", - " else: # Found no trains to correct.\n", - " latex_warning(f\"No trains available to correct in: {dc_available_modules}\")\n", - " sys.exit(0)\n", - "except ValueError as e:\n", - " warning(f\"Missing module {m} form data: {e}\")" + "train_available = False\n", + "\n", + "for m in modules:\n", + " try:\n", + " # Attempt to select the module. If no trains are available, ValueError might be raised\n", + " if len(dc.select(instrument_src.format(m), require_all=True).train_ids) > 0:\n", + " train_available = True\n", + " break # Found a module with available trains.\n", + " except ValueError as e:\n", + " warning(f\"Missing module {m} from data: {e}\")\n", + "\n", + "if not train_available:\n", + " # Execute this block if no modules with trains were found.\n", + " latex_warning(\"No trains available to correct for selected modules.\")\n", + " sys.exit(0)" ] }, {