Re: [Numpy-discussion] slicing an n-dimensional array

2014-12-04 Thread Stefan van der Walt
On 2014-12-04 03:41:35, Jaime Fernández del Río wrote: > nx = np.arange(A.shape[0])[:, np.newaxis] > ny = np.arange(A.shape[1]) > C = A[nx, ny, B] That's the correct answer--in my answer I essentially wrote C = A[B] (== A[B, :, :]) which broadcasts the shape of B against the second and third di

Re: [Numpy-discussion] slicing an n-dimensional array

2014-12-03 Thread Jaime Fernández del Río
On Wed, Dec 3, 2014 at 4:02 PM, Stefan van der Walt wrote: > Hi Catherine > > On 2014-12-04 01:12:30, Moroney, Catherine M (398E) < > catherine.m.moro...@jpl.nasa.gov> wrote: > > I have an array "A" of shape (NX, NY, NZ), and then I have a second > array "B" of shape (NX, NY) > > that ranges from

Re: [Numpy-discussion] slicing an n-dimensional array

2014-12-03 Thread Benjamin Root
Posting in the correct thread now... A slightly different way to look at it (I don't think it is exactly the same problem, but the description reminded me of it): http://mail.scipy.org/pipermail/numpy-discussion/2013-April/066269.html (and I think there are some things that can be done to make tha

Re: [Numpy-discussion] slicing an n-dimensional array

2014-12-03 Thread Stefan van der Walt
Hi Catherine On 2014-12-04 01:12:30, Moroney, Catherine M (398E) wrote: > I have an array "A" of shape (NX, NY, NZ), and then I have a second array "B" > of shape (NX, NY) > that ranges from 0 to NZ in value. > > I want to create a third array "C" of shape (NX, NY) that holds the > "B"-th slice

[Numpy-discussion] slicing an n-dimensional array

2014-12-03 Thread Moroney, Catherine M (398E)
Hello, I'm sure there's a simple solution, but I'm not seeing it so any hints would be greatly appreciated. I have an array "A" of shape (NX, NY, NZ), and then I have a second array "B" of shape (NX, NY) that ranges from 0 to NZ in value. I want to create a third array "C" of shape (NX, NY) tha