I need to flip 3D Array A shaped [m, n, k], along the Z axis. I need plane 0 (A[0,:,:]) to become k-1, plane 1 become k-2 plane and so on.
I need to do that on many array's, and loops are very slow.
I tried:
C = numpy.rot90(A,2)
C = flipud(A)
C = A[::-1]
I tried also rol and reshape, not what I needed.
For example: A is (3, 2, 2)
A= np.array([[[ 1.01551435, -0.76494131],
[ 0.56853752 , 1.94491724]],
[[-0.97433012 , 2.08134198],
[-1.34997602 ,-0.33543117]],
[[ 0.54217072, -1.33470658],
[-0.50179028, -0.66593918]]])
I need to reorder Z axis upside down:
[[ 0.54217072 -1.33470658]
[-0.50179028 -0.66593918]]
[[-0.7703279 0.02402204]
[-0.18006451 -0.37589744]]
[[ 1.01551435 -0.76494131]
[ 0.56853752 1.94491724]]
Any ideas ?
As @hpaulj suggested:
A = A[::-1, :, :]
print A.shape
print A
(3L, 2L, 2L)
[[[ 0.54217072 -1.33470658]
[-0.50179028 -0.66593918]]
[[-0.97433012 2.08134198]
[-1.34997602 -0.33543117]]
[[ 1.01551435 -0.76494131]
[ 0.56853752 1.94491724]]]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With