diff --git a/notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb b/notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb index 62853ba7de5b05b6a03f249c6e7d8df7e7fa59f1..bd1940cf30bb7be8fbae855ca848861e3b7d6f3c 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,13 @@ " 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", + " \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",