diff --git a/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb b/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb index d664b2c46735ed78dee5ed095c987fa51d36408c..9b2c4eda88b396d667b36cc5bf6412c16448ed48 100644 --- a/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb +++ b/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb @@ -116,6 +116,7 @@ "from cal_tools.tools import (\n", " get_dir_creation_date,\n", " get_from_db,\n", + " get_pdu_from_db,\n", " get_random_db_interface,\n", " get_report,\n", " map_gain_stages,\n", @@ -565,36 +566,6 @@ "report = get_report(out_folder)" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# TODO: add db_module when received from myMDC\n", - "# Create the modules dict of karabo_das and PDUs\n", - "qm_dict = OrderedDict()\n", - "for i, k_da in zip(modules, karabo_da):\n", - " qm = module_index_to_qm(i)\n", - " qm_dict[qm] = {\"karabo_da\": k_da}\n", - "\n", - "# gets pdu, karabo_da, and qm for all modules at snapshot\n", - "all_pdus = iCalibrationDB.ConstantMetaData().retrieve_pdus_for_detector(\n", - " karabo_id=karabo_id,\n", - " receiver=cal_db_interface,\n", - " snapshot_at=creation_time.isoformat(),\n", - " timeout=cal_db_timeout\n", - ")\n", - "# used to add db_module in qm_dict\n", - "qm_to_pdu = {d[\"virtual_device_name\"]: d[\"pdu_physical_name\"] for d in all_pdus}\n", - "for qm, qm_attr in qm_dict.items():\n", - " db_module = qm_to_pdu[qm]\n", - " qm_attr[\"db_module\"] = db_module\n", - " # saving mapping information for summary notebook\n", - " with open(f\"{out_folder}/module_mapping_{qm}.yml\", \"w\") as fd:\n", - " yaml.safe_dump({\"module_mapping\": {qm: db_module}}, fd)" - ] - }, { "cell_type": "code", "execution_count": null, @@ -612,6 +583,34 @@ ")" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Create mapping from module(s) (qm) to karabo_da(s) and PDU(s)\n", + "qm_dict = OrderedDict()\n", + "all_pdus = get_pdu_from_db(\n", + " karabo_id,\n", + " karabo_da,\n", + " constant=iCalibrationDB.CalibrationConstant(),\n", + " condition=condition,\n", + " cal_db_interface=cal_db_interface,\n", + " snapshot_at=creation_time.isoformat(),\n", + " timeout=cal_db_timeout\n", + " )\n", + "for module_index, module_da, module_pdu in zip(modules, karabo_da, all_pdus):\n", + " qm = module_index_to_qm(module_index)\n", + " qm_dict[qm] = {\n", + " \"karabo_da\": module_da,\n", + " \"db_module\": module_pdu\n", + " }\n", + " # saving mapping information for summary notebook\n", + " with open(f\"{out_folder}/module_mapping_{qm}.yml\", \"w\") as fd:\n", + " yaml.safe_dump({\"module_mapping\": {qm: module_pdu}}, fd)" + ] + }, { "cell_type": "code", "execution_count": null,