0

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

2 Answers 2

5

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

Sign up to request clarification or add additional context in comments.

1 Comment

you might need a copy if you want more than just a view
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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.