From b4a44ebd6699f39e75f29f5107f61f7cb3b960c2 Mon Sep 17 00:00:00 2001 From: Karim Ahmed <karim.ahmed@xfel.eu> Date: Tue, 10 Dec 2019 11:48:58 +0100 Subject: [PATCH] commit before rebasing --- cal_tools/cal_tools/agipdlib.py | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/cal_tools/cal_tools/agipdlib.py b/cal_tools/cal_tools/agipdlib.py index 182a1e616..2c2de40f8 100644 --- a/cal_tools/cal_tools/agipdlib.py +++ b/cal_tools/cal_tools/agipdlib.py @@ -1285,13 +1285,16 @@ class AgipdCorrections: # 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(alltrains[firange - firange[0]], return_index=True, return_counts=True) - # Validate calculated CORR INDEX contents + # Validate calculated CORR INDEX contents. train_diff = np.isin(np.array(self.infile["/INDEX/trainId"]), uq, invert=True) + # Insert zeros for missing trains. for i, diff in enumerate(train_diff): if diff: if i < len(cntsv): @@ -1301,27 +1304,16 @@ class AgipdCorrections: cntsv = np.append(cntsv, 0) fidxv = np.append(fidxv, 0) - mv = len(fidxv) - fidx = np.zeros(len(fidxv), fidxv.dtype) - fidx[self.valid[:mv]] = np.array(fidxv)[self.valid[:mv]] - - for i in range(len(fidx) - 1, 2, -1): - if fidx[i - 1] == 0 and fidx[i] != 0: - fidx[i - 1] = fidx[i] - - cnts = np.zeros(len(fidxv), cntsv.dtype) - cnts[self.valid[:mv]] = np.array(cntsv)[self.valid[:mv]] - - # add INDEX contents in CORR files + # save INDEX contents (first, count) in CORR files self.outfile.create_dataset(idx_base + "{}/first".format(do), - fidx.shape, - dtype=fidx.dtype, - data=fidx, + fidxv.shape, + dtype=fidxv.dtype, + data=fidxv, fletcher32=True) self.outfile.create_dataset(idx_base + "{}/count".format(do), - cnts.shape, - dtype=cnts.dtype, - data=cnts, + cntsv.shape, + dtype=cntsv.dtype, + data=cntsv, fletcher32=True) def create_output_datasets(self): -- GitLab