Re: [Numpy-discussion] Data cube optimization for combination

2012-03-06 Thread Hanno Klemm
Hi, this should work: import numpy as np ndim = 20 cube = np.random.rand(32,ndim, ndim) result = np.zeros([ndim, ndim], np.float32) def combine(cube, result): for ii in range(ndim): for jj in range(ndim): result[ii, jj] = np.sqrt((cube[:,ii, jj])).sum() return

Re: [Numpy-discussion] Data cube optimization for combination

2012-03-06 Thread Sebastian Berg
Hello, On Tue, 2012-03-06 at 13:00 +0100, Jose Miguel Ibáñez wrote: > Hello everyone, > > does anyone know of an efficient implementation (maybe using > numpy.where statement) of the next code for data cube (3d array) > combining ? > You use the axis keyword/argument to sum, at which point you w

[Numpy-discussion] Data cube optimization for combination

2012-03-06 Thread Jose Miguel Ibáñez
Hello everyone, does anyone know of an efficient implementation (maybe using numpy.where statement) of the next code for data cube (3d array) combining ? import numpy as np def combine( ) cube = np.random.rand(32,2048,2048) result = np.zeros([2048,2048], np.float32) for ii in range(2048