diff --git a/notebooks/LPDMini/LPD_Mini_Correct.ipynb b/notebooks/LPDMini/LPD_Mini_Correct.ipynb index f66d534abe9acd651e1bc710a2ffd08ff08f0747..3db68d53920c41ddefc796e7e8cc72e4b1bf443e 100644 --- a/notebooks/LPDMini/LPD_Mini_Correct.ipynb +++ b/notebooks/LPDMini/LPD_Mini_Correct.ipynb @@ -85,6 +85,7 @@ "import re\n", "import warnings\n", "\n", + "from IPython.display import Markdown\n", "import numpy as np\n", "import h5py\n", "\n", @@ -239,9 +240,10 @@ "\n", "# Retrieve constants from CALCAT.\n", "dark_calibrations = {\n", - " 1: 'Offset', # np.float32\n", - " 14: 'BadPixelsDark' # should be np.uint32, but is np.float64\n", + " 14: 'BadPixelsDark' # np.uint32\n", "}\n", + "if offset_corr:\n", + " dark_calibrations[1] = 'Offset' # np.float32\n", "\n", "base_condition = [\n", " # Bias voltage added below as it differs by module\n", @@ -262,25 +264,36 @@ "else:\n", " dark_condition = base_condition.copy()\n", "\n", - "illuminated_calibrations = {\n", - " 20: 'BadPixelsFF', # np.uint32\n", - " 42: 'GainAmpMap', # np.float32\n", - " 43: 'FFMap', # np.float32\n", - " 44: 'RelativeGain' # np.float32\n", - "}\n", + "illuminated_calibrations = {}\n", + "if rel_gain:\n", + " illuminated_calibrations[44] = 'RelativeGain' # np.float32\n", + "if ff_map:\n", + " illuminated_calibrations[43] = 'FFMap' # np.float32\n", + " illuminated_calibrations[20] = 'BadPixelsFF' # np.uint32\n", + "if gain_amp_map:\n", + " illuminated_calibrations[42] = 'GainAmpMap' # np.float32\n", "\n", "illuminated_condition = base_condition + [\n", " dict(parameter_id=3, value=photon_energy), # Source energy\n", - "]\n", - "\n", + "]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "print('Querying calibration database', end='', flush=True)\n", "start = perf_counter()\n", "\n", - "\n", "for calibrations, condition in [\n", " (dark_calibrations, dark_condition),\n", " (illuminated_calibrations, illuminated_condition)\n", "]:\n", + " if not calibrations:\n", + " continue\n", + "\n", " for karabo_da_m in karabo_da:\n", " mod_num = int(karabo_da_m.split('/')[-1])\n", " # mod_num is from 1 to 8, so b_v_0 applies to odd numbers\n", @@ -324,6 +337,22 @@ "print(f'{total_time:.1f}s')" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "lines = []\n", + "for karabo_da_m, mod_const_metadata in retrieved_consts.items():\n", + " lines.append(f\"- {karabo_da_m} ({mod_const_metadata['physical-name']})\")\n", + " for const_name, d in mod_const_metadata['constants'].items():\n", + " url = f\"https://in.xfel.eu/calibration/calibration_constant_versions/{d['ccv-id']}\"\n", + " lines.append(f\" - {const_name}: [{d['creation-time']}]({url})\")\n", + "\n", + "Markdown('\\n'.join(lines))" + ] + }, { "cell_type": "code", "execution_count": null,