From 3af7df1887d770f47f845447c367b24196453644 Mon Sep 17 00:00:00 2001 From: David Hammer <dhammer@mailbox.org> Date: Fri, 23 Apr 2021 15:40:13 +0200 Subject: [PATCH] Improving some variable names --- .../AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb b/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb index 7cd2606ba..9201b66fd 100644 --- a/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb +++ b/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb @@ -306,10 +306,10 @@ "source": [ "# set everything up filewise\n", "os.makedirs(out_folder, exist_ok=True)\n", - "gain_mapped_files, total_sequences, total_file_size = map_gain_stages(\n", + "gain_mapped_files, total_files, total_file_size = map_gain_stages(\n", " in_folder, offset_runs, path_template, karabo_da, sequences\n", ")\n", - "print(f\"Will process a total of {total_sequences} files ({total_file_size:.02f} GB).\")\n", + "print(f\"Will process a total of {total_files} files ({total_file_size:.02f} GB).\")\n", "\n", "inp = []\n", "inp_modules = []\n", @@ -341,7 +341,8 @@ "metadata": {}, "outputs": [], "source": [ - "parallel_num_procs = min(6, total_sequences)\n", + "# min() only relevant if running on multiple modules (i.e. within notebook)\n", + "parallel_num_procs = min(12, total_files)\n", "parallel_num_threads = multiprocessing.cpu_count() // parallel_num_procs\n", "print(f\"Will use {parallel_num_procs} processes with {parallel_num_threads} threads each\")\n", "\n", @@ -383,13 +384,13 @@ " last_index = int(last[status != 0][-1]) + 1\n", " 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", + " cell_ids = np.squeeze(infile[f\"{h5path_f}/cellId\"][first_index:last_index,...])\n", " \n", " if interlaced:\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", + " cell_ids = cell_ids[::2]\n", " else:\n", " if not fixed_gain_mode:\n", " ga = im[:, 1, ...]\n", @@ -411,7 +412,7 @@ " gains_std = context.alloc(like=offset)\n", "\n", " def process_cell(worker_id, array_index, cell_number):\n", - " cell_slice_index = (cellIds == cell_number)\n", + " cell_slice_index = (cell_ids == cell_number)\n", " im_slice = im[..., cell_slice_index]\n", " offset[..., cell_number] = np.median(im_slice, axis=2)\n", " noise[..., cell_number] = np.std(im_slice, axis=2)\n", @@ -419,7 +420,7 @@ " ga_slice = ga[..., cell_slice_index]\n", " gains[..., cell_number] = np.median(ga_slice, axis=2)\n", " gains_std[..., cell_number] = np.std(ga_slice, axis=2)\n", - " context.map(process_cell, np.unique(cellIds))\n", + " context.map(process_cell, np.unique(cell_ids))\n", "\n", " # bad pixels\n", " bp = np.zeros_like(offset, dtype=np.uint32)\n", -- GitLab