[Numpy-discussion] Multiple Boolean Operations
Andrea Gavana
andrea.gavana@gmail....
Thu May 22 06:37:42 CDT 2008
Hi Stefan & All,
On Thu, May 22, 2008 at 12:29 PM, Stéfan van der Walt wrote:
> 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.
First of all, thank you for your answer. I know next to nothing about
Cython and very little about Ctypes, but it would be nice to have an
example on how to use them to speed up the operations. Actually, I
don't really know if my dataset is "large", as I work normally with
xCent, yCent and zCent vectors of about 100,000-300,000 elements in
them. However, all the other operations I do with numpy on these
vectors are pretty fast (reshaping, re-casting, min(), max() and so
on). So I believe that also a pure numpy solution might perform well
enough for my needs: but I am really no expert in numpy, so please
forgive any mistake I'm doing :-D.
Andrea.
"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/
More information about the Numpy-discussion
mailing list