From 73078d9f24af678cdc70f2467c38371b3e44d8b5 Mon Sep 17 00:00:00 2001
From: ahmedk <karim.ahmed@xfel.eu>
Date: Thu, 21 Jul 2022 11:24:19 +0200
Subject: [PATCH] Remove np.nan assignment to uint array and remove unneeded
 uint32 conversion

---
 notebooks/LPD/LPDChar_Darks_NBC.ipynb | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/notebooks/LPD/LPDChar_Darks_NBC.ipynb b/notebooks/LPD/LPDChar_Darks_NBC.ipynb
index 1419df343..1122d39ea 100644
--- a/notebooks/LPD/LPDChar_Darks_NBC.ipynb
+++ b/notebooks/LPD/LPDChar_Darks_NBC.ipynb
@@ -722,7 +722,6 @@
     "                title = '{} value'.format(const)\n",
     "                if const == 'BadPixelsDark':\n",
     "                    vmax = 4\n",
-    "                    data[data == 0] = np.nan\n",
     "                    title = 'Bad pixel code'\n",
     "                    label = title\n",
     "\n",
@@ -1153,17 +1152,16 @@
     "            l_data_old = []\n",
     "            \n",
     "            data = np.copy(res[cap][qm]['BadPixelsDark'][:,:,:,gain])\n",
-    "            datau32 = data.astype(np.uint32)\n",
-    "            l_data.append(len(datau32[datau32>0].flatten()))\n",
+    "            l_data.append(len(data[data>0].flatten()))\n",
     "            for bit in bits:\n",
-    "                l_data.append(np.count_nonzero(badpix_g[cap][qm][:,:,:,gain].astype(np.uint32) & bit.value))\n",
+    "                l_data.append(np.count_nonzero(badpix_g[cap][qm][:,:,:,gain] & bit.value))\n",
     "            \n",
     "            if old_const[cap][qm]['BadPixelsDark'] is not None:\n",
+    "                old_const[cap][qm]['BadPixelsDark'] = old_const[cap][qm]['BadPixelsDark'].astype(np.float32)\n",
     "                dataold = np.copy(old_const[cap][qm]['BadPixelsDark'][:, :, :, gain])\n",
-    "                datau32old = dataold.astype(np.uint32)\n",
-    "                l_data_old.append(len(datau32old[datau32old>0].flatten()))\n",
+    "                l_data_old.append(len(dataold[dataold>0].flatten()))\n",
     "                for bit in bits:\n",
-    "                    l_data_old.append(np.count_nonzero(old_const[cap][qm]['BadPixelsDark'][:, :, :, gain].astype(np.uint32) & bit.value))\n",
+    "                    l_data_old.append(np.count_nonzero(old_const[cap][qm]['BadPixelsDark'][:, :, :, gain] & bit.value))\n",
     "\n",
     "            l_data_name = ['All bad pixels', 'NOISE_OUT_OF_THRESHOLD', \n",
     "                           'OFFSET_OUT_OF_THRESHOLD', 'OFFSET_NOISE_EVAL_ERROR']\n",
-- 
GitLab