spatial.py
Utilities for operating on spatial data
General Methods
- spatial_interpolators.spatial.data_type(x, y, t)[source]
Determines input data type based on variable dimensions
- Parameters
- x: float
x-dimension coordinates
- y: float
y-dimension coordinates
- t: float
time-dimension coordinates
- Returns
- string denoting input data type
'time series''drift''grid'
- spatial_interpolators.spatial.convert_ellipsoid(phi1, h1, a1, f1, a2, f2, eps=1e-12, itmax=10)[source]
Convert latitudes and heights to a different ellipsoid using Newton-Raphson
- Parameters
- phi1: float
latitude of input ellipsoid in degrees
- h1: float
height above input ellipsoid in meters
- a1: float
semi-major axis of input ellipsoid
- f1: float
flattening of input ellipsoid
- a2: float
semi-major axis of output ellipsoid
- f2: float
flattening of output ellipsoid
- eps: float, default 1e-12
tolerance to prevent division by small numbers and to determine convergence
- itmax: int, default 10
maximum number of iterations to use in Newton-Raphson
- Returns
- phi2: float
latitude of output ellipsoid in degrees
- h2: float
height above output ellipsoid in meters
References
- 1
J Meeus, Astronomical Algorithms, pp. 77-82 (1991)
- spatial_interpolators.spatial.compute_delta_h(a1, f1, a2, f2, lat)[source]
- Compute difference in elevation for two ellipsoids at a given
latitude using a simplified empirical equation
- Parameters
- a1: float
semi-major axis of input ellipsoid
- f1: float
flattening of input ellipsoid
- a2: float
semi-major axis of output ellipsoid
- f2: float
flattening of output ellipsoid
- lat: float
latitudes (degrees north)
- Returns
- delta_h: float
difference in elevation for two ellipsoids
References
- 1
J Meeus, Astronomical Algorithms, pp. 77-82 (1991)
- spatial_interpolators.spatial.wrap_longitudes(lon)[source]
Wraps longitudes to range from -180 to +180
- Parameters
- lon: float
longitude (degrees east)
- spatial_interpolators.spatial.to_cartesian(lon, lat, h=0.0, a_axis=6378137.0, flat=0.0033528106647474805)[source]
Converts geodetic coordinates to Cartesian coordinates
- Parameters
- lon: float
longitude (degrees east)
- lat: float
latitude (degrees north)
- h: float, default 0.0
height above ellipsoid (or sphere)
- a_axis: float, default 6378137.0
semimajor axis of the ellipsoid for spherical coordinates set to radius of the Earth
- flat: float, default 1.0/298.257223563
ellipsoidal flattening for spherical coordinates set to 0
- spatial_interpolators.spatial.to_sphere(x, y, z)[source]
Convert from cartesian coordinates to spherical coordinates
- Parameters
- x, float
cartesian x-coordinates
- y, float
cartesian y-coordinates
- z, float
cartesian z-coordinates
- spatial_interpolators.spatial.to_geodetic(x, y, z, a_axis=6378137.0, flat=0.0033528106647474805)[source]
Convert from cartesian coordinates to geodetic coordinates using a closed form solution
- Parameters
- x, float
cartesian x-coordinates
- y, float
cartesian y-coordinates
- z, float
cartesian z-coordinates
- a_axis: float, default 6378137.0
semimajor axis of the ellipsoid
- flat: float, default 1.0/298.257223563
ellipsoidal flattening
References
- 1
J Zhu “Exact conversion of Earth-centered, Earth-fixed coordinates to geodetic coordinates” Journal of Guidance, Control, and Dynamics, 16(2), 389–391, 1993 https://arc.aiaa.org/doi/abs/10.2514/3.21016
- spatial_interpolators.spatial.scale_areas(lat, flat=0.0033528106647474805, ref=70.0)[source]
Calculates area scaling factors for a polar stereographic projection including special case of at the exact pole
- Parameters
- lat: float,
latitude (degrees north)
- flat: float, default 1.0/298.257223563
ellipsoidal flattening
- ref: float, default 70.0
reference latitude (true scale latitude)
- Returns
- scale: float
area scaling factors at input latitudes
References
- 1
Snyder, J P (1982) Map Projections used by the U.S. Geological Survey Forward formulas for the ellipsoid. Geological Survey Bulletin 1532, U.S. Government Printing Office.
- 2
JPL Technical Memorandum 3349-85-101