From e177ef48bc4254ade3589c3869cdec12fac722fd Mon Sep 17 00:00:00 2001 From: David Hammer <dhammer@mailbox.org> Date: Fri, 28 May 2021 10:27:16 +0200 Subject: [PATCH] Re-fix path saving --- .../Characterize_AGIPD_Gain_Darks_NBC.ipynb | 52 +++++++------------ 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb b/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb index 181d4e053..86b6821ed 100644 --- a/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb +++ b/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb @@ -566,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, @@ -674,6 +644,8 @@ "\n", " if mdata is None or data is None:\n", " timestamp = \"Not found\"\n", + " filepath = None\n", + " h5path = None\n", " else:\n", " timestamp = mdata.calibration_constant_version.begin_at.isoformat()\n", " filepath = os.path.join(\n", @@ -888,9 +860,13 @@ "old_mdata = {}\n", "old_retrieval_res.wait()\n", "\n", - "for (qm, const), (data, timestamp) in zip(qm_x_const, old_retrieval_res.get()):\n", + "for (qm, const), (data, timestamp, filepath, h5path) in zip(qm_x_const, old_retrieval_res.get()):\n", " old_const.setdefault(qm, {})[const] = data\n", - " old_mdata.setdefault(qm, {})[const] = timestamp" + " old_mdata.setdefault(qm, {})[const] = {\n", + " \"timestamp\": timestamp,\n", + " \"filepath\": filepath,\n", + " \"h5path\": h5path\n", + " }" ] }, { @@ -903,7 +879,17 @@ "for qm, consts in old_mdata.items():\n", " display(Markdown(f\"- {qm}\"))\n", " for const in consts:\n", - " display(Markdown(f\" - {const} at {consts[const]}\"))" + " display(Markdown(f\" - {const} at {consts[const]['timestamp']}\"))\n", + " # saving locations of old constants for summary notebook\n", + " with open(f\"{out_folder}/module_metadata_{qm}.yml\", \"w\") as fd:\n", + " yaml.safe_dump(\n", + " {\n", + " \"module\": qm,\n", + " \"pdu\": qm_dict[qm][\"db_module\"],\n", + " \"old-constants\": old_mdata[qm]\n", + " },\n", + " fd,\n", + " )" ] }, { -- GitLab