diff --git a/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb b/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb index 90492a174708ca576846ba7e199dd06d96603a54..bb9cf91e0fd39a9f29c4d78a821dce6ad42b91fb 100644 --- a/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb +++ b/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb @@ -116,7 +116,6 @@ "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", @@ -569,6 +568,52 @@ "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] = {\n", + " \"karabo_da\": k_da,\n", + " \"db_module\": \"\"\n", + " }\n", + "\n", + "# going through tools.get_pdu_from_db seems wasteful\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", + "karabo_da_to_pdu = {d[\"karabo_da\"]: d[\"pdu_physical_name\"] for d in all_pdus}\n", + "for qm_attr in qm_dict.values():\n", + " qm_attr[\"db_module\"] = karabo_da_to_pdu[qm_attr[\"karabo_da\"]]\n", + "for pdu_dict in all_pdus:\n", + " this_karabo_da = pdu_dict[\"karabo_da\"]\n", + " if this_karabo_da in qm_dict:\n", + " qm_dict[this_karabo_da][\"db_module\"] = pdu_dict[\"pdu_physical_name\"]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "with open(f\"{out_folder}/module_mapping.yml\",\"w\") as fd:\n", + " yaml.safe_dump({\n", + " \"module_mapping\": {\n", + " qm: qm_dict[qm][\"db_module\"] for qm in qm_dict\n", + " }\n", + " }, fd)" + ] + }, { "cell_type": "code", "execution_count": null,