From bfbfb42ac834d06cf22467110aefece57b5e217a Mon Sep 17 00:00:00 2001
From: ahmedk <karim.ahmed@xfel.eu>
Date: Tue, 26 Jul 2022 16:32:08 +0200
Subject: [PATCH] AGIPD FF: enable using different memory cells that the value
 of the RAW data

---
 ...aracterize_AGIPD_Gain_FlatFields_NBC.ipynb | 13 ++++++------
 ...terize_AGIPD_Gain_FlatFields_Summary.ipynb | 20 +++++++++----------
 2 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/notebooks/AGIPD/Characterize_AGIPD_Gain_FlatFields_NBC.ipynb b/notebooks/AGIPD/Characterize_AGIPD_Gain_FlatFields_NBC.ipynb
index fab1aa797..7c49c3c89 100644
--- a/notebooks/AGIPD/Characterize_AGIPD_Gain_FlatFields_NBC.ipynb
+++ b/notebooks/AGIPD/Characterize_AGIPD_Gain_FlatFields_NBC.ipynb
@@ -65,12 +65,13 @@
     "sigma_limit = 0. # If >0, repeat fit keeping only bins within mu +- sigma_limit*sigma\n",
     "\n",
     "# Detector conditions\n",
-    "max_cells = 0 # number of memory cells used, set to 0 to automatically infer\n",
-    "bias_voltage = 300  # Bias voltage\n",
-    "acq_rate = 0. # the detector acquisition rate, use 0 to try to auto-determine\n",
-    "gain_setting = 0.1 # the gain setting, use 0.1 to try to auto-determine\n",
-    "photon_energy = 8.05 # photon energy in keV\n",
-    "integration_time = -1 # integration time, negative values for auto-detection."
+    "# NOTE: The below parameters are needed for the summary notebook when running through xfel-calibrate.\n",
+    "mem_cells = -1  # number of memory cells used, negative values for auto-detection. \n",
+    "bias_voltage = 300  # Bias voltage. \n",
+    "acq_rate = 0.  # the detector acquisition rate, use 0 to try to auto-determine.\n",
+    "gain_setting = -1  # the gain setting, negative values for auto-detection.\n",
+    "photon_energy = 8.05  # photon energy in keV.\n",
+    "integration_time = -1  # integration time, negative values for auto-detection."
    ]
   },
   {
diff --git a/notebooks/AGIPD/Characterize_AGIPD_Gain_FlatFields_Summary.ipynb b/notebooks/AGIPD/Characterize_AGIPD_Gain_FlatFields_Summary.ipynb
index 5eb1eb2b8..fd9a71161 100644
--- a/notebooks/AGIPD/Characterize_AGIPD_Gain_FlatFields_Summary.ipynb
+++ b/notebooks/AGIPD/Characterize_AGIPD_Gain_FlatFields_Summary.ipynb
@@ -51,12 +51,12 @@
     "\n",
     "\n",
     "# Detector conditions\n",
-    "max_cells = 0 # number of memory cells used, set to 0 to automatically infer\n",
-    "bias_voltage = 0. # Bias voltage\n",
-    "acq_rate = 0. # the detector acquisition rate, use 0 to try to auto-determine\n",
-    "gain_setting = -1 # the gain setting, use 0.1 to try to auto-determine\n",
-    "photon_energy = 8.05 # photon energy in keV\n",
-    "integration_time = -1 # integration time, negative values for auto-detection."
+    "mem_cells = -1  # number of memory cells used, negative values for auto-detection.\n",
+    "bias_voltage = 0.  # Bias voltage\n",
+    "acq_rate = 0.  # the detector acquisition rate, use 0 to try to auto-determine\n",
+    "gain_setting = -1  # the gain setting, negative values for auto-detection.\n",
+    "photon_energy = 8.05  # photon energy in keV\n",
+    "integration_time = -1  # integration time, negative values for auto-detection."
    ]
   },
   {
@@ -144,17 +144,17 @@
     "    ctrl_src=ctrl_src,\n",
     "    raise_error=False,  # to be able to process very old data without mosetting value\n",
     ")\n",
-    "\n",
-    "mem_cells = agipd_cond.get_num_cells()\n",
+    "if mem_cells < 0:\n",
+    "    mem_cells = agipd_cond.get_num_cells()\n",
     "if mem_cells is None:\n",
     "    raise ValueError(f\"No raw images found in {run_folder}\")\n",
     "if acq_rate == 0.:\n",
     "    acq_rate = agipd_cond.get_acq_rate()\n",
-    "if gain_setting == -1:\n",
+    "if gain_setting < 0:\n",
     "    gain_setting = agipd_cond.get_gain_setting(creation_time)\n",
     "if bias_voltage == 0.:\n",
     "    bias_voltage = agipd_cond.get_bias_voltage(karabo_id_control)\n",
-    "if integration_time == -1:\n",
+    "if integration_time < 0:\n",
     "    integration_time = agipd_cond.get_integration_time()\n",
     "\n",
     "# Evaluate detector instance for mapping\n",
-- 
GitLab