![](https://secure.gravatar.com/avatar/f0c5eaa94e4adb969b148962d59c92ec.jpg?s=120&d=mm&r=g)
Hi I have read the stuff on the numpy interface and understand most of if(?) ;-) However I want to interface numpy to an array which is stored as a series of data blocks which are not contiguous in memory... Help! so for example I hava 3d matrix of 1024*512*128 where data is stored in blocks within memory which are 16x16x16 floats an read in from disk on demand... regards gary -- ------------------------------------------------------------------- Dr Gary Thompson Astbury Centre for Structural Molecular Biology, University of Leeds, Astbury Building, Leeds, LS2 9JT, West-Yorkshire, UK Tel. +44-113-3433024 email: garyt@bmb.leeds.ac.uk Fax +44-113-2331407 -------------------------------------------------------------------
![](https://secure.gravatar.com/avatar/4d021a1d1319f36ad861ebef0eb5ba44.jpg?s=120&d=mm&r=g)
Gary S. Thompson wrote:
Hi I have read the stuff on the numpy interface and understand most of if(?) ;-) However I want to interface numpy to an array which is stored as a series of data blocks which are not contiguous in memory... Help!
so for example I hava 3d matrix of 1024*512*128 where data is stored in blocks within memory which are 16x16x16 floats an read in from disk on demand...
The memory model for numpy arrays requires that you can access the next element in each dimension by striding a "fixed-number" of bytes. In other words, to be a single ndarray, element i,j,k of the array, B, must be at start_of_data + i*B.stride[0] + j*B.stride[1] + k*B.stride[2] So, in your case, do these 16x16x16 blocks of floats all exist at arbitrary memory locations? If so, then I don't see how you can map that to a single ndarray. You could, however, write a class that wraps each block as a separate sub-array and do the indexing calculations yourself to determine which sub-block the data is stored in. But, I don't see a way to use a single ndarray to access memory layed out like that. Perhaps I still don't understand what you are doing. Are you using a memory map? -Travis
participants (2)
-
Gary S. Thompson
-
Travis Oliphant