The ellipsoids Module¶
|
Represents an ellipsoid of revolution (possibly a sphere) with a geodetic longitude-latitude coordinate frame. |
This Python 3.11 code implements ellipsoids of revolution.
Alexander Raichev (AR), 2012-01-26: Refactored code from release 0.3.
NOTE:
All lengths are measured in meters and all angles are measured in radians unless indicated otherwise.
By ‘ellipsoid’ throughout, I mean an ellipsoid of revolution and not a general (triaxial) ellipsoid. Points lying on an ellipsoid are given in geodetic (longitude, latitude) coordinates.
- class rhealpixdggs.ellipsoids.Ellipsoid(R: float | None = None, a: float = 6378137.0, b: float | None = None, e: float | None = None, f: float = 0.0033528106647474805, lon_0: float = 0, lat_0: float = 0, radians: bool = False)[source]¶
Bases:
objectRepresents an ellipsoid of revolution (possibly a sphere) with a geodetic longitude-latitude coordinate frame.
INSTANCE ATTRIBUTES:
sphere - True if the ellipsoid is a sphere, and False otherwise.
R - The radius of the ellipsoid in meters, implying that it is a sphere.
a - Major radius of the ellipsoid in meters.
b - Minor radius of the ellipsoid in meters.
e - Eccentricity of the ellipsoid.
f - Flattening of the ellipsoid.
R_A - Authalic radius of the ellipsoid in meters.
lon_0 - Central meridian. Projections and grids built on the ellipsoid are rotated about the polar axis so that this meridian becomes the planar x = 0 line.
lat_0 - Latitude of origin. Must be 0. Shifting latitude is not a rotation of an ellipsoid of revolution: a grid built on a shifted latitude is neither equal-area nor geographically coherent near the poles (issue #93). The attribute is kept so that the names match PROJ’s; reorient a grid with lon_0 and the DGGS’s north_square and south_square instead.
radians - If True, use angles measured in radians for all calculations. Use degrees otherwise.
phi_0 - The latitude separating the equatorial region and the north polar region in the context of the (r)HEALPix projection.
Except for phi_0, these attribute names match the names of the PROJ ellipsoid parameters <https://proj.org/en/9.4/usage/ellipsoids.html#ellipsoid-spherification-parameters>
- random_point(lam_min: float | None = None, lam_max: float | None = None, phi_min: float | None = None, phi_max: float | None = None) tuple[float, float][source]¶
Return a point (given in geodetic coordinates) sampled uniformly at random from the section of this ellipsoid with longitude in the range lam_min <= lam < lam_max and latitude in the range phi_min <= phi < phi_max. But avoid the poles.
EXAMPLES:
>>> E = UNIT_SPHERE >>> print(E.random_point()) (-1.0999574573422948, 0.21029104897701129)
- xyz(lam: float, phi: float) tuple[float, float, float][source]¶
Given a point on this ellipsoid with longitude-latitude coordinates (lam, phi), return the point’s 3D rectangular coordinates.
EXAMPLES:
>>> E = UNIT_SPHERE >>> print(tuple(x.tolist() for x in my_round(E.xyz(0, 45), 15))) (0.707106781186548, 0.0, 0.707106781186548)