From: Joel B. M. <jo...@ki...> - 2014-06-27 10:09:26
|
On 06/27/2014 02:14 AM, billyi wrote: > And I think the longitudes and latitudes are not monotonic, but I don't know > the way to check this, other than checking the array like lon[:] in > terminal. Is there a better way? numpy slicing (subtract prior from next element check that 'all' the results are >=0): In [1]: import numpy In [2]: x=numpy.array([1,2,3,4,5]) In [3]: (x[1:]-x[:-1])>=0 Out[3]: array([ True, True, True, True], dtype=bool) In [4]: numpy.all((x[1:]-x[:-1])>=0) Out[4]: True In [5]: x=numpy.array([1,3,2,5,4]) In [6]: numpy.all((x[1:]-x[:-1])>=0) Out[6]: False |