From a324b12f9a3c26715b26ee1e76d1e9a47627cd06 Mon Sep 17 00:00:00 2001 From: David Hammer <dhammer@mailbox.org> Date: Thu, 18 Mar 2021 12:25:04 +0100 Subject: [PATCH] Cleanup --- ...IPD_Retrieve_Constants_Precorrection.ipynb | 39 ++++++------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/notebooks/AGIPD/AGIPD_Retrieve_Constants_Precorrection.ipynb b/notebooks/AGIPD/AGIPD_Retrieve_Constants_Precorrection.ipynb index f6b40e513..664f20837 100644 --- a/notebooks/AGIPD/AGIPD_Retrieve_Constants_Precorrection.ipynb +++ b/notebooks/AGIPD/AGIPD_Retrieve_Constants_Precorrection.ipynb @@ -51,7 +51,7 @@ "xray_gain = True # do relative gain correction based on xray data\n", "blc_noise = False # if set, baseline correction via noise peak location is attempted\n", "blc_stripes = False # if set, baseline corrected via stripes\n", - "blc_hmatch = False # if set, base line correction via histogram matching is attempted \n", + "blc_hmatch = False # if set, base line correction via histogram matching is attempted\n", "match_asics = False # if set, inner ASIC borders are matched to the same signal level\n", "adjust_mg_baseline = False # adjust medium gain baseline to match highest high gain value" ] @@ -205,14 +205,11 @@ "outputs": [], "source": [ "def retrieve_constants(\n", - " qm_files: List[Path],\n", - " qm: str,\n", - " karabo_da: str,\n", - " idx: int\n", + " qm_files: List[Path], qm: str, karabo_da: str, idx: int\n", ") -> Tuple[str, str, float, float, str, dict]:\n", " \"\"\"\n", " Retrieve constants for a module.\n", - " \n", + "\n", " :return:\n", " qm: module virtual name i.e. Q1M1.\n", " karabo_da: karabo data aggregator.\n", @@ -236,7 +233,7 @@ " if local_max_cells is None:\n", " raise ValueError(f\"No raw images found for {qm} for all sequences\")\n", "\n", - " if acq_rate == 0: \n", + " if acq_rate == 0:\n", " local_acq_rate = agipdlib.get_acq_rate(fast_paths=(f, karabo_id, idx))\n", " else:\n", " local_acq_rate = acq_rate\n", @@ -244,7 +241,7 @@ " # avoid retrieving constant, if requested.\n", " if nodb_with_dark:\n", " return\n", - " \n", + "\n", " const_dict = agipdlib.assemble_constant_dict(\n", " corr_bools,\n", " pc_bools,\n", @@ -359,13 +356,11 @@ "source": [ "mod_dev = dict()\n", "mdata_dict = dict()\n", - "for r in results:\n", - " if r:\n", - " qm, md_dict, karabo_da, acq_rate, max_cells, err = r\n", - " mod_dev[karabo_da] = {\"mod\": qm, \"err\": err}\n", - " if err:\n", - " print(f\"Error for module {qm}: {err}\")\n", - " mdata_dict[karabo_da] = md_dict\n", + "for qm, md_dict, karabo_da, acq_rate, max_cells, err in results:\n", + " mod_dev[karabo_da] = {\"mod\": qm, \"err\": err}\n", + " if err:\n", + " print(f\"Error for module {qm}: {err}\")\n", + " mdata_dict[karabo_da] = md_dict\n", "# check if it is requested not to retrieve any constants from the database\n", "if nodb_with_dark:\n", " print(\"No constants were retrieved as calibrated files will be used.\")\n", @@ -390,12 +385,11 @@ "metadata": {}, "outputs": [], "source": [ - "print(\"Constants are retrieved with creation time: \")\n", - "i = 0\n", + "print(\"Constants are retrieved with creation time:\")\n", "timestamps = {}\n", "\n", "for k_da, dinfo in mod_dev.items():\n", - " print(dinfo[\"mod\"], \":\")\n", + " print(f\"{dinfo['mod']}:\")\n", " module_timestamps = {}\n", " module_name = dinfo[\"mod\"]\n", " if k_da in mdata_dict:\n", @@ -403,8 +397,6 @@ " if hasattr(mdata[\"creation-time\"], 'strftime'):\n", " mdata[\"creation-time\"] = mdata[\"creation-time\"].strftime('%y-%m-%d %H:%M')\n", " print(f'{cname:.<12s}', mdata[\"creation-time\"])\n", - " # Store few time stamps if exists\n", - " # Add NA to keep array structure\n", " for cname in ['Offset', 'SlopesPC', 'SlopesFF']:\n", " if k_da not in mdata_dict or dinfo[\"err\"]:\n", " module_timestamps[cname] = \"Err\"\n", @@ -418,13 +410,6 @@ " module_timestamps[cname] = \"NA\"\n", " timestamps[module_name] = module_timestamps\n", "\n", - " i += 1\n", - " if sequences:\n", - " seq_num = sequences[0]\n", - " else:\n", - " # if sequences[0] changed to None as it was -1\n", - " seq_num = 0\n", - "\n", "time_summary = metadata.setdefault(\"retrieved-constants\", {}).setdefault(\"time-summary\", {})\n", "time_summary[\"SAll\"] = timestamps\n", "\n", -- GitLab