rad2deg()

Returns array with radian values.
aInput array with degree
outOptional , ndarray to store result
whereOptional , array with True to get values and False to leave the value

Examples

We will use the options in our sample scripts.
import numpy as np
# input in radians
ar_rad=np.array([1.57079633, 2.0943951,  2.7925268,3.14159265])
ar_deg=np.rad2deg(ar_rad)
print(ar_deg) # output in degree
Output
[ 90.00000018 119.99999986 159.99999982 179.99999979]
In above output in degree we can use round() to roundup the values to nearest number. The last line we will change.
print(np.round(ar_deg))
Output
[ 90. 120. 160. 180.]

dtype

We will use dtype=float
import numpy as np
ar_rad=np.array([2.0943951,  2.7925268,  3.14159265])
ar_deg=np.rad2deg(ar_rad,dtype=float)
print(ar_deg)
Output
[119.99999986 159.99999982 179.99999979]

where

Value to convert to radian or not we can decide by using another array filled with True and False.
import numpy as np
ar_rad=np.array([2.0943951,  2.7925268,  3.14159265])
ar_where=np.array([True,False,True])
ar_deg=np.rad2deg(ar_rad,where=ar_where)
print(ar_deg)
Output
[119.99999986   2.7925268  179.99999979]

out

We can store the output in an array. We used shape() to create array (ar_out) of same shape() of our main array ar_rad.
We used ones() to create array of same shape() of our input array with degree values.
import numpy as np
ar_rad=np.array([2.0943951,  2.7925268,  3.14159265])
ar_out=np.ones(ar_rad.shape)
ar_deg=np.rad2deg(ar_rad,out=ar_out)
print(ar_deg)
print(ar_out)

print(ar_rad is ar_out)
Output
[119.99999986 159.99999982 179.99999979]
[119.99999986 159.99999982 179.99999979]
False
Numpy radians() bincount() arange() linspace()
Subhendu Mohapatra — author at plus2net
Subhendu Mohapatra

Author

🎥 Join me live on YouTube

Passionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.



Subscribe to our YouTube Channel here



plus2net.com







Python Video Tutorials
Python SQLite Video Tutorials
Python MySQL Video Tutorials
Python Tkinter Video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer