python – numpy arctan2 bug or usage issues?

python – numpy arctan2 bug or usage issues?

From the Excel docs:

The syntax for the ATAN2 function is:

ATAN2( x-coordinate, y-coordinate )

From the numpy docs:

numpy.arctan2(x1, x2[, out])

Element-wise arc tangent of x1/x2 choosing the quadrant correctly.

The quadrant (i.e., branch) is chosen so that arctan2(x1, x2) is the
signed angle in radians between the ray ending at the origin and
passing through the point (1,0), and the ray ending at the origin and
passing through the point (x2, x1). (Note the role reversal: the
“y-coordinate” is the first function parameter, the “x-coordinate” is
the second.)

They take their arguments in opposite order. Thus:

In [31]: arctan2(cos(deg2rad(sal)), cos(deg2rad(oc))*sin(deg2rad(sal)))
Out[31]: 0.0041572064598812417

In [32]: arctan2(cos(deg2rad(oc))*sin(deg2rad(sal)), cos(deg2rad(sal)))
Out[32]: 1.5666391203350154

python – numpy arctan2 bug or usage issues?

Leave a Reply

Your email address will not be published.