spherical_distance_to

sofia_redux.scan.coordinate_systems.coordinate_systems_numba_functions.spherical_distance_to(x, rx, cos_lat, sin_lat, r_cos_lat, r_sin_lat)[source]

Return the angular distance in radians between spherical coordinate sets.

Calculates the distance between two spherical sets of coordinates using either the law of cosines or Vincenty’s formulae. First we calculate c as:

c = sin(y) * sin(ry) + cos(y) * phi

where:

phi = cos(ry) * cos(rx - x)

and x, rx are the longitudinal coordinates or the coordinates and reference coordinates respectively, and (y, ry) are the latitudinal coordinates.

if |c| > 0.9 (indicating intermediate distances), the law of cosines is used to return an angle (a) of:

a = acos(c)

Otherwise, Vincenty’s formula is used to return a value of:

a = atan2(B, c)

where:

B = sqrt((cos(ry) * sin(rx - x))^2 + (cos(y) * sin(ry) - sin(y) * phi)^2)
Parameters:
xnumpy.ndarray (float)

The x-direction spherical coordinates in radians of the coordinate to test. Must either be of shape (1,) or (n,).

rxnumpy.ndarray (float)

The x-direction spherical reference coordinate in radians. Must either be of shape (1,) or (n,).

cos_latnumpy.ndarray (float)

The cosine(Latitude) of the spherical coordinate. Must match the shape of x.

sin_latnumpy.ndarray (float)

The sine(Latitude) of the spherical coordinate. Must match the shape of x.

r_cos_latnumpy.ndarray (float)

The cosine(Latitude) of the spherical reference coordinate. Must match the shape of rx.

r_sin_latnumpy.ndarray (float)

The sine(Latitude) of the spherical reference coordinate. Must match the shape of rx.

Returns:
distancenumpy.ndarray (float)

The distance in radians between the coordinates and reference coordinates. Will be of shape (1,) or (n,) depending on x and rx.