diff --git a/notebooks/LPD/LPD_Correct_Fast.ipynb b/notebooks/LPD/LPD_Correct_Fast.ipynb index c8024a4211708a0c0001afeea955f0296ed4a6de..91fe5d36051a32770df550a8fc4666edaeacc410 100644 --- a/notebooks/LPD/LPD_Correct_Fast.ipynb +++ b/notebooks/LPD/LPD_Correct_Fast.ipynb @@ -119,6 +119,7 @@ "source": [ "file_re = re.compile(r'^RAW-R(\\d{4})-(\\w+\\d+)-S(\\d{5})$') # This should probably move to cal_tools\n", "\n", + "run_folder = Path(in_folder) / f'r{run:04d}'\n", "out_folder = Path(out_folder)\n", "out_folder.mkdir(exist_ok=True)\n", "\n", @@ -166,16 +167,10 @@ "metadata": {}, "outputs": [], "source": [ - "# Open the entire input directory.\n", - "dc_all = xd.RunDirectory(Path(in_folder) / f'r{run:04d}') \\\n", - " .select([(src, 'image.*') for src in det_inp_sources])\n", - "\n", - "out_folder = Path(out_folder) \n", - "\n", "data_to_process = []\n", "\n", - "for file_access in dc_all.files:\n", - " match = file_re.match(Path(file_access.filename).stem)\n", + "for inp_path in run_folder.glob('RAW-*.h5'):\n", + " match = file_re.match(inp_path.stem)\n", " \n", " if match[2] not in karabo_da or not do_sequence(int(match[3])):\n", " continue\n", @@ -183,11 +178,11 @@ " outp_path = out_folder / 'CORR-R{run:04d}-{aggregator}-S{seq:05d}.h5'.format(\n", " run=int(match[1]), aggregator=match[2], seq=int(match[3]))\n", "\n", - " data_to_process.append((file_access.filename, match[2], outp_path))\n", + " data_to_process.append((match[2], inp_path, outp_path))\n", "\n", "print('Files to process:')\n", - "for data_descr in sorted(data_to_process, key=lambda x: f'{x[1]}{x[0]}'):\n", - " print('\\t'.join(data_descr[1::-1]))" + "for data_descr in sorted(data_to_process, key=lambda x: f'{x[0]}{x[1]}'):\n", + " print(f'{data_descr[0]}\\t{data_descr[1]}')" ] }, { @@ -365,11 +360,11 @@ "outputs": [], "source": [ "def correct_file(wid, index, work):\n", - " filename, aggregator, outp_path = work\n", + " aggregator, inp_path, outp_path = work\n", " module_index = int(aggregator[-2:])\n", " \n", " start = perf_counter()\n", - " dc = xd.H5File(filename).select('*', 'image.*', require_all=True)\n", + " dc = xd.H5File(inp_path).select('*', 'image.*', require_all=True)\n", " inp_source = dc[input_source.format(karabo_id=karabo_id, module_index=module_index)]\n", " open_time = perf_counter() - start\n", " \n",