0

How to change the ARRAY U(Nz,Ny, Nx) to U(Nx,Ny, Nz) by using numpy? thanks

DaMi
  • 75
  • 1
  • 7

2 Answers2

5

Just numpy.transpose(U) or U.T.

user6758673
  • 579
  • 2
  • 4
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

Community
  • 1
  • 1
scomes
  • 1,756
  • 14
  • 19