How to change the ARRAY U(Nz,Ny, Nx) to U(Nx,Ny, Nz) by using numpy? thanks
Asked
Active
Viewed 85 times
2 Answers
5
Just numpy.transpose(U)
or U.T
.

user6758673
- 579
- 2
- 4
-
you might need a copy if you want more than just a view – Henry Gomersall Sep 28 '16 at 13:13
2
In general, if you want to change the order of data in numpy array, see http://docs.scipy.org/doc/numpy-1.10.1/reference/routines.array-manipulation.html#rearranging-elements.
The np.fliplr()
and np.flipud()
functions can be particularly useful when the transpose is not actually what you want.
Additionally, more general element reordering can be done by creating an index mask, partially explained here