[Numpy-discussion] Grid indexing

Wolfgang Kerzendorf wkerzendorf@googlemail....
Mon Feb 28 08:34:16 CST 2011


I think it is possible to construct a class that takes as init function 
index converter functions and stores an array. That do for example 
linear mappings from the floats to the int. I am wondering if the numpy 
community would be interested in such a thing? I think the code would be 
very short, but might help a few people.

Cheers
     W
On 1/03/11 1:21 AM, Ian Stokes-Rees wrote:
>
> 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
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion



More information about the NumPy-Discussion mailing list