Я пытаюсь переопределить в python функцию IDL:
http://star.pst.qub.ac.uk/idl/REBIN.html
который уменьшает с помощью целочисленного коэффициента массив 2d путем усреднения.
Например:
>>> a=np.arange(24).reshape((4,6))
>>> a
array([[ 0, 1, 2, 3, 4, 5],
[ 6, 7, 8, 9, 10, 11],
[12, 13, 14, 15, 16, 17],
[18, 19, 20, 21, 22, 23]])
Я хотел бы изменить его до (2,3), взяв среднее значение соответствующих выборок, ожидаемый результат:
>>> b = rebin(a, (2, 3))
>>> b
array([[ 3.5, 5.5, 7.5],
[ 15.5, 17.5, 19.5]])
то есть. b[0,0] = np.mean(a[:2,:2]), b[0,1] = np.mean(a[:2,2:4])
и т.д.
Я считаю, что я должен переделать в 4-мерный массив, а затем взять среднее значение на правильном фрагменте, но не смог вычислить алгоритм. У вас есть намек?