diff --git a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb index 03f5dc521c66216de93efc0e1ff23b5a728350b0..e1940696b246d82dd29bb5bb256aa11db1c290cc 100644 --- a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb +++ b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb @@ -154,9 +154,6 @@ "sns.set_context(\"paper\", font_scale=1.4)\n", "sns.set_style(\"ticks\")\n", "\n", - "from extra_redu import make_litframe_finder\n", - "from extra_redu.litfrm.utils import litfrm_run_report\n", - "\n", "import cal_tools\n", "import seaborn as sns\n", "from cal_tools import agipdalgs as calgs\n", @@ -455,29 +452,34 @@ "outputs": [], "source": [ "if use_litframe_finder != 'off':\n", + " from extra_redu import make_litframe_finder\n", + " from extra_redu.litfrm.utils import litfrm_run_report\n", + "\n", " if use_litframe_finder not in ['auto', 'offline', 'online']:\n", " raise ValueError(\"Unexpected value in 'use_litframe_finder'.\")\n", "\n", " inst = karabo_id_control[:3]\n", " litfrm = make_litframe_finder(inst, dc, litframe_device_id)\n", " try:\n", - " if use_litframe_finder != 'auto':\n", + " if use_litframe_finder == 'auto':\n", " r = litfrm.read_or_process()\n", - " elif use_litframe_finder != 'offline':\n", + " elif use_litframe_finder == 'offline':\n", " r = litfrm.process()\n", - " elif use_litframe_finder != 'online':\n", + " elif use_litframe_finder == 'online':\n", " r = litfrm.read()\n", "\n", " report = litfrm_run_report(r)\n", " print(\"Lit-frame patterns:\")\n", + " print(\" # trains Np Nd Nf lit frames\")\n", " for rec in report:\n", " frmintf = ', '.join(\n", - " [':'.join([str(n) for n in slc]) for slc in rec[6]]\n", + " [':'.join([str(n) for n in slc]) for slc in rec['frames']]\n", " )\n", - " trsintf = ':'.join([str(n) for n in rec[2]])\n", + " trsintf = ':'.join([str(n) for n in rec['trains']])\n", " print(\n", - " f\"{rec[1]:2d} {trsintf:25s} {rec[3]:4d} {rec[4]:3d} \"\n", - " f\"{rec[5]:3d} [{frmintf}]\"\n", + " (\"{pattern_no:2d} {trsintf:25s} {npulse:4d} \"\n", + " \"{ndataframe:3d} {nframe:3d} [{frmintf}]\"\n", + " ).format(frmintf=frmintf, trsintf=trsintf, **rec)\n", " )\n", " cell_sel = LitFrameSelection(r, train_ids, max_pulses, energy_threshold)\n", " except Exception as err:\n", diff --git a/src/cal_tools/agipdlib.py b/src/cal_tools/agipdlib.py index 2d6e8ab9f802fe798e9161b047868f33f104bd73..cb7d83a20b8702e4d280f6392301009070b72497 100644 --- a/src/cal_tools/agipdlib.py +++ b/src/cal_tools/agipdlib.py @@ -1591,7 +1591,9 @@ class LitFrameSelection(CellSelection): """Selection of detector memery cells indicated as lit frames by the AgipdLitFrameFinder """ - def __init__(self, litfrmdata, train_ids: List[int], + def __init__(self, + litfrmdata: 'AgipdLitFrameFinderOffline', + train_ids: List[int], crange: Optional[List[int]] = None, energy_threshold: Optional[float] = None): """Initialize lit frame selection