taking a 2D uneven surface slice
![](https://secure.gravatar.com/avatar/f4d8c0d66f34d59cee0210131d9e7add.jpg?s=120&d=mm&r=g)
I'm trying to do something that at first glance I think should be simple but I can't quite figure out how to do it. The problem is as follows: I have a 3D grid Values[Nx, Ny, Nz] I want to slice Values at a 2D surface in the Z dimension specified by Z_index[Nx, Ny] and return a 2D slice[Nx, Ny]. It is not as simple as Values[:,:,Z_index]. I tried this:
Obviously I could create an empty 2D slice and then fill it by using np.ndenumerate to fill it point by point by selecting values[i, j, Z_index[i, j]]. This just seems too inefficient and not very pythonic.
![](https://secure.gravatar.com/avatar/09939f25b639512a537ce2c90f77f958.jpg?s=120&d=mm&r=g)
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 that faster, but I don't recall it right now) Ben Root On Tue, Apr 16, 2013 at 4:35 PM, Bradley M. Froehle <brad.froehle@gmail.com> wrote:
![](https://secure.gravatar.com/avatar/09939f25b639512a537ce2c90f77f958.jpg?s=120&d=mm&r=g)
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 that faster, but I don't recall it right now) Ben Root On Tue, Apr 16, 2013 at 4:35 PM, Bradley M. Froehle <brad.froehle@gmail.com> wrote:
participants (3)
-
Benjamin Root
-
Bradley M. Froehle
-
Bryan Woods