From b6d8826422f415ff737e6fdd5b159b6592563454 Mon Sep 17 00:00:00 2001
From: ahmedk <karim.ahmed@xfel.eu>
Date: Tue, 23 Jan 2024 15:12:16 +0100
Subject: [PATCH] skip empty sequence files

---
 notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb b/notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb
index ed9be026c..bd1940cf3 100644
--- a/notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb
+++ b/notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb
@@ -429,7 +429,12 @@
     "    # Select module INSTRUMENT sources and deselect empty trains.\n",
     "    dc = H5File(raw_file).select(data_sources, require_all=True)\n",
     "    n_trains = len(dc.train_ids)\n",
-    "    print(f\"Correcting {n_trains} for {raw_file}.\")\n",
+    "    \n",
+    "    if n_trains == 0:\n",
+    "        warning(f\"Skipping correction. No trains to correct for this sequence file: {raw_file}.\")\n",
+    "        continue\n",
+    "    else:\n",
+    "        print(f\"Correcting {n_trains} for {raw_file}.\")\n",
     "\n",
     "    # Initialize GH2 data and gain arrays to store in corrected files.\n",
     "    if gh2_detector == \"25um\":\n",
-- 
GitLab