diff --git a/cal_tools/cal_tools/agipdlib.py b/cal_tools/cal_tools/agipdlib.py index 019808b84cdfa655bdc615286003c7fbe101301d..9fa3e19a0da721a17d607d61d262708a039321ba 100644 --- a/cal_tools/cal_tools/agipdlib.py +++ b/cal_tools/cal_tools/agipdlib.py @@ -67,7 +67,7 @@ def get_acq_rate(fast_paths: Tuple[str, str, int], fast_data_file = Path(fast_data_file) if fast_data_file.is_file(): fast_data_path = f'INSTRUMENT/{karabo_id}/DET/{module}CH0:xtdf/image/pulseId' # noqa - with h5py.File(fast_data_file) as fin: + with h5py.File(fast_data_file, "r") as fin: if fast_data_path in fin: # pulses is of shape (NNNN, 1), of type uint8. # Squeeze out the data, and subtract the 3rd entry from the 2nd @@ -122,7 +122,7 @@ def get_gain_mode(fname: str, h5path_ctrl: str) -> AgipdGainMode: h5path_run = h5path_ctrl.replace("CONTROL/", "RUN/", 1) h5path_gainmode = f'{h5path_run}/gainModeIndex/value' - with h5py.File(fname, 'r') as fd: + with h5py.File(fname, "r") as fd: if h5path_gainmode in fd: return AgipdGainMode(fd[h5path_gainmode][0]) return AgipdGainMode.ADAPTIVE_GAIN @@ -289,20 +289,20 @@ class AgipdCorrections: data_dict = self.shared_dict[i_proc] data_dict['moduleIdx'][0] = module_idx try: - f = h5py.File(file_name, 'r') + f = h5py.File(file_name, "r") group = f[agipd_base]["image"] - (_, first_index, last_index, + (_, first_index, last_index, _, valid_indices) = self.get_valid_image_idx(idx_base, f) allcells = np.squeeze(group['cellId']) allpulses = np.squeeze(group['pulseId']) - + firange = self.gen_valid_range(first_index, last_index, self.max_cells, allcells, allpulses, valid_indices, apply_sel_pulses) - + n_img = firange.shape[0] data_dict['nImg'][0] = n_img if np.all(np.diff(firange) == 1): @@ -352,7 +352,7 @@ class AgipdCorrections: return trains = data_dict['trainId'][:n_img] - with h5py.File(ofile_name, 'w') as outfile: + with h5py.File(ofile_name, "w") as outfile: # Copy any other data from the input file. # This includes indexes, so it's important that the corrected data # we write is aligned with the raw data.