[Numpy-discussion] Newby question: best way to create a list of indices

Hanlie Pretorius hanlie.pretorius at gmail.com
Wed Jun 9 06:01:53 EDT 2010


Hi,

I'm reading netCDF files using pupynere and I want to extract 22
values from a 1440x400 array. I have the indices of the values, they
are:

92	832
92	833
91	832
91	833
91	834
90	835
90	832
90	833
90	834
89	832
89	833
89	834
88	832
88	833
88	834
87	832
87	833
87	834
86	832
86	833
86	834
85	833

What is the best way to store these indices so that I can
programmatically extract the values? I have tried storing them in
pairs
-----
(index1='92,832')
-----
and then I can use:
-----
precipitation.data[int(index1[:2]),int(index1[3:])]
-----
Is there a better way? The values are also not regular enough to use a
nested loop, as far as I can see.

Thanks
Hanlie



More information about the NumPy-Discussion mailing list