[Numpy-discussion] Indexing with integer ndarrays
Joe Kington
jkington@wisc....
Sat Jun 13 19:30:17 CDT 2009
Thank you! That answered things quite nicely. My apologies for not finding
the earlier discussion before sending out the question...
Thanks again,
-Joe
On Sat, Jun 13, 2009 at 7:17 PM, Robert Kern <robert.kern@gmail.com> wrote:
> On Sat, Jun 13, 2009 at 19:11, Joe Kington<jkington@wisc.edu> wrote:
> > Hi folks,
> >
> > This is probably a very simple question, but it has me stumped...
> >
> > I have an integer 2D array containing 3rd dimesion indicies that I'd like
> to
> > use to index values in a 3D array.
> >
> > Basically, I want the equivalent of:
> >
> >> output = np.zeros((ny,nx))
> >>
> >> for i in xrange(ny):
> >> for j in xrange(nx):
> >> z = grid[i,j]
> >> output[j,i] = bigVolume[j,i,z]
> >
> > Where grid is my 2D array of indicies and bigVolume is my 3D array.
> >
> > I've read the numpy-user and numpybook sections on indexing with an
> integer
> > ndarray, but I'm still not quite able to wrap my head around how it
> should
> > work. I'm sure I'm missing something obvious (I haven't been using numpy
> > particularly long).
> >
> > If it helps anyone visualize it, I'm essentially trying to extract
> > attributes out of a seismic volume along the surface of a horizion.
>
> I discuss this particular use case (well, a little different; we are
> pulling out a thin slab around a horizon rather than a slice) here:
>
> http://mail.scipy.org/pipermail/numpy-discussion/2008-July/035776.html
>
> --
> Robert Kern
>
> "I have come to believe that the whole world is an enigma, a harmless
> enigma that is made terrible by our own mad attempt to interpret it as
> though it had an underlying truth."
> -- Umberto Eco
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090613/da1e8b93/attachment.html
More information about the Numpy-discussion
mailing list