clouddrift.sphere.plane_to_sphere

clouddrift.sphere.plane_to_sphere#

clouddrift.sphere.plane_to_sphere(x: ndarray, y: ndarray, lon_origin: float = 0, lat_origin: float = 0) tuple[ndarray, ndarray][source]#

Convert Cartesian coordinates on a plane to spherical coordinates.

The arrays of input zonal and meridional displacements x and y are assumed to follow a contiguous trajectory. The spherical coordinate of each successive point is determined by following a great circle path from the previous point. The spherical coordinate of the first point is determined by following a great circle path from the origin, by default (0, 0).

The output arrays have the same floating-point output type as the input.

If projecting multiple trajectories onto the same plane, use apply_ragged() for highest accuracy.

Parameters#

xnp.ndarray

An N-d array of zonal displacements in meters

ynp.ndarray

An N-d array of meridional displacements in meters

lon_originfloat, optional

Origin longitude of the tangent plane in degrees, default 0

lat_originfloat, optional

Origin latitude of the tangent plane in degrees, default 0

Returns#

lonnp.ndarray

Longitude in degrees

latnp.ndarray

Latitude in degrees

Examples#

>>> plane_to_sphere(np.array([0., 0.]), np.array([0., 1000.]))
(array([0.00000000e+00, 5.50062664e-19]), array([0.       , 0.0089832]))

You can also specify an origin longitude and latitude:

>>> plane_to_sphere(np.array([0., 0.]), np.array([0., 1000.]), lon_origin=1, lat_origin=0)
(array([1., 1.]), array([0.       , 0.0089832]))

Raises#

AttributeError

If x and y are not NumPy arrays

See Also#

sphere_to_plane()