diff --git a/notebooks/LPDMini/LPD_Mini_Inject_calibration_constants_from_h5files.ipynb b/notebooks/LPDMini/LPD_Mini_Inject_calibration_constants_from_h5files.ipynb index 215a52eb09bab2be5739e3027f7af306a85a81a8..53bb19aac9effb20b80b132a33a5c14b0ea4ecc0 100644 --- a/notebooks/LPDMini/LPD_Mini_Inject_calibration_constants_from_h5files.ipynb +++ b/notebooks/LPDMini/LPD_Mini_Inject_calibration_constants_from_h5files.ipynb @@ -9,7 +9,11 @@ "\n", "Author: European XFEL Detector Group, Version: 1.0\n", "\n", - "Reading h5files of LPD Mini's calibration constants to inject them to the database." + "This notebook is used to read HDF5 files with LPDMINI constants to inject into the CALCAT database.\n", + "\n", + "The notebook expects an explicit filename format: <calibration_constant_name>_<karabo_da>.h5 for example `RelativeGain_LPDMINI00_2.h5`\n", + " - <calibration_constant_name>: The calibration name as it is named in CALCAT.\n", + " - <karabo_da>: The data aggregator name. As LPDMini aggregators have `/` we replace it with `_`." ] }, { @@ -27,7 +31,7 @@ "\n", "# detector parameters:\n", "karabo_id = \"FXE_DET_LPD_MINI\" # detector identifier.\n", - "karabo_da = [\"all\"] # karabo data aggregators. default \"all\" for all 8 karabo data aggregator names.\n", + "karabo_da = [\"\"] # karabo data aggregators. default \"all\" for all 8 karabo data aggregator names.\n", "\n", "# calibration database parameters:\n", "cal_db_interface = \"tcp://max-exfl016:8015#8045\" # calibration DB zmq address.\n", @@ -38,7 +42,7 @@ "bias_voltage_1 = 250 # bias voltage for minis 2, 4, 6, 8\n", "capacitor = 5 # capacitor value. Used for constant conditions.\n", "photon_energy = 9.2 # calibration constant photon energy. Used for constant conditions.\n", - "creation_time = '2020-01-20T14:12:06' # creation time for the injected constants. required format '2019-01-20T14:12:06'" + "creation_time = '2023-05-07T15:10:07' # creation time for the injected constants. required format '2019-01-20T14:12:06'" ] }, { @@ -56,7 +60,7 @@ "import h5py\n", "from cal_tools.calcat_interface import CalCatApi\n", "from cal_tools.restful_config import calibration_client\n", - "from cal_tools.tools import get_pdu_from_db, get_report, send_to_db\n", + "from cal_tools.tools import get_report, send_to_db\n", "from iCalibrationDB import Conditions, Constants" ] }, @@ -76,7 +80,7 @@ "detector_id = calcat.detector(karabo_id)['id']\n", "pdus_by_da = calcat.physical_detector_units(detector_id, pdu_snapshot_at=creation_time)\n", "\n", - "if not karabo_da or karabo_da == ['']:\n", + "if not karabo_da or karabo_da == [\"\"]:\n", " karabo_da = sorted(pdus_by_da.keys())\n", "else:\n", " karabo_da = karabo_da\n", @@ -214,28 +218,8 @@ " default_path=report_name\n", ")\n", "\n", - "# Calibration constants condition object.\n", - "condition = Conditions.Illuminated.LPD(\n", - " memory_cells=memory_cells,\n", - " bias_voltage=bias_voltage_0,\n", - " photon_energy=photon_energy,\n", - " pixels_x=pixels_x,\n", - " pixels_y=pixels_y,\n", - " capacitor=capacitor,\n", - " category=None,\n", - ")\n", - "\n", - "# Retrieve all physical detector units for the given karabo_da list.\n", - "physical_units = get_pdu_from_db(\n", - " karabo_id=karabo_id,\n", - " karabo_da=karabo_da,\n", - " constant=getattr(Constants.LPD, constant_names[0])(),\n", - " condition=condition,\n", - " cal_db_interface=cal_db_interface,\n", - " snapshot_at=creation_time\n", - ")\n", "\n", - "mod_mapping = dict(zip(karabo_da, physical_units))\n", + "mod_mapping = {mod: pdus_by_da[mod][\"physical_name\"] for mod in karabo_da}\n", "print(\"Physical detector units retrieved are: \", mod_mapping, \"\\n\")\n", "\n", "inp = []\n",