The ellipsoids Module¶
|
Represents an ellipsoid of revolution (possibly a sphere) with a geodetic longitude-latitude coordinate frame. |
Ellipsoids of revolution: Ellipsoid and the WGS84 and unit
sphere instances the grids are built on.
Lengths are in metres and angles in degrees, or in radians when the
ellipsoid is built with radians=True. An ellipsoid is an ellipsoid
of revolution, never a triaxial one, and a point on it is given as
(longitude, latitude).
- 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, rng: Random | 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. The draw comes from rng, a
random.Random, so a seeded one makes it reproducible; by default it is fresh and unseeded.EXAMPLES:
>>> from random import Random >>> E = UNIT_SPHERE >>> print(E.random_point(rng=Random(1))) (-131.62887211953554, 44.01665753153827)
- 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)