diff --git a/notebooks/Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb b/notebooks/Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb index bf2384afb09c59108e739a9ab9493d8adaf8f7b8..3ecf9f72b38e5f15c8a8e3895f62160140f9b0f4 100644 --- a/notebooks/Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb +++ b/notebooks/Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb @@ -99,6 +99,17 @@ "%matplotlib inline" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "bc4a9824", + "metadata": {}, + "outputs": [], + "source": [ + "# Input parameters validation\n", + "gotthard2lib.validate_sensor_type(sensor_type)" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb b/notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb index 478719287185de554a953965039c62d6550ee8b6..b44d20e869d32179b79deb47c9d6e666ec330c7a 100644 --- a/notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb +++ b/notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb @@ -106,7 +106,6 @@ "import warnings\n", "from logging import warning\n", "\n", - "import h5py\n", "import pasha as psh\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", @@ -132,6 +131,17 @@ "%matplotlib inline" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "fc893eff", + "metadata": {}, + "outputs": [], + "source": [ + "# Input parameters validation\n", + "gotthard2lib.validate_sensor_type(sensor_type)" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/notebooks/Gotthard2/Summary_Darks_Gotthard2_NBC.ipynb b/notebooks/Gotthard2/Summary_Darks_Gotthard2_NBC.ipynb index 9b03e08e39185fc2a98f62e2fd3efc55dfab0328..adda2211f2a982e967940dc40818b5eb480cd6cd 100644 --- a/notebooks/Gotthard2/Summary_Darks_Gotthard2_NBC.ipynb +++ b/notebooks/Gotthard2/Summary_Darks_Gotthard2_NBC.ipynb @@ -69,6 +69,16 @@ "from cal_tools.tools import CalibrationMetadata" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Input parameters validation\n", + "gotthard2lib.validate_sensor_type(sensor_type)" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/src/cal_tools/gotthard2/gotthard2lib.py b/src/cal_tools/gotthard2/gotthard2lib.py index e13e5ad1e142c123a9dc387f2c91a0141d14574b..faacc8add6096bc8b733b3c3d6aac80fcf98f60e 100644 --- a/src/cal_tools/gotthard2/gotthard2lib.py +++ b/src/cal_tools/gotthard2/gotthard2lib.py @@ -3,6 +3,16 @@ from pathlib import Path from typing import List, Union import extra_data +import numpy as np + + +def validate_sensor_type(sensor_type): + choices = ["25um", "50um"] + if sensor_type and sensor_type not in choices: + raise ValueError( + f"Unexpected Gotthard2 `sensor_type` given: '{sensor_type}'. " + f"Valid options are: {', '.join(choices)}." + ) def map_da_to_source(dc, das, source_template, karabo_id, affixes): @@ -70,8 +80,6 @@ class Gotthard2Ctrl(): Returns: str: return if its a 25um or 50um detector. """ - import numpy as np - hostnames = self.run_dc.get_run_value(self.ctrl_src, "rxHostname") num_hosts = np.count_nonzero(hostnames != b'') if num_hosts == 0: