Math API#

Angles and vectors#

angle()#

planetary_coverage.math.angle(v1, v2)[source]#

Angular separation between two vectors.

dist()#

planetary_coverage.math.dist(v1, v2)[source]#

Distance between two vectors.

cs()#

planetary_coverage.math.cs(angle)[source]#

Cosines and sines value of an angle (°).

Parameters

angle (float or numpy.ndarray) – Input angle(s) (°).

Returns

Cosine and Sines of this angle(s).

Return type

float or numpy.ndarray

Examples

>>> cs(0)
1, 0
>>> cs(45)
0.707..., 0.707...

lonlat()#

planetary_coverage.math.lonlat(xyz)[source]#

Convert cartesian coordinates into geographic coordinates.

Parameters

xyz (numpy.ndarray) – XYZ cartesian vector.

Returns

East Longitude [0°, 360°[ and North Latitude (°).

Return type

(float, float)

Examples

>>> lonlat([1, 0, 0])
(0, 0)
>>> lonlat([0, 1, 0])
(90, 0)
>>> lonlat([1, 1, 0])
(45, 0)
>>> lonlat([1, 0, 1])
(0, 45)

xyz()#

planetary_coverage.math.xyz(lon_e, lat, r=1)[source]#

Convert geographic coordinates in cartesian coordinates.

Parameters
Returns

Cartesian coordinates.

Return type

[float, float, float]

Examples

>>> xyz(0, 0)
[1, 0, 0]
>>> xyz(90, 0)
[0, 1, 0]
>>> xyz(45, 0)
[0.707..., 0.707..., 0]
>>> xyz(0, 45)
[0.707..., 0, 0.707...]

vdot()#

planetary_coverage.math.vectors.vdot(v1, v2)[source]#

Dot product between two vectors.

norm()#

planetary_coverage.math.vectors.norm(v)[source]#

Vector norm.

Parameters

v (numpy.ndarray) – Input vector to measure(s).

Returns

Input vector norm(s).

Return type

float or numpy.ndarray

Examples

>>> norm([1, 0, 0])
1
>>> norm([1, 1, 1])
1.732050...

hat()#

planetary_coverage.math.vectors.hat(v)[source]#

Normalize vector.

Parameters

v (numpy.ndarray) – Input vector to normalize.

Returns

Normalize input vector.

Return type

numpy.ndarray

Examples

>>> hat([1, 0, 0])
array([1., 0., 0.])
>>> hat([1, 1, 1])
array([0.577..., 0.577..., 0.577...])

Great circles#

great_circle()#

planetary_coverage.math.great_circle(lon_e_1, lat_1, lon_e_2, lat_2, npt=361)[source]#

Great circle through 2 points.

Parameters
  • lon0 (float) – East longitude of the first point (°).

  • lat0 (float) – Latitude of the first point (°).

  • lon_e_1 (float) – East longitude of the second point (°).

  • lat_1 (float) – Latitude of the second point (°).

  • npt (int, optional) – Number of points on the great circle.

Returns

Great circle coordinates.

Return type

numpy.array

great_circle_arc()#

planetary_coverage.math.great_circle_arc(lon_e_1, lat_1, lon_e_2, lat_2, npt=361)[source]#

Great circle arc coordinates between 2 anchor points.

Use Slerp interpolation.

Parameters
  • lon_e_1 (float) – East longitude of the first point (°).

  • lat_1 (float) – Latitude of the first point (°).

  • lon_e_2 (float) – East longitude of the second point (°).

  • lat_2 (float) – Latitude of the second point (°).

  • npt (int, option) – Number of points in the great circle.

Raises

ValueError – If the two longitudes are on the same meridian (±180°).

great_circle_pole()#

planetary_coverage.math.great_circle_pole(lon_e_p, lat_p, npt=361)[source]#

Great circle from its polar axis.

Parameters
  • lon_e_p (float) – Polar axis east longitude (°).

  • lat_p (float) – Polar axis latitude (°).

  • npt (int, optional) – Number of points on the great circle.

Returns

Great circle coordinates.

Return type

numpy.array

great_circle_path()#

planetary_coverage.math.greatcircle.great_circle_path(lon_e_p, lat_p, npt=361, inside=True)[source]#

Great circle path from its polar axis.

Parameters
  • lon_e_p (float) – Polar axis east longitude (°).

  • lat_p (float) – Polar axis latitude (°).

  • npt (int, optional) – Number of points on the great circle.

  • inside (bool, optional) – Close polygon around the polar point if TRUE (default), or around the anti-pole if FALSE.

Returns

Great circle path.

Return type

matplotlib.path.Path

great_circle_patch()#

planetary_coverage.math.greatcircle.great_circle_patch(lon_p, lat_p, npt=361, inside=True, **kwargs)[source]#

Great circle patch from its polar axis.

Parameters
  • lon_p (float) – Polar axis east longitude (°).

  • lat_p (float) – Polar axis latitude (°).

  • npt (int, optional) – Number of points on the great circle.

  • inside (bool, optional) – Close polygon around the polar point if TRUE (default), or around the anti-pole if FALSE.

Returns

Great circle patch.

Return type

matplotlib.patches.PathPatch

Projections#

scalar_proj()#

planetary_coverage.math.vectors.scalar_proj(v, n)[source]#

Scalar projection.

s   `n`
o---|---->
\
\ `v`
x

    `v` · `n`
s = ---------
      ||n||
Parameters
Returns

Scalar resolute of v in the direction of n.

Return type

float or numpy.ndarray

scalar_rejection()#

planetary_coverage.math.vectors.scalar_rejection(v, n)[source]#

Scalar rejection.

Orthogonal component u of the vector v in the plane of normal n. Also known as perpendicular dot product.

        `n`
    o-------->
    |\
`u` | \ `v`
    v  x

            `v` · `n`
`u` = `v` - --------- `n`
              ||n||


p² = ||u||² = ||v||² - [(`v` · `n`) / ||n||]²
Parameters
Returns

Scalar resolute of v orthogonal to the direction of n.

Return type

float or numpy.ndarray

vector_rejection()#

planetary_coverage.math.vectors.vector_rejection(v, n)[source]#

Vector rejection.

Orthogonal vector u of the vector v in the plane of normal n.

        `n`
    o-------->
    |\
`u` | \ `v`
    v  x

            `v` · `n`
`u` = `v` - --------- `n`
              ||n||
Parameters
Returns

Scalar resolute of v orthogonal to the direction of n.

Return type

float or numpy.ndarray

Sphere functions#

hav_dist()#

planetary_coverage.math.hav_dist(lon_e_1, lat_1, lon_e_2, lat_2, r=1)[source]#

Calculate distance between 2 points on a sphere.

Parameters
Returns

Haversine distance between the 2 points.

Return type

float or numpy.ndarray

sph_pixel_scale()#

planetary_coverage.math.sphere.sph_pixel_scale(e, ifov, d, r)[source]#

Compute pixel scale in spherical geometry.

Project both sides of the pixel iFOV on the sphere and measure its extend on the surface.

If the pixel extend above the limb, a NaN will be return.

Pixel scale spherical geometry calculation.
Parameters
  • e (float, list or numpy.ndarray) – Local emission angle (in degrees).

  • ifov (float) – Pixel instantaneous field of view (in radians).

  • d (float, list or numpy.ndarray) – Distance from the observer to the target body center (in km).

  • r (float) – Target body radius (in km).

Returns

Pixel scale on the surface (in km) and NaN if the pixel extend above the limb.

Return type

float

Raises

ValueError – If the observer distance is smaller than the target radius.