I wonder if there is a fancy numpy indexing to perform this operation. If I have an array and two limits it is easy to index with colon:
import numpy as np
myArray = np.arange(10)
lowLimit = 2
highLimit = 5
print myArray[lowLimit:highLimit]
which gives [2 3 4]
. However, if you have two arrays for the limits:
lowLimit = np.ones(10) * 2
highLimit = np.ones(10) * 5
The previous operation does not work.
How would you get a 2D array with the sliced regions of myArray?:
array([[2, 3, 4],
[2, 3, 4],
[2, 3, 4],
[2, 3, 4],
[2, 3, 4],
[2, 3, 4],
[2, 3, 4],
[2, 3, 4],
[2, 3, 4],
[2, 3, 4]])
UPDATE: In this example the limit arrays have a constant value but that might not be the case.