diff --git a/src/cal_tools/agipdlib.py b/src/cal_tools/agipdlib.py index ac71140f025c8fd73258d00c545d293503fc231d..feb47f68c4b3d4fbcf5b652a90b4acdd075d61d9 100644 --- a/src/cal_tools/agipdlib.py +++ b/src/cal_tools/agipdlib.py @@ -1272,72 +1272,6 @@ class AgipdCorrections: return n_img_sel - def copy_and_sanitize_non_cal_data(self, infile, outfile, agipd_base, - idx_base, trains): - """ Copy and sanitize data in `infile` that is not touched by - `correctAGIPD` - """ - # these are touched in the correct function, do not copy them here - dont_copy = ["data", "cellId", "trainId", "pulseId", "status", - "length"] - dont_copy = [posixpath.join(agipd_base, "image", ds) - for ds in dont_copy] - - # don't copy index as we may need to adjust if we filter trains - dont_copy.append(posixpath.join(idx_base, "image")) - - h5_copy_except_paths(infile, outfile, dont_copy) - - # sanitize indices - for do in ["image", ]: - # uq: INDEX/trainID - # fidxv: INDEX/.../image/first idx values - # cntsv: INDEX/.../image/counts values - - # Extract parameters through identifying - # unique trains, index and numbers. - uq, fidxv, cntsv = np.unique(trains, return_index=True, return_counts=True) # noqa - - # Validate calculated CORR INDEX contents by checking - # difference between trainId stored in RAW data and trains from - train_diff = np.isin(np.array(infile["/INDEX/trainId"]), uq, invert=True) # noqa - - # Insert zeros for missing trains. - # fidxv and cntsv should have same length as - # raw INDEX/.../image/first and INDEX/.../image/count, - # respectively - - # first_inc = first incrementation - first_inc = True - for i, diff in enumerate(train_diff): - if diff: - if i < len(cntsv): - cntsv = np.insert(cntsv, i, 0) - fidxv = np.insert(fidxv, i, 0) if i == 0 else np.insert(fidxv, i, fidxv[i]) - else: - # append if at the end of the array - cntsv = np.append(cntsv, 0) - # increment fidxv once with the - # no. of processed mem-cells. - if first_inc: - fidxv = np.append(fidxv, - (2 * fidxv[i-1]) - fidxv[i-2]) - first_inc = False - else: - fidxv = np.append(fidxv, fidxv[i-1]) - - # save INDEX contents (first, count) in CORR files - outfile.create_dataset(idx_base + "{}/first".format(do), - fidxv.shape, - dtype=fidxv.dtype, - data=fidxv, - fletcher32=True) - outfile.create_dataset(idx_base + "{}/count".format(do), - cntsv.shape, - dtype=cntsv.dtype, - data=cntsv, - fletcher32=True) - def init_constants( self, cons_data: dict, module_idx: int, variant: dict): """