def cart2sph(x, y, z):
"""
Converts cartesian coordinates `x`, `y`, `z` into a longitude and latitude.
x=0, y=0, z=0 is assumed to correspond to the center of the globe.
Returns lon and lat in radians.
Parameters
----------
`x`, `y`, `z` : Arrays of cartesian coordinates
Returns
-------
lon : Longitude in radians
lat : Latitude in radians
"""
r = np.sqrt(x**2 + y**2 + z**2)
lat = np.arcsin(z/r)
lon = np.arctan2(y, x)
return lon, lat
评论列表
文章目录