contrailopt.slerp¶
Spherical geometry helpers using SLERP (Spherical Linear intERPolation).
https://en.wikipedia.org/wiki/Spherical_linear_interpolation
These are rougher than pyproj in that they model Earth as a perfect sphere rather than a WGS84 ellipsoid but significantly faster for vectorized numpy operations.
The pycontrails library already includes geo.haversine and geo.azimuth
functions for computing great circle distances and azimuths. The functions here extend
those utilities with forward projection and interpolation capabilities.
Functions
|
Interpolate along great circles via SLERP. |
|
Return n equally-spaced intermediate points along a great circle. |
|
Project from |
- contrailopt.slerp.spherical_fwd(lon: NDArray[floating], lat: NDArray[floating], az: NDArray[floating], dist: NDArray[floating]) tuple[NDArray[floating], NDArray[floating]][source]¶
Project from
(lon, lat)along azimuthazbydistmeters on a sphere.Equivalent to
lon2, lat2, _ = geod.fwd(lon, lat, az, dist).- Parameters:
lon (
numpy.ndarray) – Longitude of starting point, [\(\deg\)].lat (
numpy.ndarray) – Latitude of starting point, [\(\deg\)].az (
numpy.ndarray) – Forward azimuth, [\(\deg\)].dist (
numpy.ndarray) – Distance to project, [\(m\)].
- Returns:
Longitude and latitude of projected point, [\(\deg\)].
- Return type:
tuple[npt.NDArray[np.floating],npt.NDArray[np.floating]]
- contrailopt.slerp.gc_interp(lon1: NDArray[floating], lat1: NDArray[floating], lon2: NDArray[floating], lat2: NDArray[floating], frac: NDArray[floating]) tuple[NDArray[floating], NDArray[floating]][source]¶
Interpolate along great circles via SLERP.
Equivalent to
geod.fwd(lon1, lat1, az, frac * dist)but without requiring a separategeod.invcall to obtainazanddist.- Parameters:
lon1 (
numpy.ndarray) – Longitude of source, [\(\deg\)].lat1 (
numpy.ndarray) – Latitude of source, [\(\deg\)].lon2 (
numpy.ndarray) – Longitude of destination, [\(\deg\)].lat2 (
numpy.ndarray) – Latitude of destination, [\(\deg\)].frac (
numpy.ndarray) – Fractional position along the arc, 0 = source, 1 = dest.
- Returns:
Interpolated longitude and latitude, [\(\deg\)].
- Return type:
tuple[npt.NDArray[np.floating],npt.NDArray[np.floating]]
- contrailopt.slerp.gc_npts(lon1: float, lat1: float, lon2: float, lat2: float, n: int) tuple[NDArray[float64], NDArray[float64]][source]¶
Return n equally-spaced intermediate points along a great circle.
Excludes the endpoints themselves. Equivalent to
geod.npts(lon1, lat1, lon2, lat2, n).- Parameters:
- Returns:
Longitude and latitude of intermediate points, [\(\deg\)]. These arrays always have dtype
np.float64.- Return type:
tuple[npt.NDArray[np.float64],npt.NDArray[np.float64]]