[Numpy-discussion] Multiple Boolean Operations

Stéfan van der Walt stefan@sun.ac...
Thu May 22 06:29:59 CDT 2008

Hi Andrea

2008/5/22 Andrea Gavana <andrea.gavana@gmail.com>:
>    I am building some 3D grids for visualization starting from a much
> bigger grid. I build these grids by satisfying certain conditions on
> x, y, z coordinates of their cells: up to now I was using VTK to
> perform this operation, but VTK is slow as a turtle, so I thought to
> use numpy to get the cells I am interested in.
> Basically, for every cell I have the coordinates of its center point
> (centroids), named xCent, yCent and zCent. These values are stored in
> numpy arrays (i.e., if I have 10,000 cells, I have 3 vectors xCent,
> yCent and zCent with 10,000 values in them). What I'd like to do is:

You clearly have a large dataset, otherwise speed wouldn't have been a
concern to you.  You can do your operation in one pass over the data,
and I'd suggest you try doing that with Cython or Ctypes.  If you need
an example on how to access data using those methods, let me know.

Of course, it *can* be done using NumPy (maybe not in one pass), but
thinking in terms of for-loops is sometimes easier, and immediately
takes you to a highly optimised execution time.


More information about the Numpy-discussion mailing list