[Numpy-discussion] 3D array -> 2D array issue...

Fred fredmfp@gmail....
Mon Feb 7 06:21:15 CST 2011


Hi all,

Let's say C1 is a 3D array,
and q0 and k are 2D array.

dim C1 = nx*ny*nz

dim q0 = nx*ny = dim k

I have to do the following:

q0[0, 0] = C1[0, 0, k[0, 0]]
q0[1, 1] = C1[1, 1, k[1, 1]]
...
q0[i, j] = C1[i, j, k[i, j]]
...

I tried

q0 = C1[:, :, k]

but this obviously does not work.


How could I do this ala NumPy?

TIA

Cheers,

-- 
Fred


More information about the NumPy-Discussion mailing list