[Numpy-discussion] Grid indexing
Ian Stokes-Rees
ijstokes@hkl.hms.harvard....
Mon Feb 28 08:21:55 CST 2011
On 2/26/11 3:36 AM, Wolfgang Kerzendorf wrote:
> I have a n dimensional grid. The grids axes are linear but not
> intergers. Let's say I want the value in gridcell [3.2,-5.6,0.01]. Is
> there an easy way to transform the index? Do I have to write my own
> class to accomplish this. Is there an easy way in numpy to accomplish
> this. Can I give functions to transform the index somehow to the numpy
> array?
I can't answer this definitively, but this sounds like a tough one to
find builtin -- the idea of array indexing is very tightly tied to
integers starting from zero. I think you'll need to map from your grid
coordinate system to an integer system (and vice-versa). If you can
come up with a linear transformation for each dimension that map your
floats to non-negative ints, that is probably pretty fast and easy for
single cell lookups. Sparse arrays could be helpful if the data isn't
"dense" on your grid.
Ian
More information about the NumPy-Discussion
mailing list