0

I have the following coordinates stored in arrays that I want to convert into polar coordinates :

import numpy as np

R = 1.;
NcellB = 5;
xm = np.linspace(-R, R,NcellB);
ym = np.linspace(-R, R,NcellB);

Is there a simple and fast way to do it?

3
  • You can find an answer here stackoverflow.com/a/26757297/14280520. Commented Oct 22, 2020 at 14:03
  • I saw this already, it is defined for a single couple (x, y). I was looking for a better way without having to use two for loops, which costs a bit in calculating time... Commented Oct 22, 2020 at 15:25
  • Both np.sqrt and np.arctan2 accept array as input, so no for loop is required. Commented Mar 6, 2023 at 2:54

0

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.