diff --git a/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb b/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb index 2a719adffb376cb6c3beecd90b6141075781fd1f..f078a19efc75ebb06a33ef645b858ed395b275d8 100644 --- a/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb +++ b/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb @@ -331,32 +331,41 @@ " first_index = int(first[status != 0][0])\n", " im = np.array(infile[f\"{h5path_f}/data\"][first_index:last_index,...])\n", " cellIds = np.squeeze(infile[f\"{h5path_f}/cellId\"][first_index:last_index,...])\n", - "\n", + " \n", " if interlaced:\n", - " ga = im[1::2, 0, ...]\n", + " if not fixed_gain_mode:\n", + " ga = im[1::2, 0, ...]\n", " im = im[0::2, 0, ...].astype(np.float32)\n", " cellIds = cellIds[::2]\n", " else:\n", - " ga = im[:, 1, ...]\n", + " if not fixed_gain_mode:\n", + " ga = im[:, 1, ...]\n", " im = im[:, 0, ...].astype(np.float32)\n", "\n", " im = np.rollaxis(im, 2)\n", " im = np.rollaxis(im, 2, 1)\n", "\n", - " ga = np.rollaxis(ga, 2)\n", - " ga = np.rollaxis(ga, 2, 1)\n", - "\n", + " if not fixed_gain_mode:\n", + " ga = np.rollaxis(ga, 2)\n", + " ga = np.rollaxis(ga, 2, 1)\n", + " \n", " offset = np.zeros((im.shape[0], im.shape[1], num_cells))\n", - " gains = np.zeros((im.shape[0], im.shape[1], num_cells))\n", " noise = np.zeros((im.shape[0], im.shape[1], num_cells))\n", - " gains_std = np.zeros((im.shape[0], im.shape[1], num_cells))\n", + "\n", + " if fixed_gain_mode:\n", + " gains = None\n", + " gains_std = None\n", + " else:\n", + " gains = np.zeros((im.shape[0], im.shape[1], num_cells))\n", + " gains_std = np.zeros((im.shape[0], im.shape[1], num_cells))\n", "\n", " for cc in np.unique(cellIds[cellIds < num_cells]):\n", " cellidx = cellIds == cc\n", " offset[...,cc] = np.median(im[..., cellidx], axis=2)\n", " noise[...,cc] = np.std(im[..., cellidx], axis=2)\n", - " gains[...,cc] = np.median(ga[..., cellidx], axis=2)\n", - " gains_std[...,cc] = np.std(ga[..., cellidx], axis=2)\n", + " if not fixed_gain_mode:\n", + " gains[...,cc] = np.median(ga[..., cellidx], axis=2)\n", + " gains_std[...,cc] = np.std(ga[..., cellidx], axis=2)\n", "\n", " # bad pixels\n", " bp = np.zeros(offset.shape, np.uint32)\n", @@ -389,10 +398,11 @@ "source": [ "offset_g = OrderedDict()\n", "noise_g = OrderedDict()\n", - "gain_g = OrderedDict()\n", - "gainstd_g = OrderedDict()\n", "badpix_g = OrderedDict()\n", - "\n", + "if not fixed_gain_mode:\n", + " gain_g = OrderedDict()\n", + " gainstd_g = OrderedDict()\n", + " \n", "start = datetime.now()\n", "all_cells = []\n", "all_acq_rate = []\n", @@ -421,15 +431,17 @@ " if qm not in offset_g:\n", " offset_g[qm] = np.zeros((offset.shape[0], offset.shape[1], offset.shape[2], 3))\n", " noise_g[qm] = np.zeros_like(offset_g[qm])\n", - " gain_g[qm] = np.zeros_like(offset_g[qm])\n", - " gainstd_g[qm] = np.zeros_like(offset_g[qm])\n", " badpix_g[qm] = np.zeros_like(offset_g[qm], np.uint32)\n", + " if not fixed_gain_mode:\n", + " gain_g[qm] = np.zeros_like(offset_g[qm])\n", + " gainstd_g[qm] = np.zeros_like(offset_g[qm])\n", "\n", " offset_g[qm][...,gg] = offset\n", " noise_g[qm][...,gg] = noise\n", - " gain_g[qm][...,gg] = gains\n", - " gainstd_g[qm][..., gg] = gains_std\n", " badpix_g[qm][...,gg] = bp\n", + " if not fixed_gain_mode:\n", + " gain_g[qm][...,gg] = gains\n", + " gainstd_g[qm][..., gg] = gains_std\n", "\n", "\n", "duration = (datetime.now() - start).total_seconds()\n", @@ -878,7 +890,7 @@ "if fixed_gain_mode:\n", " constants = ['Offset', 'Noise']\n", "else:\n", - " ['Offset', 'Noise', 'ThresholdsDark']\n", + " constants = ['Offset', 'Noise', 'ThresholdsDark']\n", "\n", "for const in constants:\n", "\n",