From 50fe51c62ff349c11798c003eab25060791e6285 Mon Sep 17 00:00:00 2001
From: karnem <mikhail.karnevskiy@desy.de>
Date: Wed, 4 Sep 2019 19:34:53 +0200
Subject: [PATCH] Use spShape for plotting

---
 cal_tools/cal_tools/ana_tools.py                  |  3 +--
 notebooks/AGIPD/PlotFromCalDB_AGIPD_NBC.ipynb     | 10 +++++-----
 notebooks/FastCCD/PlotFromCalDB_FastCCD_NBC.ipynb |  3 ++-
 notebooks/LPD/PlotFromCalDB_LPD_NBC.ipynb         |  9 +++------
 4 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/cal_tools/cal_tools/ana_tools.py b/cal_tools/cal_tools/ana_tools.py
index dce75cf70..83ee3a30f 100644
--- a/cal_tools/cal_tools/ana_tools.py
+++ b/cal_tools/cal_tools/ana_tools.py
@@ -354,8 +354,7 @@ class HMType(Enum):
 
 def get_range(data, scale):
     """
-    Get range, which includes most of the data points.
-    Range is calculated in units of median absolute deviations
+    Return a range calculated by median absolute deviations
 
     :param data: numpy.array of data points
     :param scale: range in units of median absolute deviations
diff --git a/notebooks/AGIPD/PlotFromCalDB_AGIPD_NBC.ipynb b/notebooks/AGIPD/PlotFromCalDB_AGIPD_NBC.ipynb
index e3efb528a..09e8c0160 100644
--- a/notebooks/AGIPD/PlotFromCalDB_AGIPD_NBC.ipynb
+++ b/notebooks/AGIPD/PlotFromCalDB_AGIPD_NBC.ipynb
@@ -32,10 +32,10 @@
     "constants = [\"Noise\", \"SlopesFF\", \"SlopesPC\", \"Offset\"]  # Constants to plot\n",
     "modules = [1]  # Modules, set to -1 for all, range allowed\n",
     "bias_voltages = [300, 500]  # Bias voltage\n",
-    "mem_cells = [128, 176, 250]  # Number of used memory cells. Typically: 4,32,64,128,176.\n",
-    "acquisition_rate = [None]\n",
+    "mem_cells = [128, 176, 202, 250]  # Number of used memory cells. Typically: 4,32,64,128,176.\n",
+    "acquisition_rate = [None, 1.1, 2.2, 4.5]\n",
     "photon_energy = 9.2  # Photon energy of the beam\n",
-    "out_folder = \"/gpfs/exfel/data/scratch/karnem/testAGIPD16_25/\"  # Output folder, required\n",
+    "out_folder = \"/gpfs/exfel/data/scratch/karnem/test_AGIPD/\"  # Output folder, required\n",
     "use_existing = \"\" # If not empty, constants stored in given folder will be used\n",
     "cal_db_timeout = 120000 # timeout on caldb requests\",\n",
     "adu_to_photon = 33.17 # ADU to photon conversion factor (8000 / 3.6 / 67.)\n",
@@ -591,8 +591,8 @@
     "                    rdata['MeanBP'][rdata['MeanBP'] < 0.1] = np.nan\n",
     "\n",
     "            if 'NBP' in rdata:\n",
-    "                rdata[\"NBP\"][rdata[\"NBP\"] == 4096] = np.nan\n",
-    "                rdata[\"NBP\"] = rdata[\"NBP\"] / (64 * 64) * 100\n",
+    "                rdata[\"NBP\"][rdata[\"NBP\"] == (spShape[0] * spShape[1])] = np.nan\n",
+    "                rdata[\"NBP\"] = rdata[\"NBP\"] / (spShape[0] * spShape[1]) * 100\n",
     "\n",
     "            # Reshape: ASICs over cells for plotting\n",
     "            pdata = {}\n",
diff --git a/notebooks/FastCCD/PlotFromCalDB_FastCCD_NBC.ipynb b/notebooks/FastCCD/PlotFromCalDB_FastCCD_NBC.ipynb
index 1bd8c1792..b0b88ecd6 100644
--- a/notebooks/FastCCD/PlotFromCalDB_FastCCD_NBC.ipynb
+++ b/notebooks/FastCCD/PlotFromCalDB_FastCCD_NBC.ipynb
@@ -35,7 +35,7 @@
     "parameter_names = ['bias_voltage', 'integration_time', 'temperature', \n",
     "                   'gain_setting', 'pixels_x', 'pixels_y'] # names of parameters\n",
     "photon_energy = 9.2 # Photon energy of the beam\n",
-    "out_folder = \"/gpfs/exfel/data/scratch/karnem/test_FCCD6/\" # output folder\n",
+    "out_folder = \"/gpfs/exfel/data/scratch/karnem/test_FCCD/\" # output folder\n",
     "use_existing = \"\" # If not empty, constants stored in given folder will be used\n",
     "cal_db_interface = \"tcp://max-exfl016:8015#8025\" # the database interface to use\n",
     "cal_db_timeout = 180000 # timeout on caldb requests\",\n",
@@ -443,6 +443,7 @@
     "                    rdata['MeanBP'][rdata['MeanBP'] < 0.1] = np.nan\n",
     "                    \n",
     "            if 'NBP' in rdata:\n",
+    "                rdata[\"NBP\"][rdata[\"NBP\"] == (spShape[0] * spShape[1])] = np.nan\n",
     "                rdata[\"NBP\"] = rdata[\"NBP\"] / spShape[0] / spShape[1] * 100\n",
     "\n",
     "            # Reshape: ASICs over cells for plotting\n",
diff --git a/notebooks/LPD/PlotFromCalDB_LPD_NBC.ipynb b/notebooks/LPD/PlotFromCalDB_LPD_NBC.ipynb
index a9471e229..d30fc84ba 100644
--- a/notebooks/LPD/PlotFromCalDB_LPD_NBC.ipynb
+++ b/notebooks/LPD/PlotFromCalDB_LPD_NBC.ipynb
@@ -34,7 +34,7 @@
     "bias_voltages = [250, 500]  # Bias voltage\n",
     "mem_cells = [128, 256, 512]  # Number of used memory cells.\n",
     "photon_energy = 9.2  # Photon energy of the beam\n",
-    "out_folder = \"/gpfs/exfel/data/scratch/karnem/testLPD_11/\"  # Output folder, required\n",
+    "out_folder = \"/gpfs/exfel/data/scratch/karnem/test_LPD/\"  # Output folder, required\n",
     "use_existing = \"\" # If not empty, constants stored in given folder will be used\n",
     "cal_db_timeout = 180000 # timeout on caldb requests\",\n",
     "adu_to_photon = 33.17 # ADU to photon conversion factor (8000 / 3.6 / 67.)\n",
@@ -171,7 +171,6 @@
     "                           meta_only=True,\n",
     "                           version_info=True)\n",
     "\n",
-    "        print(data)\n",
     "        # Request BP constant versions\n",
     "        print('constantDark:', constantsDark[const], )        \n",
     "        dataBP = get_from_db(getattr(det, pars['module']),\n",
@@ -185,8 +184,6 @@
     "                             meta_only=True,\n",
     "                             version_info=True)\n",
     "        \n",
-    "        print('BP!!!!!', dataBP)\n",
-    "        \n",
     "        if not isinstance(data, list) or not isinstance(dataBP, list):\n",
     "            continue\n",
     "            \n",
@@ -581,8 +578,8 @@
     "                    rdata['MeanBP'][rdata['MeanBP'] < 0.1] = np.nan\n",
     "\n",
     "            if 'NBP' in rdata:\n",
-    "                rdata[\"NBP\"][rdata[\"NBP\"] == 4096] = np.nan\n",
-    "                rdata[\"NBP\"] = rdata[\"NBP\"] / (64 * 64) * 100\n",
+    "                rdata[\"NBP\"][rdata[\"NBP\"] == (spShape[0] * spShape[1])] = np.nan\n",
+    "                rdata[\"NBP\"] = rdata[\"NBP\"] / (spShape[0] * spShape[1]) * 100\n",
     "\n",
     "            # Reshape: ASICs over cells for plotting\n",
     "            pdata = {}\n",
-- 
GitLab