contrailopt.slerp¶
Spherical geometry helpers using SLERP (Spherical Linear intERPolation).
See Spherical linear interpolation.
These are rougher than pyproj in that they model Earth as a perfect sphere of radius
pycontrails.physics.constants.radius_earth rather than a WGS84 ellipsoid but
significantly faster for vectorized numpy operations.
The pycontrails library already includes pycontrails.physics.geo.haversine() and
pycontrails.physics.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
pyproj.Geod.fwd(), which returnslon2, lat2, _.- 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:
lon2 (
numpy.ndarray) – Longitude of projected point, [\(\deg\)].lat2 (
numpy.ndarray) – Latitude of projected point, [\(\deg\)].
- 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
pyproj.Geod.fwd()evaluated atfrac * dist, but without the separatepyproj.Geod.inv()call 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:
lon (
numpy.ndarray) – Interpolated longitude, [\(\deg\)].lat (
numpy.ndarray) – Interpolated latitude, [\(\deg\)].
- 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
pyproj.Geod.npts().- Parameters:
- Returns:
lon (
numpy.ndarray) – Longitude of intermediate points, [\(\deg\)]. Alwaysnp.float64.lat (
numpy.ndarray) – Latitude of intermediate points, [\(\deg\)]. Alwaysnp.float64.