radians()


Youtube Live session on Tkinter

Numpy Math Functions

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
ar_deg=np.array([20,90,120,160,180]) # input array in degree
ar_rad=np.radians(ar_deg)
print(ar_rad) # output in radian
Output
[0.34906585 1.57079633 2.0943951  2.7925268  3.14159265]

dtype

We will use dtype=float
import numpy as np
ar_deg=np.array([20,90,120,160,180])
ar_rad=np.radians(ar_deg,dtype=float)
print(ar_rad)
Output
[0.34906585 1.57079633 2.0943951  2.7925268  3.14159265]

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_deg=np.array([120,160,180])
ar_where=np.array([True,False,True])
ar_rad=np.radians(ar_deg,where=ar_where)
print(ar_rad)
Output
[2.09439510e+000 7.90505033e-322 3.14159265e+000]

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_deg.
We used ones() to create array of same shape() of our input array with degree values.
import numpy as np
ar_deg=np.array([120,160,180])
ar_out=np.ones(ar_deg.shape) # array created to store result 
ar_rad=np.radians(ar_deg,out=ar_out)
print(ar_rad)
print(ar_out)
# check of both arrays are same or not
print(ar_rad is ar_out) # True
Output
[2.0943951  2.7925268  3.14159265]
[2.0943951  2.7925268  3.14159265]
True
Numpy rad2deg() bincount() arange() linspace()
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    Post your comments , suggestion , error , requirements etc here





    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 FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer