diff --git a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb index f095b97ae6a09efa97c880ae72ec153d4e2c0dbc..884076591bb1da22cd0091719a04ea7e3eac8d31 100644 --- a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb +++ b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb @@ -116,6 +116,7 @@ "spi_hf_min_scores = 100 # The minimal size of events to compute adaptive threshold in SPI hitfinding\n", "spi_hf_fixed_threshold = 0 # The fixed threshold value\n", "spi_hf_hitrate_window_size = 200 # The window size for runnig average of hitrate in trains\n", + "spi_hf_xgm_norm = False # Use XGM pulse energy for hitscore normalization\n", "spi_hf_miss_fraction = 1 # The fraction of misses to select along with hits\n", "spi_hf_miss_fraction_base = \"hit\" # The base to compute the number of misses to select: the number of hits (`hit`) or misses (`miss`)\n", "\n", diff --git a/notebooks/AGIPD/AGIPD_Correct_and_Verify_Summary_NBC.ipynb b/notebooks/AGIPD/AGIPD_Correct_and_Verify_Summary_NBC.ipynb index d33ae9d818836db00e7b3614c0d205497b10d58f..c6562774d625dbb5ee47bff806aa34230adbdd47 100644 --- a/notebooks/AGIPD/AGIPD_Correct_and_Verify_Summary_NBC.ipynb +++ b/notebooks/AGIPD/AGIPD_Correct_and_Verify_Summary_NBC.ipynb @@ -14,6 +14,7 @@ "outputs": [], "source": [ "run = 11 # runs to process, required\n", + "in_folder = \"/gpfs/exfel/exp/MID/202201/p002834/raw\" # the folder to read data from, required\n", "out_folder = \"/gpfs/exfel/data/scratch/ahmedk/test/AGIPD_Corr\" # path to output to, required\n", "metadata_folder = \"\" # Directory containing calibration_metadata.yml when run by xfel-calibrate\n", "karabo_id = \"SPB_DET_AGIPD1M-1\" # karabo karabo_id\n", @@ -31,8 +32,13 @@ "spi_hf_min_scores = 100 # The minimal size of events to compute adaptive threshold in SPI hitfinding\n", "spi_hf_fixed_threshold = 0 # The fixed threshold value\n", "spi_hf_hitrate_window_size = 200 # The window size for runnig average of hitrate in trains\n", + "spi_hf_xgm_norm = False # Use XGM pulse energy for hitscore normalization\n", "spi_hf_miss_fraction = 1 # The fraction of misses to select along with hits\n", - "spi_hf_miss_fraction_base = \"hit\" # The base to compute the number of misses to select: the number of hits (`hit`) or misses (`miss`)" + "spi_hf_miss_fraction_base = \"hit\" # The base to compute the number of misses to select: the number of hits (`hit`) or misses (`miss`)\n", + "\n", + "# Lit-frame finder\n", + "use_litframe_finder = 'off' # Process only illuminated frames: 'off' - disable, 'device' - use online device data, 'offline' - use offline algorithm, 'auto' - choose online/offline source automatically (default)\n", + "litframe_device_id = '' # Device ID for a lit frame finder device, empty string to auto detection" ] }, { @@ -150,6 +156,30 @@ "if spi_hitfinding and count_lit_pixels:\n", " display(Markdown(\"# SPI hit finding\"))\n", "\n", + " litfrm_src = None\n", + " if use_litframe_finder != 'off':\n", + " from extra_redu import make_litframe_finder, LitFrameFinderError\n", + " from extra_redu.fileutils import PulseSource\n", + "\n", + " dc = RunDirectory(Path(in_folder) / f'r{run:04d}')\n", + " litfrm = make_litframe_finder(karabo_id[:3], dc, litframe_device_id)\n", + " try:\n", + " get_data = {\n", + " 'auto': litfrm.read_or_process,\n", + " 'offline': litfrm.process,\n", + " 'online': litfrm.read\n", + " }\n", + " r = get_data[use_litframe_finder]()\n", + " litfrm_src = PulseSource(\n", + " r.meta.trainId, r.output.nFrame,\n", + " r.output.detectorPulseId.ravel(),\n", + " {\n", + " \"energyPerFrame\": r.output.energyPerFrame.ravel(),\n", + " }\n", + " )\n", + " except LitFrameFinderError as err:\n", + " pass\n", + "\n", " dc = RunDirectory(out_folder)\n", " litpx_src = StackedPulseSource.from_datacollection(\n", " dc, f\"{karabo_id}/CORR/(?P<key>\\d+)CH0:output\", \"litpx\")\n", @@ -161,10 +191,11 @@ " min_scores=spi_hf_min_scores,\n", " fixed_threshold=spi_hf_fixed_threshold,\n", " hitrate_window_size=spi_hf_hitrate_window_size,\n", + " xgm_norm=spi_hf_xgm_norm,\n", " miss_fraction=spi_hf_miss_fraction,\n", " miss_fraction_base=spi_hf_miss_fraction_base,\n", " )\n", - " hitfinder.find_hits(litpx_src)\n", + " hitfinder.find_hits(litpx_src, litfrm_src)\n", "\n", " # write hit-finder data in file\n", " sources = {\n", diff --git a/setup.py b/setup.py index aec41c827f536a2df66f6e1042469ea2531931dc..f0a67b6268c1b407656fc448ac55cebaca9aad27 100644 --- a/setup.py +++ b/setup.py @@ -102,7 +102,7 @@ install_requires = [ "tabulate==0.9.0", "traitlets==5.14.1", "xarray==2024.2.0", - "EXtra-redu==1.0.0", + "EXtra-redu==1.0.1", "rich==13.7.0", "httpx==0.27.0", ]