I have a numpy array, and I want to get the \"neighbourhood\" of the i\'th point. Usually the arrays I\'m using are two-dimensional, but the following 1D example illustrates
numpy.take in 'wrap' mode will use your indices modulo the length of the array.
numpy.take
'wrap'
indices = range(i-2,i+3) neighbourhood = A.take(indices, mode='wrap')
See documentation for details numpy.take