From d3df783170e93f8b9ef90865ecd89382d47fa895 Mon Sep 17 00:00:00 2001 From: ahmedk <karim.ahmed@xfel.eu> Date: Tue, 23 Jan 2024 15:07:12 +0100 Subject: [PATCH] show number of available trains and raise ValueError for runs with no trains --- .../Gotthard2/Correction_Gotthard2_NBC.ipynb | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb b/notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb index 62853ba7d..ed9be026c 100644 --- a/notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb +++ b/notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb @@ -248,6 +248,21 @@ " print(f\"Using {corr_receiver} as a receiver name for the corrected data.\")" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "2551b923", + "metadata": {}, + "outputs": [], + "source": [ + "# Check the available trains to correct.\n", + "total_trains = len(RunDirectory(run_folder).select(data_sources, require_all=True).train_ids)\n", + "if total_trains:\n", + " print(f\"Correcting {total_trains}.\")\n", + "else:\n", + " raise ValueError(f\"No trains to correct for run {run}.\")" + ] + }, { "cell_type": "markdown", "id": "8c852392-bb19-4c40-b2ce-3b787538a92d", @@ -413,8 +428,8 @@ " out_file = out_folder / raw_file.name.replace(\"RAW\", \"CORR\")\n", " # Select module INSTRUMENT sources and deselect empty trains.\n", " dc = H5File(raw_file).select(data_sources, require_all=True)\n", - "\n", " n_trains = len(dc.train_ids)\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