//  [python]
def set_temporal_resolution(bdnn_obj, min_bs, rate_type='speciation'):
    trt_tbls = copy_lib.deepcopy(bdnn_obj.trait_tbls)
    fixed_shifts = None
    n_bins_highres = 1.0
    if rate_type != 'sampling':
        if trt_tbls[0].ndim == 3:
            fixed_shifts = copy_lib.deepcopy(bdnn_obj.bdnn_settings['fixed_times_of_shift_bdnn'])
            fixed_shifts2 = np.concatenate((np.zeros(1), fixed_shifts[::-1]), axis = None)
            bin_size = np.diff(fixed_shifts2)
            if ~np.alltrue(bin_size == np.mean(bin_size)) and min_bs < 0.0:
                new_bs = np.min(bin_size)
                print(("\nDifferent bin sizes detected due to using -fixShift.\nTime windows resampled to a resolution of %s." ) % new_bs)
                print("Window size can be set with -BDNN_pred_importance_window_size")
            else:
                new_bs = min_bs
            if new_bs > 0.0:
                bin_size = np.concatenate((bin_size, bin_size[-1]), axis = None)
                n_bins_lowres = trt_tbls[0].shape[0]
                trt_tbl_lam = trt_tbls[0][::-1]
                trt_tbl_mu = trt_tbls[1][::-1]
                n_bins_highres = np.floor(bin_size / new_bs).astype(int)
                if np.alltrue(n_bins_highres == 0):
                    sys.exit("\nError: Decreasing temporal resolution instead of increasing\n")
                n_bins_highres[n_bins_highres == 0] = 1
                bin_idx_lowres = np.repeat(np.arange(n_bins_lowres), repeats = n_bins_highres)
                trt_tbl_lam_highres = trt_tbl_lam[bin_idx_lowres, :, :]
                trt_tbl_mu_highres = trt_tbl_mu[bin_idx_lowres, :, :]
                trt_tbls[0] = trt_tbl_lam_highres[::-1]
                trt_tbls[1] = trt_tbl_mu_highres[::-1]
                fixed_shifts = np.zeros(trt_tbls[0].shape[0] - 1)
                for i in range(len(bin_size)):
                    if n_bins_highres[i] == 1:
                         if i < len(bin_size):
                             add_shifts = fixed_shifts2[i + 1]
                         else:
                             add_shifts = fixed_shifts2[i]
                         fixed_shifts[np.sum(n_bins_highres[:i])] = add_shifts
                    else:
                         add_shifts = (fixed_shifts2[i] + new_bs) + np.linspace(0.0, bin_size[i] - new_bs, n_bins_highres[i])
                         idx = np.arange(np.sum(n_bins_highres[:i]), np.sum(n_bins_highres[:(i + 1)]), 1, dtype = int)
                         if i == (len(bin_size) - 1):
                             idx = idx[:-1]
                             add_shifts = add_shifts[:-1]
                         fixed_shifts[idx] = add_shifts
                fixed_shifts = fixed_shifts[::-1]
    else:
        if trt_tbls[2].ndim == 3:
            fixed_shifts2 = copy_lib.deepcopy(bdnn_obj.bdnn_settings['q_time_frames'])[::-1]
            bin_size = np.diff(fixed_shifts2)
            if ~np.alltrue(bin_size == np.mean(bin_size)) and min_bs < 0.0:
                new_bs = np.min(bin_size)
                print(("\nDifferent bin sizes detected due to using -qShift.\nTime windows resampled to a resolution of %s." ) % new_bs)
                print("Window size can be set with -BDNN_pred_importance_window_size")
            else:
                new_bs = min_bs
            if new_bs > 0.0:
                n_bins_lowres = trt_tbls[2].shape[0]
                trt_tbl_q = trt_tbls[2][::-1]
#                print('trt_tbl_q original\n', trt_tbls[2])
                n_bins_highres = np.floor(bin_size / new_bs).astype(int)
                if np.alltrue(n_bins_highres == 0):
                    sys.exit("\nError: Decreasing temporal resolution instead of increasing\n")
                n_bins_highres[n_bins_highres == 0] = 1
                bin_idx_lowres = np.repeat(np.arange(n_bins_lowres), repeats = n_bins_highres)
                trt_tbl_q_highres = trt_tbl_q[bin_idx_lowres, :, :]
                trt_tbls[2] = trt_tbl_q_highres[::-1] # Why is reordering not needed for sampling????
#                print('trt_tbl_q resampled\n', trt_tbls[2])
                fixed_shifts = np.zeros(trt_tbls[2].shape[0] - 1)
                for i in range(len(bin_size)):
                    if n_bins_highres[i] == 1:
                         if i < len(bin_size):
                             add_shifts = fixed_shifts2[i + 1]
                         else:
                             add_shifts = fixed_shifts2[i]
                         fixed_shifts[np.sum(n_bins_highres[:i])] = add_shifts
                    else:
                         add_shifts = (fixed_shifts2[i] + new_bs) + np.linspace(0.0, bin_size[i] - new_bs, n_bins_highres[i])
                         idx = np.arange(np.sum(n_bins_highres[:i]), np.sum(n_bins_highres[:(i + 1)]), 1, dtype = int)
                         if i == (len(bin_size) - 1):
                             idx = idx[:-1]
                             add_shifts = add_shifts[:-1]
                         fixed_shifts[idx] = add_shifts
                fixed_shifts = np.concatenate((np.max(fixed_shifts2), fixed_shifts[::-1], np.zeros(1)), axis=None)
                n_bins_highres = n_bins_highres[::-1]
                fixed_shifts = fixed_shifts[::-1]
    return trt_tbls, fixed_shifts, n_bins_highres