[Numpy-discussion] how to efficiently build an array of x, y, z points

Brennan Williams brennan.williams@visualreservoir....
Tue Mar 2 20:29:09 CST 2010


I'm reading a file which contains a grid definition. Each cell in the 
grid, apart from having an i,j,k index also has 8 x,y,z coordinates.
I'm reading each set of coordinates into a numpy array. I then want to 
add/append those coordinates to what will be my large "points" array.
Due to the orientation/order of the 8 corners of each hexahedral cell I 
may have to reorder them before adding them to my large points array 
(not sure about that yet).

Should I create a numpy array with nothing in it and then .append to it? 
But this is probably expensive isn't it as it creates a new copy of the 
array each time?

Or should I create a zero or empty array of sufficient size and then put 
each set of 8 coordinates into the correct position in that big array?

I don't know exactly how big the array will be (some cells are inactive 
and therefore don't have a geometry defined) but I do know what its 
maximum size is (ni*nj*nk,3).

Thanks

Brennan




More information about the NumPy-Discussion mailing list