diff --git a/cal_tools/cal_tools/agipdlib.py b/cal_tools/cal_tools/agipdlib.py
index 455ee524d72d0fd571d4aab384d9b48cac115a64..b7281dd8dc26813ddc13ca847c848f885e0cadb5 100644
--- a/cal_tools/cal_tools/agipdlib.py
+++ b/cal_tools/cal_tools/agipdlib.py
@@ -15,6 +15,8 @@ def get_num_cells(fname, loc, module):
     with h5py.File(fname, "r") as f:
         cells = \
         f["INSTRUMENT/{}/DET/{}CH0:xtdf/image/cellId".format(loc, module)][()]
+        if cells.shape[0] == 0:
+            return None
         maxcell = np.max(cells)
         options = [4, 32, 64, 76, 128, 176, 202, 250]
         dists = [abs(o - maxcell) for o in options]
@@ -23,10 +25,13 @@ def get_num_cells(fname, loc, module):
 
 def get_acq_rate(fname, loc, module):
     with h5py.File(fname, "r") as f:
-        pulses = \
-            np.squeeze(f["INSTRUMENT/{}/DET/{}CH0:xtdf/image/pulseId".format(
-                loc, module)][:2])
-        diff = pulses[1] - pulses[0]
+        try:
+            pulses = \
+                np.squeeze(f["INSTRUMENT/{}/DET/{}CH0:xtdf/image/pulseId".format(
+                    loc, module)][:2])
+            diff = pulses[1] - pulses[0]
+        except:
+            diff = 0
         options = {8: 0.5, 4: 1.1, 2: 2.2, 1: 4.5}
         return options.get(diff, None)
 
diff --git a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb
index 23e304ff048c22a7ce1bab632a8dc38a0ebec35f..06c8ed1f4efab43a399a78e07c7aad1d98edce56 100644
--- a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb
+++ b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb
@@ -414,7 +414,11 @@
     "        \n",
     "        if max_cells == 0:\n",
     "            max_cells = get_num_cells(filename, loc, channel)\n",
-    "            cells = np.arange(max_cells)\n",
+    "            if max_cells == 0:\n",
+    "                raise ValueError(\"Number of memory cells are zero, \"\n",
+    "                                 \"No processed data for {}\".format(qm))\n",
+    "            else:\n",
+    "                cells = np.arange(max_cells)\n",
     "            \n",
     "        if acq_rate == 0.:\n",
     "            acq_rate = get_acq_rate(filename, loc, channel)\n",