diff --git a/notebooks/LPD/LPDChar_Darks_NBC.ipynb b/notebooks/LPD/LPDChar_Darks_NBC.ipynb index 008620e36e2ea2c14a77897ffc2ea5554232c924..2e2f90b1404ddf5f9a7cec2c9a939f2fe3108219 100644 --- a/notebooks/LPD/LPDChar_Darks_NBC.ipynb +++ b/notebooks/LPD/LPDChar_Darks_NBC.ipynb @@ -127,7 +127,7 @@ "view = client[:]\n", "view.use_dill()\n", "gains = np.arange(3)\n", - "max_cells = mem_cells\n", + "max_cells = 512\n", "cells = np.arange(max_cells)\n", "gain_names = ['High', 'Medium', 'Low']\n", " \n", @@ -246,9 +246,11 @@ " offset = np.zeros((im.shape[0], im.shape[1], cells))\n", " noise = np.zeros((im.shape[0], im.shape[1], cells))\n", " normal_test = np.zeros((im.shape[0], im.shape[1], cells))\n", + " data_for_cell = np.zeros(cells, np.bool_)\n", " for cc in range(cells):\n", " idx = cellid == cc\n", " if np.any(idx):\n", + " data_for_cell[cc] = True\n", "\n", " offset[..., cc] = np.median(im[:, :, idx], axis=2)\n", " noise[..., cc] = np.std(im[:, :, idx], axis=2)\n", @@ -277,8 +279,14 @@ " bp[(noise < thresholds_noise_hard[0]) | (\n", " noise > thresholds_noise_hard[1])] |= BadPixels.NOISE_OUT_OF_THRESHOLD.value\n", " bp[~np.isfinite(noise)] |= BadPixels.OFFSET_NOISE_EVAL_ERROR.value\n", + " \n", + " # Where there is no data, override any other bad pixel indicators calculated above\n", + " bp[..., ~data_for_cell] = BadPixels.NO_DARK_DATA\n", "\n", - " idx = cellid == 12\n", + " if np.any(cellid == 12):\n", + " idx = cellid == 12\n", + " else:\n", + " idx = (cellid == cellid[0])\n", " return offset, noise, channel, gg, cap, bp, im[12, 12, idx], normal_test\n", "\n", "\n", @@ -396,7 +404,7 @@ " qm_db = qm_dict[qm]\n", " karabo_da = qm_db[\"karabo_da\"]\n", "\n", - " condition = Conditions.Dark.LPD(memory_cells=max_cells,\n", + " condition = Conditions.Dark.LPD(memory_cells=mem_cells,\n", " bias_voltage=bias_voltage,\n", " capacitor=cap)\n", " for const in clist:\n", @@ -488,7 +496,7 @@ " dconst.data = res[cap][qm][const]\n", "\n", " # set the operating condition\n", - " condition = Conditions.Dark.LPD(memory_cells=max_cells,\n", + " condition = Conditions.Dark.LPD(memory_cells=mem_cells,\n", " bias_voltage=bias_voltage,\n", " capacitor=cap)\n", "\n", @@ -505,7 +513,7 @@ " print(f\"Calibration constant {const} is stored locally.\\n\")\n", "\n", " print(\"Constants parameter conditions are:\\n\")\n", - " print(f\"• memory_cells: {max_cells}\\n• bias_voltage: {bias_voltage}\\n\"\n", + " print(f\"• memory_cells: {mem_cells}\\n• bias_voltage: {bias_voltage}\\n\"\n", " f\"• capacitor: {cap}\\n\"\n", " f\"• creation_time: {md.calibration_constant_version.begin_at if md is not None else creation_time}\\n\")" ] @@ -1253,7 +1261,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.7" + "version": "3.8.12" } }, "nbformat": 4, diff --git a/notebooks/LPD/LPD_Correct_Fast.ipynb b/notebooks/LPD/LPD_Correct_Fast.ipynb index 6dc356abeaf13a79ad985ee885515f43e4682106..222a5d1a7f8f9e032946fdecc9c3e95b47902d39 100644 --- a/notebooks/LPD/LPD_Correct_Fast.ipynb +++ b/notebooks/LPD/LPD_Correct_Fast.ipynb @@ -249,6 +249,8 @@ " dict(parameter_id=3, value=photon_energy), # Source energy\n", " dict(parameter_id=25, value=category) # category\n", "]\n", + "illuminated_condition[1] = dict(parameter_id=7, value=512) # Override number of cells\n", + "\n", "\n", "const_data = {}\n", "const_load_mp = psh.ProcessContext(num_workers=24)\n", @@ -277,7 +279,7 @@ " const_data[(da, calibration_name)] = dict(\n", " path=Path(ccv['path_to_file']) / ccv['file_name'],\n", " dataset=ccv['data_set_name'],\n", - " data=const_load_mp.alloc(shape=(256, 256, mem_cells, 3), dtype=dtype)\n", + " data=const_load_mp.alloc(shape=(256, 256, 512, 3), dtype=dtype)\n", " )\n", " print('.', end='', flush=True)\n", " \n", @@ -318,7 +320,7 @@ "ccv_gains = {}\n", "ccv_masks = {}\n", "\n", - "ccv_shape = (mem_cells, 256, 256, 3)\n", + "ccv_shape = (512, 256, 256, 3)\n", "\n", "constant_order = {\n", " 'Offset': (2, 1, 0, 3),\n",