J = np.arange(s[1] - 1, -1, -1)
shifts = (I + s[0] / 2) % s[0]
linear_idx = (shifts[:, (None)] + J) % s[1] + I[:, (None)] * s[1]
out = np.take(Trace, linear_idx)
Оптимизация смещения элементов массива в Python/Numpy