Skip to content
Snippets Groups Projects

Fix: [AGIPD][DARK] index out of range in case of running for one module

Merged Karim Ahmed requested to merge fix/AGIPD_dark_one_module_inp_list into master
1 unresolved thread
1 file
+ 7
7
Compare changes
  • Side-by-side
  • Inline
@@ -337,12 +337,11 @@
"# print(f\"Will process a total of {total_files} files ({total_file_size:.02f} GB).\")\n",
"\n",
"# TODO: Remove all of this nonsense with Extra-data.\n",
"inp = [None] * 3 * len(modules)\n",
"inp = []\n",
"for gain_index, (gain, qm_file_map) in enumerate(gain_mapped_files.items()):\n",
" gain_input = []\n",
" selected_inp = None\n",
" for module_index in modules:\n",
" max_n_imgs = 0\n",
" inp_idx = gain_index * len(modules) + module_index\n",
" qm = module_index_to_qm(module_index)\n",
" if qm not in qm_file_map:\n",
" print(f\"Did not find files for {qm}\")\n",
@@ -355,15 +354,16 @@
" with h5py.File(filename, \"r\") as fin:\n",
" n_imgs = fin[h5path.format(module_index)+\"/trainId\"].shape[0]\n",
" if n_imgs != 0 and n_imgs > max_n_imgs:\n",
" inp[inp_idx] = (filename, module_index, gain_index)\n",
" selected_inp = (filename, module_index, gain_index)\n",
" max_n_imgs = n_imgs\n",
" print(f\"Process {inp[inp_idx][0]} for {qm}\")\n",
" if inp[inp_idx] is None:\n",
" print(f\"Process {selected_inp[0]} for {qm}\")\n",
" inp.append(selected_inp)\n",
" if selected_inp is None:\n",
" raise ValueError(\n",
" \"No images to process for run: \"\n",
" f\"{[v for v in offset_runs.values()][gain_index]}\"\n",
" )\n",
"inp = [x for x in inp if x is not None]\n",
"\n",
"total_files = len(inp)"
]
},
Loading