I have a NumPy array 'data' as follows:
data = np.array([
[0.0, 30.0, 60.0, 90.0, 120.0, 150.0, -180.0, -150.0, -120.0, -90.0, -60.0, -30.0],
[0.0, 30.0, 60.0, 90.0, 120.0, 150.0, -180.0, -150.0, -120.0, -90.0, -60.0, -30.0],
[0.0, 30.0, 60.0, 90.0, 120.0, 150.0, -180.0, -150.0, -120.0, -90.0, -60.0, -30.0]])
I want to produce the array 'result' from the given array 'data'. Actually, in the required array, the zero column has to be put on the middle, then the values are increasing towards right direction, while the values are decreasing in the left direction as shown below:
result = np.array([
[-180.0, -150.0, -120.0, -90.0, -60.0, -30.0, 0.0, 30.0, 60.0, 90.0, 120.0, 150.0, 180.0],
[-180.0, -150.0, -120.0, -90.0, -60.0, -30.0, 0.0, 30.0, 60.0, 90.0, 120.0, 150.0, 180.0],
[-180.0, -150.0, -120.0, -90.0, -60.0, -30.0, 0.0, 30.0, 60.0, 90.0, 120.0, 150.0, 180.0]])
The resulted array should be based on index manipulation of the given array. What is the best way of doing it in NumPy?
I tried np.rot90, np.flipud, np.fliprl functions with no success.
However, I could not think how to start.