Coverage for pygeodesy/ellipsoids.py: 96%

760 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-09-09 13:03 -0400

1 

2# -*- coding: utf-8 -*- 

3 

4u'''Ellipsoidal and spherical earth models. 

5 

6Classes L{a_f2Tuple}, L{Ellipsoid} and L{Ellipsoid2}, an L{Ellipsoids} registry and 

72 dozen functions to convert I{equatorial} radius, I{polar} radius, I{eccentricities}, 

8I{flattenings} and I{inverse flattening}. 

9 

10See module L{datums} for L{Datum} and L{Transform} information and other details. 

11 

12Following is the list of predefined L{Ellipsoid}s, all instantiated lazily. 

13 

14@var Ellipsoids.Airy1830: Ellipsoid(name='Airy1830', a=6377563.396, f=0.00334085, f_=299.3249646, b=6356256.90923729) 

15@var Ellipsoids.AiryModified: Ellipsoid(name='AiryModified', a=6377340.189, f=0.00334085, f_=299.3249646, b=6356034.44793853) 

16@var Ellipsoids.ATS1977: Ellipsoid(name='ATS1977', a=6378135, f=0.00335281, f_=298.257, b=6356750.30492159) 

17@var Ellipsoids.Australia1966: Ellipsoid(name='Australia1966', a=6378160, f=0.00335289, f_=298.25, b=6356774.71919531) 

18@var Ellipsoids.Bessel1841: Ellipsoid(name='Bessel1841', a=6377397.155, f=0.00334277, f_=299.1528128, b=6356078.962818) 

19@var Ellipsoids.BesselModified: Ellipsoid(name='BesselModified', a=6377492.018, f=0.00334277, f_=299.1528128, b=6356173.5087127) 

20@var Ellipsoids.CGCS2000: Ellipsoid(name='CGCS2000', a=6378137, f=0.00335281, f_=298.2572221, b=6356752.31414036) 

21@var Ellipsoids.Clarke1866: Ellipsoid(name='Clarke1866', a=6378206.4, f=0.00339008, f_=294.97869821, b=6356583.8) 

22@var Ellipsoids.Clarke1880: Ellipsoid(name='Clarke1880', a=6378249.145, f=0.00340756, f_=293.465, b=6356514.86954978) 

23@var Ellipsoids.Clarke1880IGN: Ellipsoid(name='Clarke1880IGN', a=6378249.2, f=0.00340755, f_=293.46602129, b=6356515) 

24@var Ellipsoids.Clarke1880Mod: Ellipsoid(name='Clarke1880Mod', a=6378249.145, f=0.00340755, f_=293.46630766, b=6356514.96639549) 

25@var Ellipsoids.CPM1799: Ellipsoid(name='CPM1799', a=6375738.7, f=0.00299052, f_=334.39, b=6356671.92557493) 

26@var Ellipsoids.Delambre1810: Ellipsoid(name='Delambre1810', a=6376428, f=0.00321027, f_=311.5, b=6355957.92616372) 

27@var Ellipsoids.Engelis1985: Ellipsoid(name='Engelis1985', a=6378136.05, f=0.00335282, f_=298.2566, b=6356751.32272154) 

28@var Ellipsoids.Everest1969: Ellipsoid(name='Everest1969', a=6377295.664, f=0.00332445, f_=300.8017, b=6356094.667915) 

29@var Ellipsoids.Everest1975: Ellipsoid(name='Everest1975', a=6377299.151, f=0.00332445, f_=300.8017255, b=6356098.14512013) 

30@var Ellipsoids.Fisher1968: Ellipsoid(name='Fisher1968', a=6378150, f=0.00335233, f_=298.3, b=6356768.33724438) 

31@var Ellipsoids.GEM10C: Ellipsoid(name='GEM10C', a=6378137, f=0.00335281, f_=298.2572236, b=6356752.31424783) 

32@var Ellipsoids.GPES: Ellipsoid(name='GPES', a=6378135, f=0, f_=0, b=6378135) 

33@var Ellipsoids.GRS67: Ellipsoid(name='GRS67', a=6378160, f=0.00335292, f_=298.24716743, b=6356774.51609071) 

34@var Ellipsoids.GRS80: Ellipsoid(name='GRS80', a=6378137, f=0.00335281, f_=298.2572221, b=6356752.31414035) 

35@var Ellipsoids.Helmert1906: Ellipsoid(name='Helmert1906', a=6378200, f=0.00335233, f_=298.3, b=6356818.16962789) 

36@var Ellipsoids.IAU76: Ellipsoid(name='IAU76', a=6378140, f=0.00335281, f_=298.257, b=6356755.28815753) 

37@var Ellipsoids.IERS1989: Ellipsoid(name='IERS1989', a=6378136, f=0.00335281, f_=298.257, b=6356751.30156878) 

38@var Ellipsoids.IERS1992TOPEX: Ellipsoid(name='IERS1992TOPEX', a=6378136.3, f=0.00335281, f_=298.25722356, b=6356751.61659215) 

39@var Ellipsoids.IERS2003: Ellipsoid(name='IERS2003', a=6378136.6, f=0.00335282, f_=298.25642, b=6356751.85797165) 

40@var Ellipsoids.Intl1924: Ellipsoid(name='Intl1924', a=6378388, f=0.003367, f_=297, b=6356911.94612795) 

41@var Ellipsoids.Intl1967: Ellipsoid(name='Intl1967', a=6378157.5, f=0.0033529, f_=298.24961539, b=6356772.2) 

42@var Ellipsoids.Krassovski1940: Ellipsoid(name='Krassovski1940', a=6378245, f=0.00335233, f_=298.3, b=6356863.01877305) 

43@var Ellipsoids.Krassowsky1940: Ellipsoid(name='Krassowsky1940', a=6378245, f=0.00335233, f_=298.3, b=6356863.01877305) 

44@var Ellipsoids.Maupertuis1738: Ellipsoid(name='Maupertuis1738', a=6397300, f=0.0052356, f_=191, b=6363806.28272251) 

45@var Ellipsoids.Mercury1960: Ellipsoid(name='Mercury1960', a=6378166, f=0.00335233, f_=298.3, b=6356784.28360711) 

46@var Ellipsoids.Mercury1968Mod: Ellipsoid(name='Mercury1968Mod', a=6378150, f=0.00335233, f_=298.3, b=6356768.33724438) 

47@var Ellipsoids.NWL1965: Ellipsoid(name='NWL1965', a=6378145, f=0.00335289, f_=298.25, b=6356759.76948868) 

48@var Ellipsoids.OSU86F: Ellipsoid(name='OSU86F', a=6378136.2, f=0.00335281, f_=298.2572236, b=6356751.51693008) 

49@var Ellipsoids.OSU91A: Ellipsoid(name='OSU91A', a=6378136.3, f=0.00335281, f_=298.2572236, b=6356751.6165948) 

50@var Ellipsoids.Plessis1817: Ellipsoid(name='Plessis1817', a=6376523, f=0.00324002, f_=308.64, b=6355862.93325557) 

51@var Ellipsoids.PZ90: Ellipsoid(name='PZ90', a=6378136, f=0.0033528, f_=298.2578393, b=6356751.36174571) 

52@var Ellipsoids.SGS85: Ellipsoid(name='SGS85', a=6378136, f=0.00335281, f_=298.257, b=6356751.30156878) 

53@var Ellipsoids.SoAmerican1969: Ellipsoid(name='SoAmerican1969', a=6378160, f=0.00335289, f_=298.25, b=6356774.71919531) 

54@var Ellipsoids.Sphere: Ellipsoid(name='Sphere', a=6371008.771415, f=0, f_=0, b=6371008.771415) 

55@var Ellipsoids.SphereAuthalic: Ellipsoid(name='SphereAuthalic', a=6371000, f=0, f_=0, b=6371000) 

56@var Ellipsoids.SpherePopular: Ellipsoid(name='SpherePopular', a=6378137, f=0, f_=0, b=6378137) 

57@var Ellipsoids.Struve1860: Ellipsoid(name='Struve1860', a=6378298.3, f=0.00339294, f_=294.73, b=6356657.14266956) 

58@var Ellipsoids.WGS60: Ellipsoid(name='WGS60', a=6378165, f=0.00335233, f_=298.3, b=6356783.28695944) 

59@var Ellipsoids.WGS66: Ellipsoid(name='WGS66', a=6378145, f=0.00335289, f_=298.25, b=6356759.76948868) 

60@var Ellipsoids.WGS72: Ellipsoid(name='WGS72', a=6378135, f=0.00335278, f_=298.26, b=6356750.52001609) 

61@var Ellipsoids.WGS84: Ellipsoid(name='WGS84', a=6378137, f=0.00335281, f_=298.25722356, b=6356752.31424518) 

62@var Ellipsoids.WGS84_NGS: Ellipsoid(name='WGS84_NGS', a=6378137, f=0.00335281, f_=298.2572221, b=6356752.31414035) 

63''' 

64# make sure int/int division yields float quotient, see .basics 

65from __future__ import division as _; del _ # noqa: E702 ; 

66 

67# from pygeodesy.albers import AlbersEqualAreaCylindrical # _MODS 

68from pygeodesy.basics import copysign0, isbool, _isin, isint, typename 

69from pygeodesy.constants import EPS, EPS_2, EPS0, EPS02, EPS1, INF, NINF, \ 

70 _over, PI_2, PI_3, PI4, R_M, R_MA, R_FM, _EPSqrt, \ 

71 _EPStol as _TOL, _floatuple as _T, _isfinite, \ 

72 _0_0s, _0_0, _0_5, _1_0, _1_EPS, _2_0, _4_0, _90_0, \ 

73 _0_25, _3_0 # PYCHOK used! 

74from pygeodesy.errors import _AssertionError, IntersectionError, _ValueError, _xattr, _xkwds_not 

75from pygeodesy.fmath import cbrt, cbrt2, fdot, Fhorner, fpowers, hypot, hypot_, \ 

76 hypot1, hypot2, sqrt3, Fsum 

77# from pygeodesy.fsums import Fsum # from .fmath 

78# from pygeodesy.internals import typename # from .basics 

79from pygeodesy.interns import NN, _a_, _Airy1830_, _AiryModified_, _b_, _Bessel1841_, _beta_, \ 

80 _Clarke1866_, _Clarke1880IGN_, _DMAIN_, _DOT_, _f_, _GRS80_, \ 

81 _height_, _Intl1924_, _incompatible_, _invalid_, _Krassovski1940_, \ 

82 _Krassowsky1940_, _lat_, _meridional_, _negative_, _not_finite_, \ 

83 _prime_vertical_, _radius_, _Sphere_, _SPACE_, _vs_, _WGS72_, _WGS84_ 

84# from pygeodesy.lazily import _ALL_LAZY, _ALL_MODS as _MODS # from .named 

85from pygeodesy.named import _lazyNamedEnumItem as _lazy, _name__, _NamedEnum, \ 

86 _NamedEnumItem, _NamedTuple, _Pass, _ALL_LAZY, _MODS 

87from pygeodesy.namedTuples import Distance2Tuple, Vector3Tuple, Vector4Tuple 

88from pygeodesy.props import deprecated_Property_RO, Property_RO, property_doc_, \ 

89 deprecated_property_RO, property_RO, property_ROver 

90from pygeodesy.streprs import Fmt, fstr, instr, strs, unstr 

91# from pygeodesy.triaxials import _hartzell3 # _MODS 

92from pygeodesy.units import Azimuth, Bearing, Distance, Float, Float_, Height, Lamd, Lat, \ 

93 Meter, Meter2, Meter3, Phi, Phid, Radius, Radius_, Scalar 

94from pygeodesy.utily import atan1, atan1d, atan2b, degrees90, m2radians, radians2m, sincos2d 

95 

96from math import asinh, atan, atanh, cos, degrees, exp, fabs, radians, sin, sinh, sqrt, tan # as _tan 

97 

98__all__ = _ALL_LAZY.ellipsoids 

99__version__ = '25.08.31' 

100 

101_f_0_0 = Float(f =_0_0) # zero flattening 

102_f__0_0 = Float(f_=_0_0) # zero inverse flattening 

103# see U{WGS84_f<https://GeographicLib.SourceForge.io/C++/doc/classGeographicLib_1_1Constants.html>} 

104_f__WGS84 = Float(f_=_1_0 / (1000000000 / 298257223563)) # 298.257223562_999_97 vs 298.257223563 

105 

106 

107def _aux(lat, inverse, auxLat, clip=90): 

108 '''Return a named auxiliary latitude in C{degrees}. 

109 ''' 

110 return Lat(lat, clip=clip, name=_lat_ if inverse else typename(auxLat)) 

111 

112 

113def _s2_c2(phi): 

114 '''(INTERNAL) Return 2-tuple C{(sin(B{phi})**2, cos(B{phi})**2)}. 

115 ''' 

116 if phi: 

117 s2 = sin(phi)**2 

118 if s2 > EPS: 

119 c2 = _1_0 - s2 

120 if c2 > EPS: 

121 if c2 < EPS1: 

122 return s2, c2 

123 else: 

124 return _1_0, _0_0 # phi == PI_2 

125 return _0_0, _1_0 # phi == 0 

126 

127 

128class a_f2Tuple(_NamedTuple): 

129 '''2-Tuple C{(a, f)} specifying an ellipsoid by I{equatorial} 

130 radius C{a} in C{meter} and scalar I{flattening} C{f}. 

131 

132 @see: Class L{Ellipsoid2}. 

133 ''' 

134 _Names_ = (_a_, _f_) # name 'f' not 'f_' 

135 _Units_ = (_Pass, _Pass) 

136 

137 def __new__(cls, a, f, **name): 

138 '''New L{a_f2Tuple} ellipsoid specification. 

139 

140 @arg a: Equatorial radius (C{scalar} > 0). 

141 @arg f: Flattening (C{scalar} < 1, negative for I{prolate}). 

142 @kwarg name: Optional C{B{name}=NN} (C{str}). 

143 

144 @return: An L{a_f2Tuple}C{(a, f)}. 

145 

146 @raise UnitError: Invalid B{C{a}} or B{C{f}}. 

147 

148 @note: C{abs(B{f}) < }L{EPS<pygeodesy.constants.EPS>} is 

149 forced to C{B{f}=0}, I{spherical}. 

150 

151 @note: Negative C{B{f}} produces a I{prolate} ellipsoid. 

152 ''' 

153 a = Radius_(a=a) # low=EPS, high=None 

154 f = Float_( f=f, low=None, high=EPS1) 

155 if fabs(f) < EPS: # force spherical 

156 f = _f_0_0 

157 return _NamedTuple.__new__(cls, a, f, **name) 

158 

159 @Property_RO 

160 def b(self): 

161 '''Get the I{polar} radius (C{meter}), M{a * (1 - f)}. 

162 ''' 

163 return a_f2b(self.a, self.f) # PYCHOK .a and .f 

164 

165 def ellipsoid(self, **name): 

166 '''Return an L{Ellipsoid} for this 2-tuple C{(a, f)}. 

167 

168 @kwarg name: Optional C{B{name}=NN} (C{str}). 

169 

170 @raise NameError: A registered C{ellipsoid} with the 

171 same B{C{name}} already exists. 

172 ''' 

173 return Ellipsoid(self.a, f=self.f, name=self._name__(name)) # PYCHOK .a and .f 

174 

175 @Property_RO 

176 def f_(self): 

177 '''Get the I{inverse} flattening (C{scalar}), M{1 / f} == M{a / (a - b)}. 

178 ''' 

179 return f2f_(self.f) # PYCHOK .f 

180 

181 

182class Circle4Tuple(_NamedTuple): 

183 '''4-Tuple C{(radius, height, lat, beta)} of the C{radius} and C{height}, 

184 both conventionally in C{meter} of a parallel I{circle of latitude} at 

185 (geodetic) latitude C{lat} and the I{parametric (or reduced) auxiliary 

186 latitude} C{beta}, both in C{degrees90}. 

187 

188 The C{height} is the (signed) distance along the z-axis between the 

189 parallel and the equator. At near-polar C{lat}s, the C{radius} is C{0}, 

190 the C{height} is the ellipsoid's (signed) polar radius and C{beta} 

191 equals C{lat}. 

192 ''' 

193 _Names_ = (_radius_, _height_, _lat_, _beta_) 

194 _Units_ = ( Radius, Height, Lat, Lat) 

195 

196 

197class Curvature2Tuple(_NamedTuple): 

198 '''2-Tuple C{(meridional, prime_vertical)} of radii of curvature, both in 

199 C{meter}, conventionally. 

200 ''' 

201 _Names_ = (_meridional_, _prime_vertical_) 

202 _Units_ = ( Meter, Meter) 

203 

204 @property_RO 

205 def transverse(self): 

206 '''Get this I{prime_vertical}, aka I{transverse} radius of curvature. 

207 ''' 

208 return self.prime_vertical 

209 

210 

211class Ellipsoid(_NamedEnumItem): 

212 '''Ellipsoid with I{equatorial} and I{polar} radii, I{flattening}, I{inverse 

213 flattening} and other, often used, I{cached} attributes, supporting 

214 I{oblate} and I{prolate} ellipsoidal and I{spherical} earth models. 

215 ''' 

216 _a = 0 # equatorial radius, semi-axis (C{meter}) 

217 _b = 0 # polar radius, semi-axis (C{meter}): a * (f - 1) / f 

218 _f = 0 # (1st) flattening: (a - b) / a 

219 _f_ = 0 # inverse flattening: 1 / f = a / (a - b) 

220 

221 _geodsolve = NN # means, use PYGEODESY_GEODSOLVE 

222 _KsOrder = 8 # Krüger series order (4, 6 or 8) 

223 _rhumbsolve = NN # means, use PYGEODESY_RHUMBSOLVE 

224 

225 def __init__(self, a, b=None, f_=None, f=None, **name): 

226 '''New L{Ellipsoid} from the I{equatorial} radius I{and} either 

227 the I{polar} radius or I{inverse flattening} or I{flattening}. 

228 

229 @arg a: Equatorial radius, semi-axis (C{meter}). 

230 @arg b: Optional polar radius, semi-axis (C{meter}). 

231 @arg f_: Inverse flattening: M{a / (a - b)} (C{float} >>> 1.0). 

232 @arg f: Flattening: M{(a - b) / a} (C{scalar}, near zero for 

233 spherical). 

234 @kwarg name: Optional, unique C{B{name}=NN} (C{str}). 

235 

236 @raise NameError: Ellipsoid with the same B{C{name}} already exists. 

237 

238 @raise ValueError: Invalid B{C{a}}, B{C{b}}, B{C{f_}} or B{C{f}} or 

239 B{C{f_}} and B{C{f}} are incompatible. 

240 

241 @note: M{abs(f_) > 1 / EPS} or M{abs(1 / f_) < EPS} is forced 

242 to M{1 / f_ = 0}, spherical. 

243 ''' 

244 ff_ = f, f_ # assertion below 

245 n = _name__(**name) if name else NN 

246 try: 

247 a = Radius_(a=a) # low=EPS 

248 if not _isfinite(a): 

249 raise ValueError(_SPACE_(_a_, _not_finite_)) 

250 

251 if b: # not _isin(b, None, _0_0) 

252 b = Radius_(b=b) # low=EPS 

253 f = a_b2f(a, b) if f is None else Float(f=f) 

254 f_ = f2f_(f) if f_ is None else Float(f_=f_) 

255 elif f is not None: 

256 f = Float(f=f) 

257 b = a_f2b(a, f) 

258 f_ = f2f_(f) if f_ is None else Float(f_=f_) 

259 elif f_: 

260 f_ = Float(f_=f_) 

261 b = a_f_2b(a, f_) # a * (f_ - 1) / f_ 

262 f = f_2f(f_) 

263 else: # only a, spherical 

264 f_ = f = 0 

265 b = a # superfluous 

266 

267 if not f < _1_0: # sanity check, see .ecef.Ecef.__init__ 

268 raise ValueError(_SPACE_(_f_, _invalid_)) 

269 if not _isfinite(b): 

270 raise ValueError(_SPACE_(_b_, _not_finite_)) 

271 

272 if fabs(f) < EPS or a == b or not f_: # spherical 

273 b = a 

274 f = _f_0_0 

275 f_ = _f__0_0 

276 

277 except (TypeError, ValueError) as x: 

278 d = _xkwds_not(None, b=b, f_=f_, f=f) 

279 t = instr(self, a=a, name=n, **d) 

280 raise _ValueError(t, cause=x) 

281 

282 self._a = a 

283 self._b = b 

284 self._f = f 

285 self._f_ = f_ 

286 

287 self._register(Ellipsoids, n) 

288 

289 if f and f_: # see test/testEllipsoidal 

290 d = dict(eps=_TOL) 

291 if None in ff_: # both f_ and f given 

292 d.update(Error=_ValueError, txt=_incompatible_) 

293 self._assert(_1_0 / f, f_=f_, **d) 

294 self._assert(_1_0 / f_, f =f, **d) 

295 self._assert(self.b2_a2, e21=self.e21, eps=EPS) 

296 

297 def __eq__(self, other): 

298 '''Compare this and an other ellipsoid. 

299 

300 @arg other: The other ellipsoid (L{Ellipsoid} or L{Ellipsoid2}). 

301 

302 @return: C{True} if equal, C{False} otherwise. 

303 ''' 

304 return self is other or (isinstance(other, Ellipsoid) and 

305 self.a == other.a and 

306 (self.f == other.f or self.b == other.b)) 

307 

308 def __hash__(self): 

309 return self._hash # memoized 

310 

311 @Property_RO 

312 def a(self): 

313 '''Get the I{equatorial} radius, semi-axis (C{meter}). 

314 ''' 

315 return self._a 

316 

317 equatoradius = a # = Requatorial 

318 

319 @Property_RO 

320 def a2(self): 

321 '''Get the I{equatorial} radius I{squared} (C{meter} I{squared}), M{a**2}. 

322 ''' 

323 return Meter2(a2=self.a**2) 

324 

325 @Property_RO 

326 def a2_(self): 

327 '''Get the inverse of the I{equatorial} radius I{squared} (C{meter} I{squared}), M{1 / a**2}. 

328 ''' 

329 return Float(a2_=_1_0 / self.a2) 

330 

331 @Property_RO 

332 def a_b(self): 

333 '''Get the ratio I{equatorial} over I{polar} radius (C{float}), M{a / b} == M{1 / (1 - f)}. 

334 ''' 

335 return Float(a_b=self.a / self.b if self.f else _1_0) 

336 

337 @Property_RO 

338 def a2_b(self): 

339 '''Get the I{polar} meridional (or polar) radius of curvature (C{meter}), M{a**2 / b}. 

340 

341 @see: U{Radii of Curvature 

342 <https://WikiPedia.org/wiki/Earth_radius#Radii_of_curvature>} 

343 and U{Moritz, H. (1980), Geodetic Reference System 1980 

344 <https://WikiPedia.org/wiki/Earth_radius#cite_note-Moritz-2>}. 

345 

346 @note: Symbol C{c} is used by IUGG and IERS for the U{polar radius of curvature 

347 <https://WikiPedia.org/wiki/Earth_radius#Radii_of_curvature>}, see L{c2} 

348 and L{R2} or L{Rauthalic}. 

349 ''' 

350 return Radius(a2_b=self.a2 / self.b if self.f else self.a) # = rocPolar 

351 

352 @Property_RO 

353 def a2_b2(self): 

354 '''Get the ratio I{equatorial} over I{polar} radius I{squared} (C{float}), 

355 M{(a / b)**2} == M{1 / (1 - e**2)} == M{1 / (1 - e2)} == M{1 / e21}. 

356 ''' 

357 return Float(a2_b2=self.a_b**2 if self.f else _1_0) 

358 

359 @Property_RO 

360 def a_f(self): 

361 '''Get the I{equatorial} radius and I{flattening} (L{a_f2Tuple}), see method C{toEllipsoid2}. 

362 ''' 

363 return a_f2Tuple(self.a, self.f, name=self.name) 

364 

365 a_f2 = a_f # synonym 

366 

367 @Property_RO 

368 def A(self): 

369 '''Get the UTM I{meridional (or rectifying)} radius (C{meter}). 

370 

371 @note: C{A * PI / 2} ≈= L{L<Ellipsoid.L>}, the I{quarter meridian}. 

372 

373 @see: I{Meridian arc unit} U{Q<https://StudyLib.net/doc/7443565/>}, 

374 the mean, meridional length I{per radian}. 

375 ''' 

376 A, n = self.a, self.n 

377 if n: 

378 d = (n + _1_0) * 1048576 / A 

379 if d: # use 6 n**2 terms, half-way between the _KsOrder's 4, 6, 8 

380 # <https://GeographicLib.SourceForge.io/C++/doc/tmseries30.html> 

381 # <https://GeographicLib.SourceForge.io/C++/doc/transversemercator.html> and 

382 # <https://www.MyGeodesy.id.AU/documents/Karney-Krueger%20equations.pdf> (3) 

383 # A *= fhorner(n**2, 1048576, 262144, 16384, 4096, 1600, 784, 441) / 1048576) / (1 + n) 

384 A = Radius(A=Fhorner(n**2, 1048576, 262144, 16384, 4096, 1600, 784, 441).fover(d)) 

385 return A 

386# # Moritz, H. <https://Geodesy.Geology.Ohio-State.EDU/course/refpapers/00740128.pdf> 

387# # q = 4 / self.rocPolar 

388# # Q = (1 - 3 / 4 * e'2 + 45 / 64 * e'4 - 175 / 256 * e'6 + 11025 / 16384 * e'8) * rocPolar 

389# # = (4 + e'2 * (-3 + e'2 * (45 / 16 + e'2 * (-175 / 64 + e'2 * 11025 / 4096)))) / q 

390# return Radius(Q=Fhorner(self.e22, 4, -3, 45 / 16, -175 / 64, 11025 / 4096).fover(q)) 

391 

392 @Property_RO 

393 def _albersCyl(self): 

394 '''(INTERNAL) Helper for C{auxAuthalic}. 

395 ''' 

396 return _MODS.albers.AlbersEqualAreaCylindrical(datum=self, name=self.name) 

397 

398 @Property_RO 

399 def AlphaKs(self): 

400 '''Get the I{Krüger} U{Alpha series coefficients<https://GeographicLib.SourceForge.io/C++/doc/tmseries30.html>} (C{KsOrder}C{-tuple}). 

401 ''' 

402 return self._Kseries( # XXX int/int quotients may require from __future__ import division as _; del _ # noqa: E702 ; 

403 # n n**2 n**3 n**4 n**5 n**6 n**7 n**8 

404 _T(1/2, -2/3, 5/16, 41/180, -127/288, 7891/37800, 72161/387072, -18975107/50803200), 

405 _T(13/48, -3/5, 557/1440, 281/630, -1983433/1935360, 13769/28800, 148003883/174182400), # PYCHOK unaligned 

406 _T(61/240, -103/140, 15061/26880, 167603/181440, -67102379/29030400, 79682431/79833600), # PYCHOK unaligned 

407 _T(49561/161280, -179/168, 6601661/7257600, 97445/49896, -40176129013/7664025600), # PYCHOK unaligned 

408 _T(34729/80640, -3418889/1995840, 14644087/9123840, 2605413599/622702080), # PYCHOK unaligned 

409 _T(212378941/319334400, -30705481/10378368, 175214326799/58118860800), # PYCHOK unaligned 

410 _T(1522256789/1383782400, -16759934899/3113510400), # PYCHOK unaligned 

411 _T(1424729850961/743921418240)) # PYCHOK unaligned 

412 

413 @Property_RO 

414 def area(self): 

415 '''Get the ellipsoid's surface area (C{meter} I{squared}), M{4 * PI * c2}. 

416 

417 @see: Properties L{areax}, L{c2} and L{R2} and functions 

418 L{ellipsoidalExact.areaOf} and L{ellipsoidalKarney.areaOf}. 

419 ''' 

420 return Meter2(area=self.c2 * PI4) 

421 

422 @Property_RO 

423 def areax(self): 

424 '''Get the ellipsoid's surface area (C{meter} I{squared}), M{4 * PI * c2x}, more 

425 accurate for very I{oblate} ellipsoids. 

426 

427 @see: Properties L{area}, L{c2x} and L{R2x}, class L{GeodesicExact} and 

428 functions L{ellipsoidalExact.areaOf} and L{ellipsoidalKarney.areaOf}. 

429 ''' 

430 return Meter2(areax=self.c2x * PI4) 

431 

432 def _assert(self, val, eps=_TOL, f0=_0_0, Error=_AssertionError, txt=NN, **name_value): 

433 '''(INTERNAL) Assert a C{name=value} vs C{val}. 

434 ''' 

435 for n, v in name_value.items(): 

436 if fabs(v - val) > eps: # PYCHOK no cover 

437 t = (v, _vs_, val) 

438 t = _SPACE_.join(strs(t, prec=12, fmt=Fmt.g)) 

439 t = Fmt.EQUAL(self._DOT_(n), t) 

440 raise Error(t, txt=txt or Fmt.exceeds_eps(eps)) 

441 return Float(v if self.f else f0, name=n) 

442 raise Error(unstr(self._DOT_(typename(self._assert)), val, 

443 eps=eps, f0=f0, **name_value)) 

444 

445 def auxAuthalic(self, lat, inverse=False): 

446 '''Compute the I{authalic} auxiliary latitude (Xi) or the I{inverse} thereof. 

447 

448 @arg lat: The geodetic (or I{authalic}) latitude (C{degrees90}). 

449 @kwarg inverse: If C{True}, B{C{lat}} is the I{authalic} and 

450 return the geodetic latitude (C{bool}). 

451 

452 @return: The I{authalic} (or geodetic) latitude in C{degrees90}. 

453 

454 @see: U{Inverse-/AuthalicLatitude<https://GeographicLib.SourceForge.io/ 

455 C++/doc/classGeographicLib_1_1Ellipsoid.html>}, U{Authalic latitude 

456 <https://WikiPedia.org/wiki/Latitude#Authalic_latitude>}, and 

457 U{Snyder<https://Pubs.USGS.gov/pp/1395/report.pdf>}, p 16. 

458 ''' 

459 if self.f: 

460 f = self._albersCyl._tanf if inverse else \ 

461 self._albersCyl._txif # PYCHOK attr 

462 lat = atan1d(f(tan(Phid(lat)))) # PYCHOK attr 

463 return _aux(lat, inverse, Ellipsoid.auxAuthalic) 

464 

465 def auxConformal(self, lat, inverse=False): 

466 '''Compute the I{conformal} auxiliary latitude (Chi) or the I{inverse} thereof. 

467 

468 @arg lat: The geodetic (or I{conformal}) latitude (C{degrees90}). 

469 @kwarg inverse: If C{True}, B{C{lat}} is the I{conformal} and 

470 return the geodetic latitude (C{bool}). 

471 

472 @return: The I{conformal} (or geodetic) latitude in C{degrees90}. 

473 

474 @see: U{Inverse-/ConformalLatitude<https://GeographicLib.SourceForge.io/ 

475 C++/doc/classGeographicLib_1_1Ellipsoid.html>}, U{Conformal latitude 

476 <https://WikiPedia.org/wiki/Latitude#Conformal_latitude>}, and 

477 U{Snyder<https://Pubs.USGS.gov/pp/1395/report.pdf>}, pp 15-16. 

478 ''' 

479 if self.f: 

480 f = self.es_tauf if inverse else self.es_taupf # PYCHOK attr 

481 lat = atan1d(f(tan(Phid(lat)))) # PYCHOK attr 

482 return _aux(lat, inverse, Ellipsoid.auxConformal) 

483 

484 def auxGeocentric(self, lat, inverse=False, height=_0_0): 

485 '''Compute the I{geocentric} auxiliary latitude (Theta) or the I{inverse} thereof. 

486 

487 @arg lat: The geodetic (or I{geocentric}) latitude (C{degrees90}). 

488 @kwarg inverse: If C{True}, B{C{lat}} is the geocentric and 

489 return the I{geocentric} latitude (C{bool}). 

490 @kwarg height: Optional, ellipsoidal height (C{meter}). 

491 

492 @return: The I{geocentric} (or geodetic) latitude in C{degrees90}. 

493 

494 @see: U{Inverse-/GeocentricLatitude<https://GeographicLib.SourceForge.io/ 

495 C++/doc/classGeographicLib_1_1Ellipsoid.html>}, U{Geocentric latitude 

496 <https://WikiPedia.org/wiki/Latitude#Geocentric_latitude>}, and 

497 U{Snyder<https://Pubs.USGS.gov/pp/1395/report.pdf>}, pp 17-18. 

498 ''' 

499 if self.f: # and lat 

500 t = tan(Phid(lat)) 

501 f = self.b2_a2 

502 if height: 

503 if inverse: 

504 lat = atan1d(t * f) # geodetic n 

505 d, f = f, _1_0 

506 else: 

507 d = _1_0 

508 n = self.rocPrimeVertical(lat) 

509 f = _over(n * f + height, n * d + height) 

510 elif inverse: 

511 f = self.a2_b2 

512 lat = atan1d(t * f) 

513 return _aux(lat, inverse, Ellipsoid.auxGeocentric) 

514 

515 def auxIsometric(self, lat, inverse=False): 

516 '''Compute the I{isometric} auxiliary latitude (Psi) or the I{inverse} thereof. 

517 

518 @arg lat: The geodetic (or I{isometric}) latitude (C{degrees}). 

519 @kwarg inverse: If C{True}, B{C{lat}} is the I{isometric} and 

520 return the geodetic latitude (C{bool}). 

521 

522 @return: The I{isometric} (or geodetic) latitude in C{degrees}. 

523 

524 @note: The I{isometric} latitude for geodetic C{+/-90} is far 

525 outside the C{[-90..+90]} range but the inverse thereof 

526 is the original geodetic latitude. 

527 

528 @see: U{Inverse-/IsometricLatitude<https://GeographicLib.SourceForge.io/ 

529 C++/doc/classGeographicLib_1_1Ellipsoid.html>}, U{Isometric latitude 

530 <https://WikiPedia.org/wiki/Latitude#Isometric_latitude>}, and 

531 U{Snyder<https://Pubs.USGS.gov/pp/1395/report.pdf>}, pp 15-16. 

532 ''' 

533 if self.f: 

534 r = Phid(lat, clip=0) 

535 lat = degrees(atan1(self.es_tauf(sinh(r))) if inverse else 

536 asinh(self.es_taupf(tan(r)))) 

537 # clip=0, since auxIsometric(+/-90) is far outside [-90..+90] 

538 return _aux(lat, inverse, Ellipsoid.auxIsometric, clip=0) 

539 

540 def auxParametric(self, lat, inverse=False): 

541 '''Compute the I{parametric} auxiliary latitude (Beta) or the I{inverse} thereof. 

542 

543 @arg lat: The geodetic (or I{parametric}) latitude (C{degrees90}). 

544 @kwarg inverse: If C{True}, B{C{lat}} is the I{parametric} and 

545 return the geodetic latitude (C{bool}). 

546 

547 @return: The I{parametric} (or geodetic) latitude in C{degrees90}. 

548 

549 @see: U{Inverse-/ParametricLatitude<https://GeographicLib.SourceForge.io/ 

550 C++/doc/classGeographicLib_1_1Ellipsoid.html>}, U{Parametric latitude 

551 <https://WikiPedia.org/wiki/Latitude#Parametric_(or_reduced)_latitude>}, 

552 and U{Snyder<https://Pubs.USGS.gov/pp/1395/report.pdf>}, p 18. 

553 ''' 

554 if self.f: 

555 lat = self._beta(Lat(lat), inverse=inverse) 

556 return _aux(lat, inverse, Ellipsoid.auxParametric) 

557 

558 auxReduced = auxParametric # synonymous 

559 

560 def auxRectifying(self, lat, inverse=False): 

561 '''Compute the I{rectifying} auxiliary latitude (Mu) or the I{inverse} thereof. 

562 

563 @arg lat: The geodetic (or I{rectifying}) latitude (C{degrees90}). 

564 @kwarg inverse: If C{True}, B{C{lat}} is the I{rectifying} and 

565 return the geodetic latitude (C{bool}). 

566 

567 @return: The I{rectifying} (or geodetic) latitude in C{degrees90}. 

568 

569 @see: U{Inverse-/RectifyingLatitude<https://GeographicLib.SourceForge.io/ 

570 C++/doc/classGeographicLib_1_1Ellipsoid.html>}, U{Rectifying latitude 

571 <https://WikiPedia.org/wiki/Latitude#Rectifying_latitude>}, and 

572 U{Snyder<https://Pubs.USGS.gov/pp/1395/report.pdf>}, pp 16-17. 

573 ''' 

574 if self.f: 

575 lat = Lat(lat) 

576 if 0 < fabs(lat) < _90_0: 

577 if inverse: 

578 e = self._elliptic_e22 

579 d = degrees90(e.fEinv(e.cE * lat / _90_0)) 

580 lat = self.auxParametric(d, inverse=True) 

581 else: 

582 lat = _over(self.Llat(lat), self.L) * _90_0 

583 return _aux(lat, inverse, Ellipsoid.auxRectifying) 

584 

585 @Property_RO 

586 def b(self): 

587 '''Get the I{polar} radius, semi-axis (C{meter}). 

588 ''' 

589 return self._b 

590 

591 polaradius = b # = Rpolar 

592 

593 @Property_RO 

594 def b_a(self): 

595 '''Get the ratio I{polar} over I{equatorial} radius (C{float}), M{b / a == f1 == 1 - f}. 

596 

597 @see: Property L{f1}. 

598 ''' 

599 return self._assert(self.b / self.a, b_a=self.f1, f0=_1_0) 

600 

601 @Property_RO 

602 def b2(self): 

603 '''Get the I{polar} radius I{squared} (C{float}), M{b**2}. 

604 ''' 

605 return Meter2(b2=self.b**2) 

606 

607 @Property_RO 

608 def b2_a(self): 

609 '''Get the I{equatorial} meridional radius of curvature (C{meter}), M{b**2 / a}, see C{rocMeridional}C{(0)}. 

610 

611 @see: U{Radii of Curvature<https://WikiPedia.org/wiki/Earth_radius#Radii_of_curvature>}. 

612 ''' 

613 return Radius(b2_a=_over(self.b2, self.a) if self.f else self.b) 

614 

615 @Property_RO 

616 def b2_a2(self): 

617 '''Get the ratio I{polar} over I{equatorial} radius I{squared} (C{float}), M{(b / a)**2} 

618 == M{(1 - f)**2} == M{1 - e**2} == C{e21}. 

619 ''' 

620 return Float(b2_a2=self.b_a**2 if self.f else _1_0) 

621 

622 def _beta(self, lat, inverse=False): 

623 '''(INTERNAL) Get the I{parametric (or reduced) auxiliary latitude} or inverse thereof. 

624 ''' 

625 s, c = sincos2d(lat) # like Karney's tand(lat) 

626 s *= self.a_b if inverse else self.b_a 

627 return atan1d(s, c) 

628 

629 @Property_RO 

630 def BetaKs(self): 

631 '''Get the I{Krüger} U{Beta series coefficients<https://GeographicLib.SourceForge.io/C++/doc/tmseries30.html>} (C{KsOrder}C{-tuple}). 

632 ''' 

633 return self._Kseries( # XXX int/int quotients may require from __future__ import division as _; del _ # noqa: E702 ; 

634 # n n**2 n**3 n**4 n**5 n**6 n**7 n**8 

635 _T(1/2, -2/3, 37/96, -1/360, -81/512, 96199/604800, -5406467/38707200, 7944359/67737600), 

636 _T(1/48, 1/15, -437/1440, 46/105, -1118711/3870720, 51841/1209600, 24749483/348364800), # PYCHOK unaligned 

637 _T(17/480, -37/840, -209/4480, 5569/90720, 9261899/58060800, -6457463/17740800), # PYCHOK unaligned 

638 _T(4397/161280, -11/504, -830251/7257600, 466511/2494800, 324154477/7664025600), # PYCHOK unaligned 

639 _T(4583/161280, -108847/3991680, -8005831/63866880, 22894433/124540416), # PYCHOK unaligned 

640 _T(20648693/638668800, -16363163/518918400, -2204645983/12915302400), # PYCHOK unaligne 

641 _T(219941297/5535129600, -497323811/12454041600), # PYCHOK unaligned 

642 _T(191773887257/3719607091200)) # PYCHOK unaligned 

643 

644 @deprecated_Property_RO 

645 def c(self): # PYCHOK no cover 

646 '''DEPRECATED, use property C{R2} or C{Rauthalic}.''' 

647 return self.R2 

648 

649 @Property_RO 

650 def c2(self): 

651 '''Get the I{authalic} earth radius I{squared} (C{meter} I{squared}). 

652 

653 @see: Properties L{c2x}, L{area}, L{R2}, L{Rauthalic}, I{Karney's} U{equation (60) 

654 <https://Link.Springer.com/article/10.1007%2Fs00190-012-0578-z>} and C++ U{Ellipsoid.Area 

655 <https://GeographicLib.SourceForge.io/C++/doc/classGeographicLib_1_1Ellipsoid.html>}, 

656 U{Authalic radius<https://WikiPedia.org/wiki/Earth_radius#Authalic_radius>}, U{Surface area 

657 <https://WikiPedia.org/wiki/Ellipsoid>} and U{surface area 

658 <https://www.Numericana.com/answer/geometry.htm#oblate>}. 

659 ''' 

660 return self._c2f(False) 

661 

662 @Property_RO 

663 def c2x(self): 

664 '''Get the I{authalic} earth radius I{squared} (C{meter} I{squared}), more accurate for very I{oblate} 

665 ellipsoids. 

666 

667 @see: Properties L{c2}, L{areax}, L{R2x}, L{Rauthalicx}, class L{GeodesicExact} and I{Karney}'s comments at C++ 

668 attribute U{GeodesicExact._c2<https://GeographicLib.SourceForge.io/C++/doc/GeodesicExact_8cpp_source.html>}. 

669 ''' 

670 return self._c2f(True) 

671 

672 def _c2f(self, c2x): 

673 '''(INTERNAL) Helper for C{.c2} and C{.c2x}. 

674 ''' 

675 f, c2 = self.f, self.b2 

676 if f: 

677 e = self.e 

678 if e > EPS0: 

679 if f > 0: # .isOblate 

680 c2 *= (asinh(sqrt(self.e22abs)) if c2x else atanh(e)) / e 

681 elif f < 0: # .isProlate 

682 c2 *= atan1(e) / e # XXX asin? 

683 c2 = Meter2(c2=(self.a2 + c2) * _0_5) 

684 return c2 

685 

686 def circle4(self, lat): 

687 '''Get the equatorial or a parallel I{circle of latitude}. 

688 

689 @arg lat: Geodetic latitude (C{degrees90}, C{str}). 

690 

691 @return: A L{Circle4Tuple}C{(radius, height, lat, beta)}. 

692 

693 @raise RangeError: Latitude B{C{lat}} outside valid range and 

694 L{rangerrors<pygeodesy.rangerrors>} is C{True}. 

695 

696 @raise TypeError: Invalid B{C{lat}}. 

697 

698 @raise ValueError: Invalid B{C{lat}}. 

699 

700 @see: Definition of U{I{p} and I{z} under B{Parametric (or reduced) latitude} 

701 <https://WikiPedia.org/wiki/Latitude>}, I{Karney's} C++ U{CircleRadius and CircleHeight 

702 <https://GeographicLib.SourceForge.io/C++/doc/classGeographicLib_1_1Ellipsoid.html>} 

703 and method C{Rlat}. 

704 ''' 

705 lat = Lat(lat) 

706 if lat: 

707 B = lat # beta 

708 if fabs(lat) < _90_0: 

709 if self.f: 

710 B = self._beta(lat) 

711 z, r = sincos2d(B) 

712 r *= self.a 

713 z *= self.b 

714 else: # near-polar 

715 r, z = _0_0, copysign0(self.b, lat) 

716 else: # equator 

717 r = self.a 

718 z = lat = B = _0_0 

719 return Circle4Tuple(r, z, lat, B) 

720 

721 def degrees2m(self, deg, lat=0): 

722 '''Convert an angle along the equator or along a parallel 

723 of (geodetic) latitude to the distance. 

724 

725 @arg deg: The angle (C{degrees}). 

726 @kwarg lat: Parallel latitude (C{degrees90}, C{str}). 

727 

728 @return: Distance (C{meter}, same units as the equatorial 

729 and polar radii) or C{0} for near-polar B{C{lat}}. 

730 

731 @raise RangeError: Latitude B{C{lat}} outside valid range and 

732 L{rangerrors<pygeodesy.rangerrors>} is C{True}. 

733 

734 @raise ValueError: Invalid B{C{deg}} or B{C{lat}}. 

735 ''' 

736 return self.radians2m(radians(deg), lat=lat) 

737 

738 def distance2(self, lat0, lon0, lat1, lon1): 

739 '''I{Approximate} the distance and (initial) bearing between 

740 two points based on the U{local, flat earth approximation 

741 <https://www.EdWilliams.org/avform.htm#flat>} aka U{Hubeny 

742 <https://www.OVG.AT/de/vgi/files/pdf/3781/>} formula. 

743 

744 I{Suitable only for distances of several hundred Km or Miles 

745 and only between points not near-polar}. 

746 

747 @arg lat0: From latitude (C{degrees}). 

748 @arg lon0: From longitude (C{degrees}). 

749 @arg lat1: To latitude (C{degrees}). 

750 @arg lon1: To longitude (C{degrees}). 

751 

752 @return: A L{Distance2Tuple}C{(distance, initial)} with C{distance} 

753 in same units as this ellipsoid's axes. 

754 

755 @note: The meridional and prime_vertical radii of curvature are 

756 taken and scaled I{at the initial latitude}, see C{roc2}. 

757 

758 @see: Function L{pygeodesy.flatLocal}/L{pygeodesy.hubeny}. 

759 ''' 

760 phi0 = Phid(lat0=lat0) 

761 m, n = self.roc2_(phi0, scaled=True) 

762 m *= Phid(lat1=lat1) - phi0 

763 n *= Lamd(lon1=lon1) - Lamd(lon0=lon0) 

764 return Distance2Tuple(hypot(m, n), atan2b(n, m)) 

765 

766 @Property_RO 

767 def e(self): 

768 '''Get the I{unsigned, (1st) eccentricity} (C{float}), M{sqrt(1 - (b / a)**2))}, see C{a_b2e}. 

769 

770 @see: Property L{es}. 

771 ''' 

772 return Float(e=sqrt(self.e2abs) if self.e2 else _0_0) 

773 

774 @deprecated_Property_RO 

775 def e12(self): # see property ._e12 

776 '''DEPRECATED, use property C{e21}.''' 

777 return self.e21 

778 

779# @Property_RO 

780# def _e12(self): # see property ._elliptic_e12 

781# # (INTERNAL) until e12 above can be replaced with e21. 

782# return self.e2 / (_1_0 - self.e2) # see I{Karney}'s Ellipsoid._e12 = e2 / (1 - e2) 

783 

784 @Property_RO 

785 def e2(self): 

786 '''Get the I{signed, (1st) eccentricity squared} (C{float}), M{f * (2 - f) 

787 == 1 - (b / a)**2}, see C{a_b2e2}. 

788 ''' 

789 return self._assert(a_b2e2(self.a, self.b), e2=f2e2(self.f)) 

790 

791 @Property_RO 

792 def e2abs(self): 

793 '''Get the I{unsigned, (1st) eccentricity squared} (C{float}). 

794 ''' 

795 return fabs(self.e2) 

796 

797 @Property_RO 

798 def e21(self): 

799 '''Get 1 less I{1st eccentricity squared} (C{float}), M{1 - e**2} 

800 == M{1 - e2} == M{(1 - f)**2} == M{b**2 / a**2}, see C{b2_a2}. 

801 ''' 

802 return self._assert((_1_0 - self.f)**2, e21=_1_0 - self.e2, f0=_1_0) 

803 

804# _e2m = e21 # see I{Karney}'s Ellipsoid._e2m = 1 - _e2 

805 _1_e21 = a2_b2 # == M{1 / e21} == M{1 / (1 - e**2)} 

806 

807 @Property_RO 

808 def e22(self): 

809 '''Get the I{signed, 2nd eccentricity squared} (C{float}), M{e2 / (1 - e2) 

810 == e2 / (1 - f)**2 == (a / b)**2 - 1}, see C{a_b2e22}. 

811 ''' 

812 return self._assert(a_b2e22(self.a, self.b), e22=f2e22(self.f)) 

813 

814 @Property_RO 

815 def e22abs(self): 

816 '''Get the I{unsigned, 2nd eccentricity squared} (C{float}). 

817 ''' 

818 return fabs(self.e22) 

819 

820 @Property_RO 

821 def e32(self): 

822 '''Get the I{signed, 3rd eccentricity squared} (C{float}), M{e2 / (2 - e2) 

823 == (a**2 - b**2) / (a**2 + b**2)}, see C{a_b2e32}. 

824 ''' 

825 return self._assert(a_b2e32(self.a, self.b), e32=f2e32(self.f)) 

826 

827 @Property_RO 

828 def e32abs(self): 

829 '''Get the I{unsigned, 3rd eccentricity squared} (C{float}). 

830 ''' 

831 return fabs(self.e32) 

832 

833 @Property_RO 

834 def e4(self): 

835 '''Get the I{unsignd, (1st) eccentricity} to 4th power (C{float}), M{e**4 == e2**2}. 

836 ''' 

837 return Float(e4=self.e2**2 if self.e2 else _0_0) 

838 

839 eccentricity = e # eccentricity 

840# eccentricity2 = e2 # eccentricity squared 

841 eccentricity1st2 = e2 # first eccentricity squared, signed 

842 eccentricity2nd2 = e22 # second eccentricity squared, signed 

843 eccentricity3rd2 = e32 # third eccentricity squared, signed 

844 

845 def ecef(self, Ecef=None): 

846 '''Return U{ECEF<https://WikiPedia.org/wiki/ECEF>} converter. 

847 

848 @kwarg Ecef: ECEF class to use, default L{EcefKarney}. 

849 

850 @return: An ECEF converter for this C{ellipsoid}. 

851 

852 @raise TypeError: Invalid B{C{Ecef}}. 

853 

854 @see: Module L{pygeodesy.ecef}. 

855 ''' 

856 return _MODS.ecef._4Ecef(self, Ecef) 

857 

858 @Property_RO 

859 def _elliptic_e12(self): # see I{Karney}'s Ellipsoid._e12 

860 '''(INTERNAL) Elliptic helper for C{Rhumb}. 

861 ''' 

862 e12 = _over(self.e2, self.e2 - _1_0) # NOT DEPRECATED .e12! 

863 return _MODS.elliptic.Elliptic(e12) 

864 

865 @Property_RO 

866 def _elliptic_e22(self): # aka ._elliptic_ep2 

867 '''(INTERNAL) Elliptic helper for C{auxRectifying}, C{L}, C{Llat}. 

868 ''' 

869 return _MODS.elliptic.Elliptic(-self.e22abs) # complex 

870 

871 equatoradius = a # Requatorial 

872 

873 def e2s(self, s): 

874 '''Compute norm M{sqrt(1 - e2 * s**2)}. 

875 

876 @arg s: Sine value (C{scalar}). 

877 

878 @return: Norm (C{float}). 

879 

880 @raise ValueError: Invalid B{C{s}}. 

881 ''' 

882 return sqrt(self.e2s2(s)) if self.e2 else _1_0 

883 

884 def e2s2(self, s): 

885 '''Compute M{1 - e2 * s**2}. 

886 

887 @arg s: Sine value (C{scalar}). 

888 

889 @return: Result (C{float}). 

890 

891 @raise ValueError: Invalid B{C{s}}. 

892 ''' 

893 r, e2 = _1_0, self.e2 

894 if e2: # and s 

895 try: 

896 r -= e2 * Scalar(s=s)**2 

897 if r < 0: 

898 raise ValueError(_negative_) 

899 except (TypeError, ValueError) as x: 

900 t = self._DOT_(typename(Ellipsoid.e2s2)) 

901 raise _ValueError(t, s, cause=x) 

902 return r 

903 

904 @Property_RO 

905 def es(self): 

906 '''Get the I{signed (1st) eccentricity} (C{float}). 

907 

908 @see: Property L{e}. 

909 ''' 

910 # note, self.e is always non-negative 

911 return Float(es=copysign0(self.e, self.f)) # see .ups 

912 

913 def es_atanh(self, x): 

914 '''Compute M{es * atanh(es * x)} or M{-es * atan(es * x)} 

915 for I{oblate} respectively I{prolate} ellipsoids where 

916 I{es} is the I{signed} (1st) eccentricity. 

917 

918 @raise ValueError: Invalid B{C{x}}. 

919 

920 @see: Function U{Math::eatanhe<https://GeographicLib.SourceForge.io/ 

921 C++/doc/classGeographicLib_1_1Math.html>}. 

922 ''' 

923 return self._es_atanh(Scalar(x=x)) if self.f else _0_0 

924 

925 def _es_atanh(self, x): # see .albers._atanhee, .AuxLat._atanhee 

926 '''(INTERNAL) Helper for .es_atanh, ._es_taupf2 and ._exp_es_atanh. 

927 ''' 

928 es = self.es # signOf(es) == signOf(f) 

929 return es * (atanh(es * x) if es > 0 else # .isOblate 

930 (-atan(es * x) if es < 0 else # .isProlate 

931 _0_0)) # .isSpherical 

932 

933 @Property_RO 

934 def es_c(self): 

935 '''Get M{(1 - f) * exp(es_atanh(1))} (C{float}), M{b_a * exp(es_atanh(1))}. 

936 ''' 

937 return Float(es_c=(self._exp_es_atanh_1 * self.b_a) if self.f else _1_0) 

938 

939 def es_tauf(self, taup): 

940 '''Compute I{Karney}'s U{equations (19), (20) and (21) 

941 <https://ArXiv.org/abs/1002.1417>}. 

942 

943 @see: I{Karney}'s C++ method U{Math::tauf<https://GeographicLib. 

944 SourceForge.io/C++/doc/classGeographicLib_1_1Math.html>} and 

945 and I{Veness}' JavaScript method U{toLatLon<https://www. 

946 Movable-Type.co.UK/scripts/latlong-utm-mgrs.html>}. 

947 ''' 

948 t = Scalar(taup=taup) 

949 if self.f: # .isEllipsoidal 

950 a = fabs(t) 

951 T = (self._exp_es_atanh_1 if a > 70 else self._1_e21) * t 

952 if fabs(T * _EPSqrt) < _2_0: # handles +/- INF and NAN 

953 s = (a * _TOL) if a > _1_0 else _TOL 

954 for T, _, d in self._es_tauf3(t, T): # max 2 

955 if fabs(d) < s: 

956 break 

957 t = Scalar(tauf=T) 

958 return t 

959 

960 def _es_tauf3(self, taup, T, N=9): # in .utm.Utm._toLLEB 

961 '''(INTERNAL) Yield a 3-tuple C{(τi, iteration, delta)} for at most 

962 B{C{N}} Newton iterations, converging rapidly except when C{delta} 

963 toggles on +/-1.12e-16 or +/-4.47e-16, see C{.utm.Utm._toLLEB}. 

964 ''' 

965 e = self._1_e21 

966 _F2_ = Fsum(T).fsum2f_ # τ0 

967 _tf2 = self._es_taupf2 

968 for i in range(1, N + 1): 

969 a, h = _tf2(T) 

970 # = (taup - a) / hypot1(a) / ((e + T**2) / h) 

971 d = _over((taup - a) * (T**2 + e), hypot1(a) * h) 

972 T, d = _F2_(d) # τi, (τi - τi-1) 

973 yield T, i, d 

974 

975 def es_taupf(self, tau): 

976 '''Compute I{Karney}'s U{equations (7), (8) and (9) 

977 <https://ArXiv.org/abs/1002.1417>}. 

978 

979 @see: I{Karney}'s C++ method U{Math::taupf<https://GeographicLib. 

980 SourceForge.io/C++/doc/classGeographicLib_1_1Math.html>}. 

981 ''' 

982 t = Scalar(tau=tau) 

983 if self.f: # .isEllipsoidal 

984 t, _ = self._es_taupf2(t) 

985 t = Scalar(taupf=t) 

986 return t 

987 

988 def _es_taupf2(self, tau): 

989 '''(INTERNAL) Return 2-tuple C{(es_taupf(tau), hypot1(tau))}. 

990 ''' 

991 if _isfinite(tau): 

992 h = hypot1(tau) 

993 s = sinh(self._es_atanh(tau / h)) 

994 a = hypot1(s) * tau - h * s 

995 else: 

996 a, h = tau, INF 

997 return a, h 

998 

999 @Property_RO 

1000 def _exp_es_atanh_1(self): 

1001 '''(INTERNAL) Helper for .es_c and .es_tauf. 

1002 ''' 

1003 return exp(self._es_atanh(_1_0)) if self.es else _1_0 

1004 

1005 @Property_RO 

1006 def f(self): 

1007 '''Get the I{flattening} (C{scalar}), M{(a - b) / a}, C{0} for spherical, negative for prolate. 

1008 ''' 

1009 return self._f 

1010 

1011 @Property_RO 

1012 def f_(self): 

1013 '''Get the I{inverse flattening} (C{scalar}), M{1 / f} == M{a / (a - b)}, C{0} for spherical, see C{a_b2f_}. 

1014 ''' 

1015 return self._f_ 

1016 

1017 @Property_RO 

1018 def f1(self): 

1019 '''Get the I{1 - flattening} (C{float}), M{f1 == 1 - f == b / a}. 

1020 

1021 @see: Property L{b_a}. 

1022 ''' 

1023 return Float(f1=_1_0 - self.f) 

1024 

1025 @Property_RO 

1026 def f2(self): 

1027 '''Get the I{2nd flattening} (C{float}), M{(a - b) / b == f / (1 - f)}, C{0} for spherical, see C{a_b2f2}. 

1028 ''' 

1029 return self._assert(self.a_b - _1_0, f2=f2f2(self.f)) 

1030 

1031 @deprecated_Property_RO 

1032 def geodesic(self): 

1033 '''DEPRECATED, use property C{geodesicw}.''' 

1034 return self.geodesicw 

1035 

1036 def geodesic_(self, exact=True): 

1037 '''Get the an I{exact} C{Geodesic...} instance for this ellipsoid. 

1038 

1039 @kwarg exact: If C{bool} return L{GeodesicExact}C{(exact=B{exact}, ...)}, 

1040 otherwise a L{Geodesic}, L{GeodesicExact} or L{GeodesicSolve} 

1041 instance for I{this} ellipsoid. 

1042 

1043 @return: The C{exact} geodesic (C{Geodesic...}). 

1044 

1045 @raise TypeError: Invalid B{C{exact}}. 

1046 

1047 @raise ValueError: Incompatible B{C{exact}} ellipsoid. 

1048 ''' 

1049 if isbool(exact): # for consistenccy with C{.rhumb_} 

1050 g = _MODS.geodesicx.GeodesicExact(self, C4order=30 if exact else 24, 

1051 name=self.name) 

1052 else: 

1053 g = exact 

1054 E = _xattr(g, ellipsoid=None) 

1055 if not (E is self and isinstance(g, self._Geodesics)): 

1056 raise _ValueError(exact=g, ellipsoid=E, txt_not_=self.name) 

1057 return g 

1058 

1059 @property_ROver 

1060 def _Geodesics(self): 

1061 '''(INTERNAL) Get all C{Geodesic...} classes, I{once}. 

1062 ''' 

1063 t = (_MODS.geodesicx.GeodesicExact, 

1064 _MODS.geodsolve.GeodesicSolve) 

1065 try: 

1066 t += (_MODS.geodesicw.Geodesic, 

1067 _MODS.geodesicw._wrapped.Geodesic) 

1068 except ImportError: 

1069 pass 

1070 return t # overwrite property_ROver 

1071 

1072 @property_RO 

1073 def geodesicw(self): 

1074 '''Get this ellipsoid's I{wrapped} U{geodesicw.Geodesic 

1075 <https://GeographicLib.SourceForge.io/Python/doc/code.html>}, provided 

1076 I{Karney}'s U{geographiclib<https://PyPI.org/project/geographiclib>} 

1077 package is installed. 

1078 ''' 

1079 # if not self.isEllipsoidal: 

1080 # raise _IsnotError(_ellipsoidal_, ellipsoid=self) 

1081 return _MODS.geodesicw.Geodesic(self) 

1082 

1083 @property_RO 

1084 def geodesicx(self): 

1085 '''Get this ellipsoid's I{exact} L{GeodesicExact}. 

1086 ''' 

1087 # if not self.isEllipsoidal: 

1088 # raise _IsnotError(_ellipsoidal_, ellipsoid=self) 

1089 return _MODS.geodesicx.GeodesicExact(self, name=self.name) 

1090 

1091 @property 

1092 def geodsolve(self): 

1093 '''Get this ellipsoid's L{GeodesicSolve}, the I{wrapper} around utility 

1094 U{GeodSolve<https://GeographicLib.SourceForge.io/C++/doc/GeodSolve.1.html>}, 

1095 provided the path to the C{GeodSolve} executable is specified with env 

1096 variable C{PYGEODESY_GEODSOLVE} or re-/set with this property.. 

1097 ''' 

1098 # if not self.isEllipsoidal: 

1099 # raise _IsnotError(_ellipsoidal_, ellipsoid=self) 

1100 return _MODS.geodsolve.GeodesicSolve(self, path=self._geodsolve, name=self.name) 

1101 

1102 @geodsolve.setter # PYCHOK setter! 

1103 def geodsolve(self, path): 

1104 '''Re-/set the (fully qualified) path to the U{GeodSolve 

1105 <https://GeographicLib.SourceForge.io/C++/doc/GeodSolve.1.html>} executable, 

1106 overriding env variable C{PYGEODESY_GEODSOLVE} (C{str}). 

1107 ''' 

1108 self._geodsolve = path 

1109 

1110 def hartzell4(self, pov, los=None): 

1111 '''Compute the intersection of this ellipsoid's surface and a Line-Of-Sight 

1112 from a Point-Of-View in space. 

1113 

1114 @arg pov: Point-Of-View outside this ellipsoid (C{Cartesian}, L{Ecef9Tuple} 

1115 or L{Vector3d}). 

1116 @kwarg los: Line-Of-Sight, I{direction} to this ellipsoid (L{Los}, L{Vector3d}) 

1117 or C{True} for the I{normal, perpendicular, plumb} to the surface 

1118 of this ellipsoid or C{False} or C{None} to point to its center. 

1119 

1120 @return: L{Vector4Tuple}C{(x, y, z, h)} with the cartesian coordinates C{x}, 

1121 C{y} and C{z} of the projection on or the intersection with this 

1122 ellipsoid and the I{distance} C{h} from B{C{pov}} to C{(x, y, z)} 

1123 along B{C{los}}, all in C{meter}, conventionally. 

1124 

1125 @raise IntersectionError: Null B{C{pov}} or B{C{los}} vector, or B{C{pov}} 

1126 is inside this ellipsoid or B{C{los}} points 

1127 outside this ellipsoid or in opposite direction. 

1128 

1129 @raise TypeError: Invalid B{C{pov}} or B{C{los}}. 

1130 

1131 @see: U{I{Satellite Line-of-Sight Intersection with Earth}<https://StephenHartzell. 

1132 Medium.com/satellite-line-of-sight-intersection-with-earth-d786b4a6a9b6>} and 

1133 methods L{Ellipsoid.height4} and L{Triaxial.hartzell4}. 

1134 ''' 

1135 try: 

1136 v, d, i = _MODS.triaxials._hartzell3(pov, los, self._triaxial) 

1137 except Exception as x: 

1138 raise IntersectionError(pov=pov, los=los, cause=x) 

1139 return Vector4Tuple(v.x, v.y, v.z, d, iteration=i, name__=self.hartzell4) 

1140 

1141 @Property_RO 

1142 def _hash(self): 

1143 return hash((self.a, self.f)) 

1144 

1145 def height4(self, xyz, normal=True): 

1146 '''Compute the projection on and the height of a cartesian above or below 

1147 this ellipsoid's surface. 

1148 

1149 @arg xyz: The cartesian (C{Cartesian}, L{Ecef9Tuple}, L{Vector3d}, 

1150 L{Vector3Tuple} or L{Vector4Tuple}). 

1151 @kwarg normal: If C{True}, the projection is perpendicular to (the nearest 

1152 point on) this ellipsoid's surface, otherwise the C{radial} 

1153 line to this ellipsoid's center (C{bool}). 

1154 

1155 @return: L{Vector4Tuple}C{(x, y, z, h)} with the cartesian coordinates C{x}, 

1156 C{y} and C{z} of the projection on and the height C{h} above or 

1157 below this ellipsoid's surface, all in C{meter}, conventionally. 

1158 

1159 @raise ValueError: Null B{C{xyz}}. 

1160 

1161 @raise TypeError: Non-cartesian B{C{xyz}}. 

1162 

1163 @see: U{Distance to<https://StackOverflow.com/questions/22959698/distance-from-given-point-to-given-ellipse>} 

1164 and U{intersection with<https://MathWorld.wolfram.com/Ellipse-LineIntersection.html>} an ellipse and 

1165 methods L{Ellipsoid.hartzell4} and L{Triaxial.height4}. 

1166 ''' 

1167 v = _MODS.vector3d._otherV3d(xyz=xyz) 

1168 r = v.length 

1169 

1170 a, b, i = self.a, self.b, None 

1171 if r < EPS0: # EPS 

1172 v = v.times(_0_0) 

1173 h = -a 

1174 

1175 elif self.isSpherical: 

1176 v = v.times(a / r) 

1177 h = r - a 

1178 

1179 elif normal: # perpendicular to ellipsoid 

1180 x, y = hypot(v.x, v.y), fabs(v.z) 

1181 if x < EPS0: # PYCHOK no cover 

1182 z = copysign0(b, v.z) 

1183 v = Vector3Tuple(v.x, v.y, z) 

1184 h = y - b # polar 

1185 elif y < EPS0: # PYCHOK no cover 

1186 t = a / r 

1187 v = v.times_(t, t, 0) # force z=0.0 

1188 h = x - a # equatorial 

1189 else: # normal in 1st quadrant 

1190 x, y, i = _MODS.triaxials._plumbTo3(x, y, self) 

1191 t, v = v, v.times_(x, x, y) 

1192 h = t.minus(v).length 

1193 

1194 else: # radial to ellipsoid's center 

1195 h = hypot_(a * v.z, b * v.x, b * v.y) 

1196 t = (a * b / h) if h > EPS0 else _0_0 # EPS 

1197 v = v.times(t) 

1198 h = r * (_1_0 - t) 

1199 

1200 return Vector4Tuple(v.x, v.y, v.z, h, iteration=i, name__=self.height4) 

1201 

1202 def _heightB(self, sa, ca, z, p): # in ecef.EcefSudano, ecec.EcefVeness 

1203 '''(INTERNAL) Height above ellipsoid (Bowring eqn 7) at C{lat}. 

1204 ''' 

1205 # sa, ca = sincos2d(lat) 

1206 # p = hypot(x, y) # distance to polar axis 

1207 

1208 # r = a / self.e2s(sa) # length of normal terminated by polar axis 

1209 # h = p * ca + z * sa - (a * a / r) 

1210 return (p * ca + fabs(z * sa) - self.a * self.e2s(sa)) if sa else (p - self.a) 

1211 

1212 @Property_RO 

1213 def _heightMax(self): 

1214 '''(INTERNAL) Get the height limit (C{meter}, conventionally). 

1215 ''' 

1216 return self.a / EPS_2 # self.a * _2_EPS, about 12M lightyears 

1217 

1218 def _hubeny_2(self, phi2, phi1, lam21, scaled=True, squared=True): 

1219 '''(INTERNAL) like function C{pygeodesy.flatLocal_}/C{pygeodesy.hubeny_}, 

1220 returning the I{angular} distance in C{radians squared} or C{radians} 

1221 ''' 

1222 m, n = self.roc2_((phi2 + phi1) * _0_5, scaled=scaled) 

1223 h, r = (hypot2, self.a2_) if squared else (hypot, _1_0 / self.a) 

1224 return h(m * (phi2 - phi1), n * lam21) * r 

1225 

1226 @Property_RO 

1227 def isEllipsoidal(self): 

1228 '''Is this model I{ellipsoidal} (C{bool})? 

1229 ''' 

1230 return self.f != 0 

1231 

1232 @Property_RO 

1233 def isOblate(self): 

1234 '''Is this ellipsoid I{oblate} (C{bool})? I{Prolate} or 

1235 spherical otherwise. 

1236 ''' 

1237 return self.f > 0 

1238 

1239 @Property_RO 

1240 def isProlate(self): 

1241 '''Is this ellipsoid I{prolate} (C{bool})? I{Oblate} or 

1242 spherical otherwise. 

1243 ''' 

1244 return self.f < 0 

1245 

1246 @Property_RO 

1247 def isSpherical(self): 

1248 '''Is this ellipsoid I{spherical} (C{bool})? 

1249 ''' 

1250 return self.f == 0 

1251 

1252 def _Kseries(self, *AB8Ks): 

1253 '''(INTERNAL) Compute the 4-, 6- or 8-th order I{Krüger} Alpha 

1254 or Beta series coefficients per I{Karney}'s U{equations (35) 

1255 and (36)<https://ArXiv.org/pdf/1002.1417v3.pdf>}. 

1256 

1257 @arg AB8Ks: 8-Tuple of 8-th order I{Krüger} Alpha or Beta series 

1258 coefficient tuples. 

1259 

1260 @return: I{Krüger} series coefficients (L{KsOrder}C{-tuple}). 

1261 

1262 @see: I{Karney}'s 30-th order U{TMseries30 

1263 <https://GeographicLib.SourceForge.io/C++/doc/tmseries30.html>}. 

1264 ''' 

1265 k = self.KsOrder 

1266 if self.n: 

1267 ns = fpowers(self.n, k) 

1268 ks = tuple(fdot(AB8Ks[i][:k-i], *ns[i:]) for i in range(k)) 

1269 else: 

1270 ks = _0_0s(k) 

1271 return ks 

1272 

1273 @property_doc_(''' the I{Krüger} series' order (C{int}), see properties C{AlphaKs}, C{BetaKs}.''') 

1274 def KsOrder(self): 

1275 '''Get the I{Krüger} series' order (C{int} 4, 6 or 8). 

1276 ''' 

1277 return self._KsOrder 

1278 

1279 @KsOrder.setter # PYCHOK setter! 

1280 def KsOrder(self, order): 

1281 '''Set the I{Krüger} series' order (C{int} 4, 6 or 8). 

1282 

1283 @raise ValueError: Invalid B{C{order}}. 

1284 ''' 

1285 if not (isint(order) and _isin(order, 4, 6, 8)): 

1286 raise _ValueError(order=order) 

1287 if self._KsOrder != order: 

1288 Ellipsoid.AlphaKs._update(self) 

1289 Ellipsoid.BetaKs._update(self) 

1290 self._KsOrder = order 

1291 

1292 @Property_RO 

1293 def L(self): 

1294 '''Get the I{quarter meridian} C{L}, aka the C{polar distance} 

1295 along a meridian between the equator and a pole (C{meter}), 

1296 M{b * Elliptic(-e2 / (1 - e2)).cE} or M{b * PI / 2}. 

1297 ''' 

1298 r = self._elliptic_e22.cE if self.f else PI_2 

1299 return Distance(L=self.b * r) 

1300 

1301 def Llat(self, lat): 

1302 '''Return the I{meridional length}, the distance along a meridian 

1303 between the equator and a (geodetic) latitude, see C{L}. 

1304 

1305 @arg lat: Geodetic latitude (C{degrees90}). 

1306 

1307 @return: The meridional length at B{C{lat}}, negative on southern 

1308 hemisphere (C{meter}). 

1309 ''' 

1310 r = self._elliptic_e22.fEd(self.auxParametric(lat)) if self.f else Phid(lat) 

1311 return Distance(Llat=self.b * r) 

1312 

1313 Lmeridian = Llat # meridional distance 

1314 

1315 @property_RO 

1316 def _Lpd(self): 

1317 '''Get the I{quarter meridian} per degree (C{meter}), M{self.L / 90}. 

1318 ''' 

1319 return Meter(_Lpd=self.L / _90_0) 

1320 

1321 @property_RO 

1322 def _Lpr(self): 

1323 '''Get the I{quarter meridian} per radian (C{meter}), M{self.L / PI_2}. 

1324 ''' 

1325 return Meter(_Lpr=self.L / PI_2) 

1326 

1327 @deprecated_Property_RO 

1328 def majoradius(self): # PYCHOK no cover 

1329 '''DEPRECATED, use property C{a} or C{Requatorial}.''' 

1330 return self.a 

1331 

1332 def m2degrees(self, distance, lat=0): 

1333 '''Convert a distance to an angle along the equator or along 

1334 a parallel of (geodetic) latitude. 

1335 

1336 @arg distance: Distance (C{meter}). 

1337 @kwarg lat: Parallel latitude (C{degrees90}, C{str}). 

1338 

1339 @return: Angle (C{degrees}) or C{INF} for near-polar B{C{lat}}. 

1340 

1341 @raise RangeError: Latitude B{C{lat}} outside valid range and 

1342 L{rangerrors<pygeodesy.rangerrors>} is C{True}. 

1343 

1344 @raise ValueError: Invalid B{C{distance}} or B{C{lat}}. 

1345 ''' 

1346 return degrees(self.m2radians(distance, lat=lat)) 

1347 

1348 def m2radians(self, distance, lat=0): 

1349 '''Convert a distance to an angle along the equator or along 

1350 a parallel of (geodetic) latitude. 

1351 

1352 @arg distance: Distance (C{meter}). 

1353 @kwarg lat: Parallel latitude (C{degrees90}, C{str}). 

1354 

1355 @return: Angle (C{radians}) or C{INF} for near-polar B{C{lat}}. 

1356 

1357 @raise RangeError: Latitude B{C{lat}} outside valid range and 

1358 L{rangerrors<pygeodesy.rangerrors>} is C{True}. 

1359 

1360 @raise ValueError: Invalid B{C{distance}} or B{C{lat}}. 

1361 ''' 

1362 r = self.circle4(lat).radius if lat else self.a 

1363 return m2radians(distance, radius=r, lat=0) 

1364 

1365 @deprecated_Property_RO 

1366 def minoradius(self): # PYCHOK no cover 

1367 '''DEPRECATED, use property C{b}, C{polaradius} or C{Rpolar}.''' 

1368 return self.b 

1369 

1370 @Property_RO 

1371 def n(self): 

1372 '''Get the I{3rd flattening} (C{float}), M{f / (2 - f) == (a - b) / (a + b)}, see C{a_b2n}. 

1373 ''' 

1374 return self._assert(a_b2n(self.a, self.b), n=f2n(self.f)) 

1375 

1376 flattening = f 

1377 flattening1st = f 

1378 flattening2nd = f2 

1379 flattening3rd = n 

1380 

1381 polaradius = b # Rpolar 

1382 

1383# Q = A # I{meridian arc unit} C{Q}, the mean, meridional length I{per radian} 

1384 

1385 @deprecated_Property_RO 

1386 def quarteradius(self): # PYCHOK no cover 

1387 '''DEPRECATED, use property C{L} or method C{Llat}.''' 

1388 return self.L 

1389 

1390 @Property_RO 

1391 def R1(self): 

1392 '''Get the I{mean} earth radius per I{IUGG} (C{meter}), M{(2 * a + b) / 3 == a * (1 - f / 3)}. 

1393 

1394 @see: U{Earth radius<https://WikiPedia.org/wiki/Earth_radius>} 

1395 and method C{Rgeometric}. 

1396 ''' 

1397 r = Fsum(self.a, self.a, self.b).fover(_3_0) if self.f else self.a 

1398 return Radius(R1=r) 

1399 

1400 Rmean = R1 

1401 

1402 @Property_RO 

1403 def R2(self): 

1404 '''Get the I{authalic} earth radius (C{meter}), M{sqrt(c2)}. 

1405 

1406 @see: C{R2x}, C{c2}, C{area} and U{Earth radius 

1407 <https://WikiPedia.org/wiki/Earth_radius>}. 

1408 ''' 

1409 return Radius(R2=sqrt(self.c2) if self.f else self.a) 

1410# # Moritz, H. <https://Geodesy.Geology.Ohio-State.EDU/course/refpapers/00740128.pdf> 

1411# # R2 = (1 - 2/3 * e'2 + 26/45 * e'4 - 100/189 * e'6 + 7034/14175 * e'8) * rocPolar 

1412# # = (3 + e'2 * (-2 + e'2 * (26/15 + e'2 * (-100/63 + e'2 * 7034/4725)))) * rocPolar / 3 

1413# return Fhorner(self.e22, 3, -2, 26 / 15, -100 / 63, 7034 / 4725).fover(3 / self.rocPolar) 

1414 

1415 Rauthalic = R2 

1416 

1417 @Property_RO 

1418 def R2x(self): 

1419 '''Get the I{authalic} earth radius (C{meter}), M{sqrt(c2x)}. 

1420 

1421 @see: C{R2}, C{c2x} and C{areax}. 

1422 ''' 

1423 return Radius(R2x=sqrt(self.c2x) if self.f else self.a) 

1424 

1425 Rauthalicx = R2x 

1426 

1427 @Property_RO 

1428 def R3(self): 

1429 '''Get the I{volumetric} earth radius (C{meter}), M{(a * a * b)**(1/3)}. 

1430 

1431 @see: U{Earth radius<https://WikiPedia.org/wiki/Earth_radius>} and C{volume}. 

1432 ''' 

1433 r = (cbrt(self.b_a) * self.a) if self.f else self.a 

1434 return Radius(R3=r) 

1435 

1436 Rvolumetric = R3 

1437 

1438 def radians2m(self, rad, lat=0): 

1439 '''Convert an angle to the distance along the equator or along 

1440 a parallel of (geodetic) latitude. 

1441 

1442 @arg rad: The angle (C{radians}). 

1443 @kwarg lat: Parallel latitude (C{degrees90}, C{str}). 

1444 

1445 @return: Distance (C{meter}, same units as the equatorial 

1446 and polar radii) or C{0} for near-polar B{C{lat}}. 

1447 

1448 @raise RangeError: Latitude B{C{lat}} outside valid range and 

1449 L{rangerrors<pygeodesy.rangerrors>} is C{True}. 

1450 

1451 @raise ValueError: Invalid B{C{rad}} or B{C{lat}}. 

1452 ''' 

1453 r = self.circle4(lat).radius if lat else self.a 

1454 return radians2m(rad, radius=r, lat=0) 

1455 

1456 @Property_RO 

1457 def Rbiaxial(self): 

1458 '''Get the I{biaxial, quadratic} mean earth radius (C{meter}), M{sqrt((a**2 + b**2) / 2)}. 

1459 

1460 @see: C{Rtriaxial} 

1461 ''' 

1462 a, b = self.a, self.b 

1463 if b < a: 

1464 b = sqrt(_0_5 + self.b2_a2 * _0_5) * a 

1465 elif b > a: 

1466 b *= sqrt(_0_5 + self.a2_b2 * _0_5) 

1467 return Radius(Rbiaxial=b) 

1468 

1469 Requatorial = a # for consistent naming 

1470 

1471 def Rgeocentric(self, lat): 

1472 '''Compute the I{geocentric} earth radius of (geodetic) latitude. 

1473 

1474 @arg lat: Latitude (C{degrees90}). 

1475 

1476 @return: Geocentric earth radius (C{meter}). 

1477 

1478 @raise ValueError: Invalid B{C{lat}}. 

1479 

1480 @see: U{Geocentric Radius 

1481 <https://WikiPedia.org/wiki/Earth_radius#Geocentric_radius>} 

1482 ''' 

1483 r, p = self.a, Phid(lat) 

1484 if p and self.f: 

1485 if fabs(p) < PI_2: 

1486 s2, c2 = _s2_c2(p) 

1487 # R == sqrt((a2**2 * c2 + b2**2 * s2) / (a2 * c2 + b2 * s2)) 

1488 # == sqrt(a2**2 * (c2 + (b2 / a2)**2 * s2) / (a2 * (c2 + b2 / a2 * s2))) 

1489 # == sqrt(a2 * (c2 + (b2 / a2)**2 * s2) / (c2 + (b2 / a2) * s2)) 

1490 # == a * sqrt((c2 + b2_a2 * b2_a2 * s2) / (c2 + b2_a2 * s2)) 

1491 s2 *= self.b2_a2 

1492 r *= sqrt((c2 + self.b2_a2 * s2) / (c2 + s2)) 

1493 else: 

1494 r = self.b 

1495 return Radius(Rgeocentric=r) 

1496 

1497 @Property_RO 

1498 def Rgeometric(self): 

1499 '''Get the I{geometric} mean earth radius (C{meter}), M{sqrt(a * b)}. 

1500 

1501 @see: C{R1}. 

1502 ''' 

1503 g = sqrt(self.a * self.b) if self.f else self.a 

1504 return Radius(Rgeometric=g) 

1505 

1506 def rhumb_(self, exact=True): 

1507 '''Get the an I{exact} C{Rhumb...} instance for this ellipsoid. 

1508 

1509 @kwarg exact: If C{bool} or C{None} return L{Rhumb}C{(exact=B{exact}, ...)}, 

1510 otherwise a L{Rhumb}, L{RhumbAux} or L{RhumbSolve} instance 

1511 for I{this} ellipsoid. 

1512 

1513 @return: The C{exact} rhumb (C{Rhumb...}). 

1514 

1515 @raise TypeError: Invalid B{C{exact}}. 

1516 

1517 @raise ValueError: Incompatible B{C{exact}} ellipsoid. 

1518 ''' 

1519 if isbool(exact): # use Rhumb for backward compatibility 

1520 r = _MODS.rhumb.ekx.Rhumb(self, exact=exact, name=self.name) 

1521 else: 

1522 r = exact 

1523 E = _xattr(r, ellipsoid=None) 

1524 if not (E is self and isinstance(r, self._Rhumbs)): 

1525 raise _ValueError(exact=r, ellipsosid=E, txt_not_=self.name) 

1526 return r 

1527 

1528 @property_RO 

1529 def rhumbaux(self): 

1530 '''Get this ellipsoid's I{Auxiliary} C{rhumb.RhumbAux}. 

1531 ''' 

1532 # if not self.isEllipsoidal: 

1533 # raise _IsnotError(_ellipsoidal_, ellipsoid=self) 

1534 return _MODS.rhumb.aux_.RhumbAux(self, name=self.name) 

1535 

1536 @property_RO 

1537 def rhumbekx(self): 

1538 '''Get this ellipsoid's I{Elliptic, Krüger} C{rhumb.Rhumb}. 

1539 ''' 

1540 # if not self.isEllipsoidal: 

1541 # raise _IsnotError(_ellipsoidal_, ellipsoid=self) 

1542 return _MODS.rhumb.ekx.Rhumb(self, name=self.name) 

1543 

1544 @property_ROver 

1545 def _Rhumbs(self): 

1546 '''(INTERNAL) Get all C{Rhumb...} classes, I{once}. 

1547 ''' 

1548 r = _MODS.rhumb 

1549 return (r.aux_.RhumbAux, # overwrite property_ROver 

1550 r.ekx.Rhumb, r.solve.RhumbSolve) 

1551 

1552 @property 

1553 def rhumbsolve(self): 

1554 '''Get this ellipsoid's L{RhumbSolve}, the I{wrapper} around utility 

1555 U{RhumbSolve<https://GeographicLib.SourceForge.io/C++/doc/GeodSolve.1.html>}, 

1556 provided the path to the C{RhumbSolve} executable is specified with env 

1557 variable C{PYGEODESY_RHUMBSOLVE} or re-/set with this property. 

1558 ''' 

1559 # if not self.isEllipsoidal: 

1560 # raise _IsnotError(_ellipsoidal_, ellipsoid=self) 

1561 return _MODS.rhumb.solve.RhumbSolve(self, path=self._rhumbsolve, name=self.name) 

1562 

1563 @rhumbsolve.setter # PYCHOK setter! 

1564 def rhumbsolve(self, path): 

1565 '''Re-/set the (fully qualified) path to the U{RhumbSolve 

1566 <https://GeographicLib.SourceForge.io/C++/doc/GeodSolve.1.html>} executable, 

1567 overriding env variable C{PYGEODESY_RHUMBSOLVE} (C{str}). 

1568 ''' 

1569 self._rhumbsolve = path 

1570 

1571 @deprecated_property_RO 

1572 def rhumbx(self): 

1573 '''DEPRECATED on 2023.11.28, use property C{rhumbekx}.''' 

1574 return self.rhumbekx 

1575 

1576 def Rlat(self, lat): 

1577 '''I{Approximate} the earth radius of (geodetic) latitude. 

1578 

1579 @arg lat: Latitude (C{degrees90}). 

1580 

1581 @return: Approximate earth radius (C{meter}). 

1582 

1583 @raise RangeError: Latitude B{C{lat}} outside valid range and 

1584 L{rangerrors<pygeodesy.rangerrors>} is C{True}. 

1585 

1586 @raise TypeError: Invalid B{C{lat}}. 

1587 

1588 @raise ValueError: Invalid B{C{lat}}. 

1589 

1590 @note: C{Rlat(B{90})} equals C{Rpolar}. 

1591 

1592 @see: Method C{circle4}. 

1593 ''' 

1594 # r = a - (a - b) * |lat| / 90 

1595 r = self.a 

1596 if self.f and lat: # .isEllipsoidal 

1597 r -= (r - self.b) * fabs(Lat(lat)) / _90_0 

1598 r = Radius(Rlat=r) 

1599 return r 

1600 

1601 Rpolar = b # for consistent naming 

1602 

1603 def roc1_(self, sa, ca=None): 

1604 '''Compute the I{prime-vertical}, I{normal} radius of curvature 

1605 of (geodetic) latitude, I{unscaled}. 

1606 

1607 @arg sa: Sine of the latitude (C{float}, [-1.0..+1.0]). 

1608 @kwarg ca: Optional cosine of the latitude (C{float}, [-1.0..+1.0]) 

1609 to use an alternate formula. 

1610 

1611 @return: The prime-vertical radius of curvature (C{float}). 

1612 

1613 @note: The delta between both formulae with C{Ellipsoids.WGS84} 

1614 is less than 2 nanometer over the entire latitude range. 

1615 

1616 @see: Method L{roc2_} and class L{EcefYou}. 

1617 ''' 

1618 if sa and self.f: # .isEllipsoidal 

1619 if ca is None: 

1620 r = self.e2s2(sa) # see .roc2_ and _EcefBase._forward 

1621 n = sqrt(self.a2 / r) if r > EPS02 else _0_0 

1622 elif ca: # derived from EcefYou.forward 

1623 h = hypot(ca, self.b_a * sa) 

1624 n = self.a / h 

1625 else: 

1626 n = self.a2_b / fabs(sa) 

1627 else: 

1628 n = self.a 

1629 return n 

1630 

1631 def roc2(self, lat, scaled=False): 

1632 '''Compute the I{meridional} and I{prime-vertical}, I{normal} 

1633 radii of curvature of (geodetic) latitude. 

1634 

1635 @arg lat: Latitude (C{degrees90}). 

1636 @kwarg scaled: Scale prime_vertical by C{cos(radians(B{lat}))} (C{bool}). 

1637 

1638 @return: An L{Curvature2Tuple}C{(meridional, prime_vertical)} with 

1639 the radii of curvature. 

1640 

1641 @raise ValueError: Invalid B{C{lat}}. 

1642 

1643 @see: Methods L{roc2_} and L{roc1_}, U{Local, flat earth approximation 

1644 <https://www.EdWilliams.org/avform.htm#flat>} and meridional and 

1645 prime vertical U{Radii of Curvature<https://WikiPedia.org/wiki/ 

1646 Earth_radius#Radii_of_curvature>}. 

1647 ''' 

1648 return self.roc2_(Phid(lat), scaled=scaled) 

1649 

1650 def roc2_(self, phi, scaled=False): 

1651 '''Compute the I{meridional} and I{prime-vertical}, I{normal} radii of 

1652 curvature of (geodetic) latitude. 

1653 

1654 @arg phi: Latitude (C{radians}). 

1655 @kwarg scaled: Scale prime_vertical by C{cos(B{phi})} (C{bool}). 

1656 

1657 @return: An L{Curvature2Tuple}C{(meridional, prime_vertical)} with the 

1658 radii of curvature. 

1659 

1660 @raise ValueError: Invalid B{C{phi}}. 

1661 

1662 @see: Methods L{roc2} and L{roc1_}, property L{rocEquatorial2}, U{Local, 

1663 flat earth approximation<https://www.EdWilliams.org/avform.htm#flat>} 

1664 and the meridional and prime vertical U{Radii of Curvature 

1665 <https://WikiPedia.org/wiki/Earth_radius#Radii_of_curvature>}. 

1666 ''' 

1667 p = fabs(Phi(phi)) 

1668 if self.f: 

1669 r = self.e2s2(sin(p)) 

1670 if r > EPS02: 

1671 n = sqrt(self.a2 / r) 

1672 m = n * self.e21 / r 

1673 else: 

1674 m = n = _0_0 

1675 else: 

1676 m = n = self.a 

1677 if scaled and p: 

1678 n *= cos(p) if p < PI_2 else _0_0 

1679 return Curvature2Tuple(m, n) 

1680 

1681 def rocAzimuth(self, lat, azimuth): 

1682 '''Compute the I{directional} radius of curvature of (geodetic) latitude 

1683 and C{azimuth} compass direction. 

1684 

1685 @see: Method L{rocBearing<Ellipsoid.rocBearing>} for details, using C{azimuth} for C{bearing}. 

1686 ''' 

1687 return Radius(rocAzimuth=self._rocDirectional(lat, Azimuth(azimuth))) 

1688 

1689 def rocBearing(self, lat, bearing): 

1690 '''Compute the I{directional} radius of curvature of (geodetic) latitude 

1691 and C{bearing} compass direction. 

1692 

1693 @arg lat: Latitude (C{degrees90}). 

1694 @arg bearing: Direction (compass C{degrees360}). 

1695 

1696 @return: Directional radius of curvature (C{meter}). 

1697 

1698 @raise RangeError: Latitude B{C{lat}} outside valid range and 

1699 L{rangerrors<pygeodesy.rangerrors>} is C{True}. 

1700 

1701 @raise ValueError: Invalid B{C{lat}} or B{C{bearing}}. 

1702 

1703 @see: U{Radii of Curvature<https://WikiPedia.org/wiki/Earth_radius#Radii_of_curvature>} 

1704 ''' 

1705 return Radius(rocBearing=self._rocDirectional(lat, Bearing(bearing))) 

1706 

1707 def _rocDirectional(self, lat, deg): 

1708 '''(INTERNAL) Helper for C{rocAzimuth} and C{rocBearing}. 

1709 ''' 

1710 if self.f: 

1711 s2, c2 = _s2_c2(radians(deg)) 

1712 m, n = self.roc2_(Phid(lat)) 

1713 if n < m: # == n / (c2 * n / m + s2) 

1714 c2 *= n / m 

1715 elif m < n: # == m / (c2 + s2 * m / n) 

1716 s2 *= m / n 

1717 n = m 

1718 r = _over(n, c2 + s2) # == 1 / (c2 / m + s2 / n) 

1719 else: 

1720 r = self.b # == self.a 

1721 return r 

1722 

1723 @Property_RO 

1724 def rocEquatorial2(self): 

1725 '''Get the I{meridional} and I{prime-vertical}, I{normal} radii of curvature 

1726 at the equator as L{Curvature2Tuple}C{(meridional, prime_vertical)}. 

1727 

1728 @see: Methods L{rocMeridional} and L{rocPrimeVertical}, properties L{b2_a}, 

1729 L{a2_b}, C{rocPolar} and polar and equatorial U{Radii of Curvature 

1730 <https://WikiPedia.org/wiki/Earth_radius#Radii_of_curvature>}. 

1731 ''' 

1732 m = self.b2_a if self.f else self.a 

1733 return Curvature2Tuple(m, self.a) 

1734 

1735 def rocGauss(self, lat): 

1736 '''Compute the I{Gaussian} radius of curvature of (geodetic) latitude. 

1737 

1738 @arg lat: Latitude (C{degrees90}). 

1739 

1740 @return: Gaussian radius of curvature (C{meter}). 

1741 

1742 @raise ValueError: Invalid B{C{lat}}. 

1743 

1744 @see: Non-directional U{Radii of Curvature<https://WikiPedia.org/wiki/ 

1745 Earth_radius#Radii_of_curvature>} 

1746 ''' 

1747 # using ... 

1748 # m, n = self.roc2_(Phid(lat)) 

1749 # return sqrt(m * n) 

1750 # ... requires 1 or 2 sqrt 

1751 g = self.b 

1752 if self.f: 

1753 s2, c2 = _s2_c2(Phid(lat)) 

1754 g = _over(g, c2 + self.b2_a2 * s2) 

1755 return Radius(rocGauss=g) 

1756 

1757 def rocMean(self, lat): 

1758 '''Compute the I{mean} radius of curvature of (geodetic) latitude. 

1759 

1760 @arg lat: Latitude (C{degrees90}). 

1761 

1762 @return: Mean radius of curvature (C{meter}). 

1763 

1764 @raise ValueError: Invalid B{C{lat}}. 

1765 

1766 @see: Non-directional U{Radii of Curvature<https://WikiPedia.org/wiki/ 

1767 Earth_radius#Radii_of_curvature>} 

1768 ''' 

1769 if self.f: 

1770 m, n = self.roc2_(Phid(lat)) 

1771 m *= _over(n * _2_0, m + n) # == 2 / (1 / m + 1 / n) 

1772 else: 

1773 m = self.a 

1774 return Radius(rocMean=m) 

1775 

1776 def rocMeridional(self, lat): 

1777 '''Compute the I{meridional} radius of curvature of (geodetic) latitude. 

1778 

1779 @arg lat: Latitude (C{degrees90}). 

1780 

1781 @return: Meridional radius of curvature (C{meter}). 

1782 

1783 @raise ValueError: Invalid B{C{lat}}. 

1784 

1785 @see: Methods L{roc2} and L{roc2_}, U{Local, flat earth approximation 

1786 <https://www.EdWilliams.org/avform.htm#flat>} and U{Radii of 

1787 Curvature<https://WikiPedia.org/wiki/Earth_radius#Radii_of_curvature>}. 

1788 ''' 

1789 r = self.roc2_(Phid(lat)) if lat else self.rocEquatorial2 

1790 return Radius(rocMeridional=r.meridional) 

1791 

1792 rocPolar = a2_b # synonymous 

1793 

1794 def rocPrimeVertical(self, lat): 

1795 '''Compute the I{prime-vertical}, I{normal} radius of curvature of 

1796 (geodetic) latitude, aka the I{transverse} radius of curvature. 

1797 

1798 @arg lat: Latitude (C{degrees90}). 

1799 

1800 @return: Prime-vertical radius of curvature (C{meter}). 

1801 

1802 @raise ValueError: Invalid B{C{lat}}. 

1803 

1804 @see: Methods L{roc2}, L{roc2_} and L{roc1_}, U{Local, flat earth 

1805 approximation<https://www.EdWilliams.org/avform.htm#flat>} and 

1806 U{Radii of Curvature<https://WikiPedia.org/wiki/ 

1807 Earth_radius#Radii_of_curvature>}. 

1808 ''' 

1809 r = self.roc1_(sin(Phid(lat))) if lat else self.a 

1810 return Radius(rocPrimeVertical=r) 

1811 

1812 rocTransverse = rocPrimeVertical # synonymous 

1813 

1814 @deprecated_Property_RO 

1815 def Rquadratic(self): # PYCHOK no cover 

1816 '''DEPRECATED, use property C{Rbiaxial} or C{Rtriaxial}.''' 

1817 return self.Rbiaxial 

1818 

1819 @deprecated_Property_RO 

1820 def Rr(self): # PYCHOK no cover 

1821 '''DEPRECATED, use property C{Rrectifying}.''' 

1822 return self.Rrectifying 

1823 

1824 @Property_RO 

1825 def Rrectifying(self): 

1826 '''Get the I{rectifying} earth radius (C{meter}), M{((a**(3/2) + b**(3/2)) / 2)**(2/3)}. 

1827 

1828 @see: U{Earth radius<https://WikiPedia.org/wiki/Earth_radius>}. 

1829 ''' 

1830 r = self.a 

1831 if self.f: 

1832 r *= cbrt2((sqrt3(self.b_a) + _1_0) * _0_5) 

1833 return Radius(Rrectifying=r) 

1834 

1835 @deprecated_Property_RO 

1836 def Rs(self): # PYCHOK no cover 

1837 '''DEPRECATED, use property C{Rgeometric}.''' 

1838 return self.Rgeometric 

1839 

1840 @Property_RO 

1841 def Rtriaxial(self): 

1842 '''Get the I{triaxial, quadratic} mean earth radius (C{meter}), M{sqrt((3 * a**2 + b**2) / 4)}. 

1843 

1844 @see: C{Rbiaxial} 

1845 ''' 

1846 q, b = self.a, self.b 

1847 if b < q: 

1848 q *= sqrt((self.b2_a2 + _3_0) * _0_25) 

1849 elif b > q: 

1850 q = sqrt((self.a2_b2 * _3_0 + _1_0) * _0_25) * b 

1851 return Radius(Rtriaxial=q) 

1852 

1853 def toEllipsoid2(self, **name): 

1854 '''Get a copy of this ellipsoid as an L{Ellipsoid2}. 

1855 

1856 @kwarg name: Optional, unique C{B{name}=NN} (C{str}). 

1857 

1858 @see: Property C{a_f}. 

1859 ''' 

1860 return Ellipsoid2(self, None, **name) 

1861 

1862 def toStr(self, prec=8, terse=4, **sep_name): # PYCHOK expected 

1863 '''Return this ellipsoid as a text string. 

1864 

1865 @kwarg prec: Number of decimal digits, unstripped (C{int}). 

1866 @kwarg terse: Limit the number of items (C{int}, 0...18), 

1867 use C{B{terse}=0} or C{=None} for all. 

1868 @kwarg sep_name: Optional C{B{name}=NN} (C{str}) or C{None} 

1869 to exclude this ellipsoid's name and separator 

1870 C{B{sep}=", "} to join the items (C{str}). 

1871 

1872 @return: This C{Ellipsoid}'s attributes (C{str}). 

1873 ''' 

1874 E = Ellipsoid 

1875 t = (E.a, E.f, E.f_, E.b, E.f2, E.n, E.e, 

1876 E.e2, E.e21, E.e22, E.e32, 

1877 E.A, E.L, E.R1, E.R2, E.R3, 

1878 E.Rbiaxial, E.Rtriaxial) 

1879 if terse: 

1880 t = t[:terse] 

1881 return self._instr(prec=prec, props=t, **sep_name) 

1882 

1883 def toTriaxial(self, **name): 

1884 '''Convert this ellipsoid to a L{Triaxial_}. 

1885 

1886 @kwarg name: Optional C{B{name}=NN} (C{str}). 

1887 

1888 @return: A L{Triaxial_} or L{Triaxial} with the C{X} axis 

1889 pointing east and C{Z} pointing north. 

1890 

1891 @see: Method L{Triaxial_.toEllipsoid}. 

1892 ''' 

1893 T = self._triaxial 

1894 return T.copy(**name) if name else T 

1895 

1896 @property_RO 

1897 def _triaxial(self): 

1898 '''(INTERNAL) Get this ellipsoid's un-/ordered C{Triaxial/_}. 

1899 ''' 

1900 a, b, m = self.a, self.b, _MODS.triaxials 

1901 T = m.Triaxial if a > b else m.Triaxial_ 

1902 return T(a, a, b, name=self.name) 

1903 

1904 @Property_RO 

1905 def volume(self): 

1906 '''Get the ellipsoid's I{volume} (C{meter**3}), M{4 / 3 * PI * R3**3}. 

1907 

1908 @see: C{R3}. 

1909 ''' 

1910 return Meter3(volume=self.a2 * self.b * PI_3 * _4_0) 

1911 

1912 

1913class Ellipsoid2(Ellipsoid): 

1914 '''An L{Ellipsoid} specified by I{equatorial} radius and I{flattening}. 

1915 ''' 

1916 def __init__(self, a, f=None, **name): 

1917 '''New L{Ellipsoid2}. 

1918 

1919 @arg a: Equatorial radius, semi-axis (C{meter}) or a previous 

1920 L{Ellipsoid} instance. 

1921 @arg f: Flattening: (C{float} < 1.0, negative for I{prolate}), 

1922 if B{C{a}} is in C{meter}. 

1923 @kwarg name: Optional, unique C{B{name}=NN} (C{str}). 

1924 

1925 @raise NameError: Ellipsoid with that B{C{name}} already exists. 

1926 

1927 @raise ValueError: Invalid B{C{a}} or B{C{f}}. 

1928 

1929 @note: C{abs(B{f}) < EPS} is forced to C{B{f}=0}, I{spherical}. 

1930 Negative C{B{f}} produces a I{prolate} ellipsoid. 

1931 ''' 

1932 if f is None and isinstance(a, Ellipsoid): 

1933 Ellipsoid.__init__(self, a.a, f =a.f, 

1934 b=a.b, f_=a.f_, **name) 

1935 else: 

1936 Ellipsoid.__init__(self, a, f=f, **name) 

1937 

1938 

1939def _ispherical_a_b(a, b): 

1940 '''(INTERNAL) C{True} for spherical or invalid C{a} or C{b}. 

1941 ''' 

1942 return a < EPS0 or b < EPS0 or fabs(a - b) < EPS0 

1943 

1944 

1945def _ispherical_f(f): 

1946 '''(INTERNAL) C{True} for spherical or invalid C{f}. 

1947 ''' 

1948 return f > EPS1 or fabs(f) < EPS 

1949 

1950 

1951def _ispherical_f_(f_): 

1952 '''(INTERNAL) C{True} for spherical or invalid C{f_}. 

1953 ''' 

1954 f_ = fabs(f_) 

1955 return f_ < EPS or f_ > _1_EPS 

1956 

1957 

1958def a_b2e(a, b): 

1959 '''Return C{e}, the I{1st eccentricity} for a given I{equatorial} and I{polar} radius. 

1960 

1961 @arg a: Equatorial radius (C{scalar} > 0). 

1962 @arg b: Polar radius (C{scalar} > 0). 

1963 

1964 @return: The I{unsigned}, (1st) eccentricity (C{float} or C{0}), M{sqrt(1 - (b / a)**2)}. 

1965 

1966 @note: The result is always I{non-negative} and C{0} for I{near-spherical} ellipsoids. 

1967 ''' 

1968 e2 = _a2b2e2(a, b, b2=False) 

1969 return Float(e=sqrt(fabs(e2)) if e2 else _0_0) # == sqrt(fabs((a - b) * (a + b))) / a 

1970 

1971 

1972def a_b2e2(a, b): 

1973 '''Return C{e2}, the I{1st eccentricity squared} for a given I{equatorial} and I{polar} radius. 

1974 

1975 @arg a: Equatorial radius (C{scalar} > 0). 

1976 @arg b: Polar radius (C{scalar} > 0). 

1977 

1978 @return: The I{signed}, (1st) eccentricity I{squared} (C{float} or C{0}), M{1 - (b / a)**2}. 

1979 

1980 @note: The result is positive for I{oblate}, negative for I{prolate} or C{0} 

1981 for I{near-spherical} ellipsoids. 

1982 ''' 

1983 return Float(e2=_a2b2e2(a, b, b2=False)) 

1984 

1985 

1986def a_b2e22(a, b): 

1987 '''Return C{e22}, the I{2nd eccentricity squared} for a given I{equatorial} and I{polar} radius. 

1988 

1989 @arg a: Equatorial radius (C{scalar} > 0). 

1990 @arg b: Polar radius (C{scalar} > 0). 

1991 

1992 @return: The I{signed}, 2nd eccentricity I{squared} (C{float} or C{0}), M{(a / b)**2 - 1}. 

1993 

1994 @note: The result is positive for I{oblate}, negative for I{prolate} or C{0} 

1995 for I{near-spherical} ellipsoids. 

1996 ''' 

1997 return Float(e22=_a2b2e2(a, b, a2=False)) 

1998 

1999 

2000def a_b2e32(a, b): 

2001 '''Return C{e32}, the I{3rd eccentricity squared} for a given I{equatorial} and I{polar} radius. 

2002 

2003 @arg a: Equatorial radius (C{scalar} > 0). 

2004 @arg b: Polar radius (C{scalar} > 0). 

2005 

2006 @return: The I{signed}, 3rd eccentricity I{squared} (C{float} or C{0}), 

2007 M{(a**2 - b**2) / (a**2 + b**2)}. 

2008 

2009 @note: The result is positive for I{oblate}, negative for I{prolate} or C{0} 

2010 for I{near-spherical} ellipsoids. 

2011 ''' 

2012 return Float(e32=_a2b2e2(a, b)) 

2013 

2014 

2015def _a2b2e2(a, b, a2=True, b2=True): 

2016 '''(INTERNAL) Helper for C{a_b2e}, C{a_b2e2}, C{a_b2e22} and C{a_b2e32}. 

2017 ''' 

2018 if _ispherical_a_b(a, b): 

2019 e2 = _0_0 

2020 else: # a > 0, b > 0 

2021 a, b = (_1_0, b / a) if a > b else (a / b, _1_0) 

2022 a2b2 = float(a - b) * (a + b) 

2023 e2 = _over(a2b2, (a**2 if a2 else _0_0) + 

2024 (b**2 if b2 else _0_0)) if a2b2 else _0_0 

2025 return e2 

2026 

2027 

2028def a_b2f(a, b): 

2029 '''Return C{f}, the I{flattening} for a given I{equatorial} and I{polar} radius. 

2030 

2031 @arg a: Equatorial radius (C{scalar} > 0). 

2032 @arg b: Polar radius (C{scalar} > 0). 

2033 

2034 @return: The flattening (C{scalar} or C{0}), M{(a - b) / a}. 

2035 

2036 @note: The result is positive for I{oblate}, negative for I{prolate} or C{0} 

2037 for I{near-spherical} ellipsoids. 

2038 ''' 

2039 f = 0 if _ispherical_a_b(a, b) else _over(float(a - b), a) 

2040 return _f_0_0 if _ispherical_f(f) else Float(f=f) 

2041 

2042 

2043def a_b2f_(a, b): 

2044 '''Return C{f_}, the I{inverse flattening} for a given I{equatorial} and I{polar} radius. 

2045 

2046 @arg a: Equatorial radius (C{scalar} > 0). 

2047 @arg b: Polar radius (C{scalar} > 0). 

2048 

2049 @return: The inverse flattening (C{scalar} or C{0}), M{a / (a - b)}. 

2050 

2051 @note: The result is positive for I{oblate}, negative for I{prolate} or C{0} 

2052 for I{near-spherical} ellipsoids. 

2053 ''' 

2054 f_ = 0 if _ispherical_a_b(a, b) else _over(a, float(a - b)) 

2055 return _f__0_0 if _ispherical_f_(f_) else Float(f_=f_) 

2056 

2057 

2058def a_b2f2(a, b): 

2059 '''Return C{f2}, the I{2nd flattening} for a given I{equatorial} and I{polar} radius. 

2060 

2061 @arg a: Equatorial radius (C{scalar} > 0). 

2062 @arg b: Polar radius (C{scalar} > 0). 

2063 

2064 @return: The I{signed}, 2nd flattening (C{scalar} or C{0}), M{(a - b) / b}. 

2065 

2066 @note: The result is positive for I{oblate}, negative for I{prolate} or C{0} 

2067 for I{near-spherical} ellipsoids. 

2068 ''' 

2069 t = 0 if _ispherical_a_b(a, b) else float(a - b) 

2070 return Float(f2=_0_0 if fabs(t) < EPS0 else _over(t, b)) 

2071 

2072 

2073def a_b2n(a, b): 

2074 '''Return C{n}, the I{3rd flattening} for a given I{equatorial} and I{polar} radius. 

2075 

2076 @arg a: Equatorial radius (C{scalar} > 0). 

2077 @arg b: Polar radius (C{scalar} > 0). 

2078 

2079 @return: The I{signed}, 3rd flattening (C{scalar} or C{0}), M{(a - b) / (a + b)}. 

2080 

2081 @note: The result is positive for I{oblate}, negative for I{prolate} or C{0} 

2082 for I{near-spherical} ellipsoids. 

2083 ''' 

2084 t = 0 if _ispherical_a_b(a, b) else float(a - b) 

2085 return Float(n=_0_0 if fabs(t) < EPS0 else _over(t, a + b)) 

2086 

2087 

2088def a_f2b(a, f): 

2089 '''Return C{b}, the I{polar} radius for a given I{equatorial} radius and I{flattening}. 

2090 

2091 @arg a: Equatorial radius (C{scalar} > 0). 

2092 @arg f: Flattening (C{scalar} < 1, negative for I{prolate}). 

2093 

2094 @return: The polar radius (C{float}), M{a * (1 - f)}. 

2095 ''' 

2096 b = a if _ispherical_f(f) else (a * (_1_0 - f)) 

2097 return Radius_(b=a if _ispherical_a_b(a, b) else b) 

2098 

2099 

2100def a_f_2b(a, f_): 

2101 '''Return C{b}, the I{polar} radius for a given I{equatorial} radius and I{inverse flattening}. 

2102 

2103 @arg a: Equatorial radius (C{scalar} > 0). 

2104 @arg f_: Inverse flattening (C{scalar} >>> 1). 

2105 

2106 @return: The polar radius (C{float}), M{a * (f_ - 1) / f_}. 

2107 ''' 

2108 b = a if _ispherical_f_(f_) else _over(a * (f_ - _1_0), f_) 

2109 return Radius_(b=a if _ispherical_a_b(a, b) else b) 

2110 

2111 

2112def b_f2a(b, f): 

2113 '''Return C{a}, the I{equatorial} radius for a given I{polar} radius and I{flattening}. 

2114 

2115 @arg b: Polar radius (C{scalar} > 0). 

2116 @arg f: Flattening (C{scalar} < 1, negative for I{prolate}). 

2117 

2118 @return: The equatorial radius (C{float}), M{b / (1 - f)}. 

2119 ''' 

2120 t = _1_0 - f 

2121 a = b if fabs(t) < EPS0 else _over(b, t) 

2122 return Radius_(a=b if _ispherical_a_b(a, b) else a) 

2123 

2124 

2125def b_f_2a(b, f_): 

2126 '''Return C{a}, the I{equatorial} radius for a given I{polar} radius and I{inverse flattening}. 

2127 

2128 @arg b: Polar radius (C{scalar} > 0). 

2129 @arg f_: Inverse flattening (C{scalar} >>> 1). 

2130 

2131 @return: The equatorial radius (C{float}), M{b * f_ / (f_ - 1)}. 

2132 ''' 

2133 t = f_ - _1_0 

2134 a = b if _ispherical_f_(f_) or fabs(t) < EPS0 \ 

2135 or fabs(t - f_) < EPS0 else _over(b * f_, t) 

2136 return Radius_(a=b if _ispherical_a_b(a, b) else a) 

2137 

2138 

2139def e2f(e): 

2140 '''Return C{f}, the I{flattening} for a given I{1st eccentricity}. 

2141 

2142 @arg e: The (1st) eccentricity (0 <= C{float} < 1) 

2143 

2144 @return: The flattening (C{scalar} or C{0}). 

2145 

2146 @see: Function L{e22f}. 

2147 ''' 

2148 return e22f(e**2) 

2149 

2150 

2151def e22f(e2): 

2152 '''Return C{f}, the I{flattening} for a given I{1st eccentricity squared}. 

2153 

2154 @arg e2: The (1st) eccentricity I{squared}, I{signed} (L{NINF} < C{float} < 1) 

2155 

2156 @return: The flattening (C{float} or C{0}), M{e2 / (sqrt(1 - e2) + 1)}. 

2157 ''' 

2158 return Float(f=_over(e2, sqrt(_1_0 - e2) + _1_0)) if e2 and e2 < _1_0 else _f_0_0 

2159 

2160 

2161def f2e2(f): 

2162 '''Return C{e2}, the I{1st eccentricity squared} for a given I{flattening}. 

2163 

2164 @arg f: Flattening (C{scalar} < 1, negative for I{prolate}). 

2165 

2166 @return: The I{signed}, (1st) eccentricity I{squared} (C{float} < 1), M{f * (2 - f)}. 

2167 

2168 @note: The result is positive for I{oblate}, negative for I{prolate} or C{0} 

2169 for I{near-spherical} ellipsoids. 

2170 

2171 @see: U{Eccentricity conversions<https://GeographicLib.SourceForge.io/ 

2172 C++/doc/classGeographicLib_1_1Ellipsoid.html>} and U{Flattening 

2173 <https://WikiPedia.org/wiki/Flattening>}. 

2174 ''' 

2175 return Float(e2=_0_0 if _ispherical_f(f) else (f * (_2_0 - f))) 

2176 

2177 

2178def f2e22(f): 

2179 '''Return C{e22}, the I{2nd eccentricity squared} for a given I{flattening}. 

2180 

2181 @arg f: Flattening (C{scalar} < 1, negative for I{prolate}). 

2182 

2183 @return: The I{signed}, 2nd eccentricity I{squared} (C{float} > -1 or C{INF}), 

2184 M{f * (2 - f) / (1 - f)**2}. 

2185 

2186 @note: The result is positive for I{oblate}, negative for I{prolate} or C{0} 

2187 for near-spherical ellipsoids. 

2188 

2189 @see: U{Eccentricity conversions<https://GeographicLib.SourceForge.io/ 

2190 C++/doc/classGeographicLib_1_1Ellipsoid.html>}. 

2191 ''' 

2192 # e2 / (1 - e2) == f * (2 - f) / (1 - f)**2 

2193 t = (_1_0 - f)**2 

2194 return Float(e22=INF if t < EPS0 else _over(f2e2(f), t)) # PYCHOK type 

2195 

2196 

2197def f2e32(f): 

2198 '''Return C{e32}, the I{3rd eccentricity squared} for a given I{flattening}. 

2199 

2200 @arg f: Flattening (C{scalar} < 1, negative for I{prolate}). 

2201 

2202 @return: The I{signed}, 3rd eccentricity I{squared} (C{float}), 

2203 M{f * (2 - f) / (1 + (1 - f)**2)}. 

2204 

2205 @note: The result is positive for I{oblate}, negative for I{prolate} or C{0} 

2206 for I{near-spherical} ellipsoids. 

2207 

2208 @see: U{Eccentricity conversions<https://GeographicLib.SourceForge.io/ 

2209 C++/doc/classGeographicLib_1_1Ellipsoid.html>}. 

2210 ''' 

2211 # e2 / (2 - e2) == f * (2 - f) / (1 + (1 - f)**2) 

2212 e2 = f2e2(f) 

2213 return Float(e32=_over(e2, _2_0 - e2)) 

2214 

2215 

2216def f_2f(f_): 

2217 '''Return C{f}, the I{flattening} for a given I{inverse flattening}. 

2218 

2219 @arg f_: Inverse flattening (C{scalar} >>> 1). 

2220 

2221 @return: The flattening (C{scalar} or C{0}), M{1 / f_}. 

2222 

2223 @note: The result is positive for I{oblate}, negative for I{prolate} or C{0} 

2224 for I{near-spherical} ellipsoids. 

2225 ''' 

2226 f = 0 if _ispherical_f_(f_) else _over(_1_0, f_) 

2227 return _f_0_0 if _ispherical_f(f) else Float(f=f) # PYCHOK type 

2228 

2229 

2230def f2f_(f): 

2231 '''Return C{f_}, the I{inverse flattening} for a given I{flattening}. 

2232 

2233 @arg f: Flattening (C{scalar} < 1, negative for I{prolate}). 

2234 

2235 @return: The inverse flattening (C{scalar} or C{0}), M{1 / f}. 

2236 

2237 @note: The result is positive for I{oblate}, negative for I{prolate} or C{0} 

2238 for I{near-spherical} ellipsoids. 

2239 ''' 

2240 f_ = 0 if _ispherical_f(f) else _over(_1_0, f) 

2241 return _f__0_0 if _ispherical_f_(f_) else Float(f_=f_) # PYCHOK type 

2242 

2243 

2244def f2f2(f): 

2245 '''Return C{f2}, the I{2nd flattening} for a given I{flattening}. 

2246 

2247 @arg f: Flattening (C{scalar} < 1, negative for I{prolate}). 

2248 

2249 @return: The I{signed}, 2nd flattening (C{scalar} or C{INF}), M{f / (1 - f)}. 

2250 

2251 @note: The result is positive for I{oblate}, negative for I{prolate} or C{0} 

2252 for I{near-spherical} ellipsoids. 

2253 

2254 @see: U{Eccentricity conversions<https://GeographicLib.SourceForge.io/ 

2255 C++/doc/classGeographicLib_1_1Ellipsoid.html>} and U{Flattening 

2256 <https://WikiPedia.org/wiki/Flattening>}. 

2257 ''' 

2258 t = _1_0 - f 

2259 return Float(f2=_0_0 if _ispherical_f(f) else 

2260 (INF if fabs(t) < EPS else _over(f, t))) # PYCHOK type 

2261 

2262 

2263def f2n(f): 

2264 '''Return C{n}, the I{3rd flattening} for a given I{flattening}. 

2265 

2266 @arg f: Flattening (C{scalar} < 1, negative for I{prolate}). 

2267 

2268 @return: The I{signed}, 3rd flattening (-1 <= C{float} < 1), 

2269 M{f / (2 - f)}. 

2270 

2271 @note: The result is positive for I{oblate}, negative for I{prolate} or C{0} 

2272 for I{near-spherical} ellipsoids. 

2273 

2274 @see: U{Eccentricity conversions<https://GeographicLib.SourceForge.io/ 

2275 C++/doc/classGeographicLib_1_1Ellipsoid.html>} and U{Flattening 

2276 <https://WikiPedia.org/wiki/Flattening>}. 

2277 ''' 

2278 return Float(n=_0_0 if _ispherical_f(f) else _over(f, float(_2_0 - f))) 

2279 

2280 

2281def n2e2(n): 

2282 '''Return C{e2}, the I{1st eccentricity squared} for a given I{3rd flattening}. 

2283 

2284 @arg n: The 3rd flattening (-1 <= C{scalar} < 1). 

2285 

2286 @return: The I{signed}, (1st) eccentricity I{squared} (C{float} or NINF), 

2287 M{4 * n / (1 + n)**2}. 

2288 

2289 @note: The result is positive for I{oblate}, negative for I{prolate} or C{0} 

2290 for I{near-spherical} ellipsoids. 

2291 

2292 @see: U{Flattening<https://WikiPedia.org/wiki/Flattening>}. 

2293 ''' 

2294 t = (n + _1_0)**2 

2295 return Float(e2=_0_0 if fabs(n) < EPS0 else 

2296 (NINF if t < EPS0 else _over(_4_0 * n, t))) 

2297 

2298 

2299def n2f(n): 

2300 '''Return C{f}, the I{flattening} for a given I{3rd flattening}. 

2301 

2302 @arg n: The 3rd flattening (-1 <= C{scalar} < 1). 

2303 

2304 @return: The flattening (C{scalar} or NINF), M{2 * n / (1 + n)}. 

2305 

2306 @see: U{Eccentricity conversions<https://GeographicLib.SourceForge.io/ 

2307 C++/doc/classGeographicLib_1_1Ellipsoid.html>} and U{Flattening 

2308 <https://WikiPedia.org/wiki/Flattening>}. 

2309 ''' 

2310 t = n + _1_0 

2311 f = 0 if fabs(n) < EPS0 else (NINF if t < EPS0 else _over(_2_0 * n, t)) 

2312 return _f_0_0 if _ispherical_f(f) else Float(f=f) 

2313 

2314 

2315def n2f_(n): 

2316 '''Return C{f_}, the I{inverse flattening} for a given I{3rd flattening}. 

2317 

2318 @arg n: The 3rd flattening (-1 <= C{scalar} < 1). 

2319 

2320 @return: The inverse flattening (C{scalar} or C{0}), M{1 / f}. 

2321 

2322 @see: L{n2f} and L{f2f_}. 

2323 ''' 

2324 return f2f_(n2f(n)) 

2325 

2326 

2327class Ellipsoids(_NamedEnum): 

2328 '''(INTERNAL) L{Ellipsoid} registry, I{must} be a sub-class 

2329 to accommodate the L{_LazyNamedEnumItem} properties. 

2330 ''' 

2331 def _Lazy(self, a, b, f_, **kwds): 

2332 '''(INTERNAL) Instantiate the L{Ellipsoid}. 

2333 ''' 

2334 return Ellipsoid(a, b=b, f_=f_, **kwds) 

2335 

2336Ellipsoids = Ellipsoids(Ellipsoid) # PYCHOK singleton 

2337'''Some pre-defined L{Ellipsoid}s, all I{lazily} instantiated.''' 

2338# <https://www.GNU.org/software/gama/manual/html_node/Supported-ellipsoids.html> 

2339# <https://GSSC.ESA.int/navipedia/index.php/Reference_Frames_in_GNSS> 

2340# <https://kb.OSU.edu/dspace/handle/1811/77986> 

2341# <https://www.IBM.com/docs/en/db2/11.5?topic=systems-supported-spheroids> 

2342# <https://w3.Energistics.org/archive/Epicentre/Epicentre_v3.0/DataModel/LogicalDictionary/StandardValues/ellipsoid.html> 

2343# <https://GitHub.com/locationtech/proj4j/blob/master/src/main/java/org/locationtech/proj4j/datum/Ellipsoid.java> 

2344Ellipsoids._assert( # <https://WikiPedia.org/wiki/Earth_ellipsoid> 

2345 Airy1830 = _lazy(_Airy1830_, *_T(6377563.396, _0_0, 299.3249646)), # b=6356256.909 

2346 AiryModified = _lazy(_AiryModified_, *_T(6377340.189, _0_0, 299.3249646)), # b=6356034.448 

2347# APL4_9 = _lazy('APL4_9', *_T(6378137.0, _0_0, 298.24985392)), # Appl. Phys. Lab. 1965 

2348# ANS = _lazy('ANS', *_T(6378160.0, _0_0, 298.25)), # Australian Nat. Spheroid 

2349# AN_SA96 = _lazy('AN_SA96', *_T(6378160.0, _0_0, 298.24985392)), # Australian Nat. South America 

2350 Australia1966 = _lazy('Australia1966', *_T(6378160.0, _0_0, 298.25)), # b=6356774.7192 

2351 ATS1977 = _lazy('ATS1977', *_T(6378135.0, _0_0, 298.257)), # "Average Terrestrial System" 

2352 Bessel1841 = _lazy(_Bessel1841_, *_T(6377397.155, 6356078.962818, 299.152812797)), 

2353 BesselModified = _lazy('BesselModified', *_T(6377492.018, _0_0, 299.1528128)), 

2354# BesselNamibia = _lazy('BesselNamibia', *_T(6377483.865, _0_0, 299.1528128)), 

2355 CGCS2000 = _lazy('CGCS2000', *_T(R_MA, _0_0, 298.257222101)), # BeiDou Coord System (BDC) 

2356# Clarke1858 = _lazy('Clarke1858', *_T(6378293.639, _0_0, 294.260676369)), 

2357 Clarke1866 = _lazy(_Clarke1866_, *_T(6378206.4, 6356583.8, 294.978698214)), 

2358 Clarke1880 = _lazy('Clarke1880', *_T(6378249.145, 6356514.86954978, 293.465)), 

2359 Clarke1880IGN = _lazy(_Clarke1880IGN_, *_T(6378249.2, 6356515.0, 293.466021294)), 

2360 Clarke1880Mod = _lazy('Clarke1880Mod', *_T(6378249.145, 6356514.96639549, 293.466307656)), # aka Clarke1880Arc 

2361 CPM1799 = _lazy('CPM1799', *_T(6375738.7, 6356671.92557493, 334.39)), # Comm. des Poids et Mesures 

2362 Delambre1810 = _lazy('Delambre1810', *_T(6376428.0, 6355957.92616372, 311.5)), # Belgium 

2363 Engelis1985 = _lazy('Engelis1985', *_T(6378136.05, 6356751.32272154, 298.2566)), 

2364# Everest1830 = _lazy('Everest1830', *_T(6377276.345, _0_0, 300.801699997)), 

2365# Everest1948 = _lazy('Everest1948', *_T(6377304.063, _0_0, 300.801699997)), 

2366# Everest1956 = _lazy('Everest1956', *_T(6377301.243, _0_0, 300.801699997)), 

2367 Everest1969 = _lazy('Everest1969', *_T(6377295.664, 6356094.667915, 300.801699997)), 

2368 Everest1975 = _lazy('Everest1975', *_T(6377299.151, 6356098.14512013, 300.8017255)), 

2369 Fisher1968 = _lazy('Fisher1968', *_T(6378150.0, 6356768.33724438, 298.3)), 

2370# Fisher1968Mod = _lazy('Fisher1968Mod', *_T(6378155.0, _0_0, 298.3)), 

2371 GEM10C = _lazy('GEM10C', *_T(R_MA, 6356752.31424783, 298.2572236)), 

2372 GPES = _lazy('GPES', *_T(6378135.0, 6356750.0, _0_0)), # "Gen. Purpose Earth Spheroid" 

2373 GRS67 = _lazy('GRS67', *_T(6378160.0, _0_0, 298.247167427)), # Lucerne b=6356774.516 

2374# GRS67Truncated = _lazy('GRS67Truncated', *_T(6378160.0, _0_0, 298.25)), 

2375 GRS80 = _lazy(_GRS80_, *_T(R_MA, 6356752.314140347, 298.25722210088)), # IUGG, ITRS, ETRS89 

2376# Hayford1924 = _lazy('Hayford1924', *_T(6378388.0, 6356911.94612795, None)), # aka Intl1924 f_=297 

2377 Helmert1906 = _lazy('Helmert1906', *_T(6378200.0, 6356818.16962789, 298.3)), 

2378# Hough1960 = _lazy('Hough1960', *_T(6378270.0, _0_0, 297.0)), 

2379 IAU76 = _lazy('IAU76', *_T(6378140.0, _0_0, 298.257)), # Int'l Astronomical Union 

2380 IERS1989 = _lazy('IERS1989', *_T(6378136.0, _0_0, 298.257)), # b=6356751.302 

2381 IERS1992TOPEX = _lazy('IERS1992TOPEX', *_T(6378136.3, 6356751.61659215, 298.257223563)), # IERS/TOPEX/Poseidon/McCarthy 

2382 IERS2003 = _lazy('IERS2003', *_T(6378136.6, 6356751.85797165, 298.25642)), 

2383 Intl1924 = _lazy(_Intl1924_, *_T(6378388.0, _0_0, 297.0)), # aka Hayford b=6356911.9462795 

2384 Intl1967 = _lazy('Intl1967', *_T(6378157.5, 6356772.2, 298.24961539)), # New Int'l 

2385 Krassovski1940 = _lazy(_Krassovski1940_, *_T(6378245.0, 6356863.01877305, 298.3)), # spelling 

2386 Krassowsky1940 = _lazy(_Krassowsky1940_, *_T(6378245.0, 6356863.01877305, 298.3)), # spelling 

2387# Kaula = _lazy('Kaula', *_T(6378163.0, _0_0, 298.24)), # Kaula 1961 

2388# Lerch = _lazy('Lerch', *_T(6378139.0, _0_0, 298.257)), # Lerch 1979 

2389 Maupertuis1738 = _lazy('Maupertuis1738', *_T(6397300.0, 6363806.28272251, 191.0)), # France 

2390 Mercury1960 = _lazy('Mercury1960', *_T(6378166.0, 6356784.28360711, 298.3)), 

2391 Mercury1968Mod = _lazy('Mercury1968Mod', *_T(6378150.0, 6356768.33724438, 298.3)), 

2392# MERIT = _lazy('MERIT', *_T(6378137.0, _0_0, 298.257)), # MERIT 1983 

2393# NWL10D = _lazy('NWL10D', *_T(6378135.0, _0_0, 298.26)), # Naval Weapons Lab. 

2394 NWL1965 = _lazy('NWL1965', *_T(6378145.0, 6356759.76948868, 298.25)), # Naval Weapons Lab. 

2395# NWL9D = _lazy('NWL9D', *_T(6378145.0, 6356759.76948868, 298.25)), # NWL1965 

2396 OSU86F = _lazy('OSU86F', *_T(6378136.2, 6356751.51693008, 298.2572236)), 

2397 OSU91A = _lazy('OSU91A', *_T(6378136.3, 6356751.6165948, 298.2572236)), 

2398# Plessis1817 = _lazy('Plessis1817', *_T(6397523.0, 6355863.0, 153.56512242)), # XXX incorrect? 

2399 Plessis1817 = _lazy('Plessis1817', *_T(6376523.0, 6355862.93325557, 308.64)), # XXX IGN France 1972 

2400# Prolate = _lazy('Prolate', *_T(6356752.3, R_MA, _0_0)), 

2401 PZ90 = _lazy('PZ90', *_T(6378136.0, _0_0, 298.257839303)), # GLOSNASS PZ-90 and PZ-90.11 

2402# SEAsia = _lazy('SEAsia', *_T(6378155.0, _0_0, 298.3)), # SouthEast Asia 

2403 SGS85 = _lazy('SGS85', *_T(6378136.0, 6356751.30156878, 298.257)), # Soviet Geodetic System 

2404 SoAmerican1969 = _lazy('SoAmerican1969', *_T(6378160.0, 6356774.71919531, 298.25)), # South American 

2405 Sphere = _lazy(_Sphere_, *_T(R_M, R_M, _0_0)), # pseudo 

2406 SphereAuthalic = _lazy('SphereAuthalic', *_T(R_FM, R_FM, _0_0)), # pseudo 

2407 SpherePopular = _lazy('SpherePopular', *_T(R_MA, R_MA, _0_0)), # EPSG:3857 Spheroid 

2408 Struve1860 = _lazy('Struve1860', *_T(6378298.3, 6356657.14266956, 294.73)), 

2409# Walbeck = _lazy('Walbeck', *_T(6376896.0, _0_0, 302.78)), 

2410# WarOffice = _lazy('WarOffice', *_T(6378300.0, _0_0, 296.0)), 

2411 WGS60 = _lazy('WGS60', *_T(6378165.0, 6356783.28695944, 298.3)), 

2412 WGS66 = _lazy('WGS66', *_T(6378145.0, 6356759.76948868, 298.25)), 

2413 WGS72 = _lazy(_WGS72_, *_T(6378135.0, _0_0, 298.26)), # b=6356750.52 

2414 WGS84 = _lazy(_WGS84_, *_T(R_MA, _0_0, _f__WGS84)), # GPS b=6356752.3142451793 

2415# U{NOAA/NOS/NGS/inverse<https://GitHub.com/noaa-ngs/inverse/blob/main/invers3d.f>} 

2416 WGS84_NGS = _lazy('WGS84_NGS', *_T(R_MA, _0_0, 298.257222100882711243162836600094)) 

2417) 

2418 

2419_EWGS84 = Ellipsoids.WGS84 # (INTERNAL) shared 

2420 

2421if __name__ == _DMAIN_: 

2422 

2423 from pygeodesy.interns import _COMMA_, _NL_, _NLATvar_ 

2424 from pygeodesy import nameof, printf 

2425 

2426 for E in (_EWGS84, Ellipsoids.GRS80, # NAD83, 

2427 Ellipsoids.Sphere, Ellipsoids.SpherePopular, 

2428 Ellipsoid(_EWGS84.b, _EWGS84.a, name='_Prolate')): 

2429 e = f2n(E.f) - E.n 

2430 printf('# %s: %s', _DOT_('Ellipsoids', E.name), E.toStr(prec=10, terse=0), nl=1) 

2431 printf('# e=%s, f_=%s, f=%s, n=%s (%s)', fstr(E.e, prec=13, fmt=Fmt.e), 

2432 fstr(E.f_, prec=13, fmt=Fmt.e), 

2433 fstr(E.f, prec=13, fmt=Fmt.e), 

2434 fstr(E.n, prec=13, fmt=Fmt.e), 

2435 fstr(e, prec=9, fmt=Fmt.e)) 

2436 printf('# %s %s', Ellipsoid.AlphaKs.name, fstr(E.AlphaKs, prec=20)) 

2437 printf('# %s %s', Ellipsoid.BetaKs.name, fstr(E.BetaKs, prec=20)) 

2438 printf('# %s %s', nameof(Ellipsoid.KsOrder), E.KsOrder) # property 

2439 

2440 # __doc__ of this file, force all into registry 

2441 t = [NN] + Ellipsoids.toRepr(all=True, asorted=True).split(_NL_) 

2442 printf(_NLATvar_.join(i.strip(_COMMA_) for i in t)) 

2443 

2444# % python3.13 -m pygeodesy.ellipsoids 

2445 

2446# Ellipsoids.WGS84: name='WGS84', a=6378137, f=0.0033528107, f_=298.257223563, b=6356752.3142451793, f2=0.0033640898, n=0.0016792204, e=0.0818191908, e2=0.00669438, e21=0.99330562, e22=0.0067394967, e32=0.0033584313, A=6367449.1458234144, L=10001965.7293127235, R1=6371008.7714150595, R2=6371007.1809184738, R3=6371000.7900091587, Rbiaxial=6367453.6345163295, Rtriaxial=6372797.5559594007 

2447# e=8.1819190842622e-02, f_=2.98257223563e+02, f=3.3528106647475e-03, n=1.6792203863837e-03 (0.0e+00) 

2448# AlphaKs 0.00083773182062446994, 0.00000076085277735725, 0.00000000119764550324, 0.00000000000242917068, 0.00000000000000571182, 0.0000000000000000148, 0.00000000000000000004, 0.0 

2449# BetaKs 0.00083773216405794875, 0.0000000590587015222, 0.00000000016734826653, 0.00000000000021647981, 0.00000000000000037879, 0.00000000000000000072, 0.0, 0.0 

2450# KsOrder 8 

2451 

2452# Ellipsoids.GRS80: name='GRS80', a=6378137, f=0.0033528107, f_=298.2572221009, b=6356752.3141403468, f2=0.0033640898, n=0.0016792204, e=0.081819191, e2=0.00669438, e21=0.99330562, e22=0.0067394968, e32=0.0033584313, A=6367449.1457710434, L=10001965.7292304561, R1=6371008.7713801153, R2=6371007.1808835147, R3=6371000.7899741363, Rbiaxial=6367453.6344640013, Rtriaxial=6372797.5559332585 

2453# e=8.1819191042833e-02, f_=2.9825722210088e+02, f=3.3528106811837e-03, n=1.6792203946295e-03 (0.0e+00) 

2454# AlphaKs 0.00083773182472890429, 0.00000076085278481561, 0.00000000119764552086, 0.00000000000242917073, 0.00000000000000571182, 0.0000000000000000148, 0.00000000000000000004, 0.0 

2455# BetaKs 0.0008377321681623882, 0.00000005905870210374, 0.000000000167348269, 0.00000000000021647982, 0.00000000000000037879, 0.00000000000000000072, 0.0, 0.0 

2456# KsOrder 8 

2457 

2458# Ellipsoids.Sphere: name='Sphere', a=6371008.7714149999, f=0, f_=0, b=6371008.7714149999, f2=0, n=0, e=0, e2=0, e21=1, e22=0, e32=0, A=6371008.7714149999, L=10007557.1761167478, R1=6371008.7714149999, R2=6371008.7714149999, R3=6371008.7714149999, Rbiaxial=6371008.7714149999, Rtriaxial=6371008.7714149999 

2459# e=0.0e+00, f_=0.0e+00, f=0.0e+00, n=0.0e+00 (0.0e+00) 

2460# AlphaKs 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 

2461# BetaKs 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 

2462# KsOrder 8 

2463 

2464# Ellipsoids.SpherePopular: name='SpherePopular', a=6378137, f=0, f_=0, b=6378137, f2=0, n=0, e=0, e2=0, e21=1, e22=0, e32=0, A=6378137, L=10018754.171394622, R1=6378137, R2=6378137, R3=6378137, Rbiaxial=6378137, Rtriaxial=6378137 

2465# e=0.0e+00, f_=0.0e+00, f=0.0e+00, n=0.0e+00 (0.0e+00) 

2466# AlphaKs 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 

2467# BetaKs 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 

2468# KsOrder 8 

2469 

2470# Ellipsoids._Prolate: name='_Prolate', a=6356752.3142451793, f=-0.0033640898, f_=-297.257223563, b=6378137, f2=-0.0033528107, n=-0.0016792204, e=0.0820944379, e2=-0.0067394967, e21=1.0067394967, e22=-0.00669438, e32=-0.0033584313, A=6367449.1458234144, L=10035500.5204500332, R1=6363880.5428301189, R2=6363878.9413582645, R3=6363872.5644020075, Rbiaxial=6367453.6345163295, Rtriaxial=6362105.2243882557 

2471# e=8.2094437949696e-02, f_=-2.97257223563e+02, f=-3.3640898209765e-03, n=-1.6792203863837e-03 (0.0e+00) 

2472# AlphaKs -0.00084149152514366627, 0.00000076653480614871, -0.00000000120934503389, 0.0000000000024576225, -0.00000000000000578863, 0.00000000000000001502, -0.00000000000000000004, 0.0 

2473# BetaKs -0.00084149187224351817, 0.00000005842735196773, -0.0000000001680487236, 0.00000000000021706261, -0.00000000000000038002, 0.00000000000000000073, -0.0, 0.0 

2474# KsOrder 8 

2475 

2476# **) MIT License 

2477# 

2478# Copyright (C) 2016-2025 -- mrJean1 at Gmail -- All Rights Reserved. 

2479# 

2480# Permission is hereby granted, free of charge, to any person obtaining a 

2481# copy of this software and associated documentation files (the "Software"), 

2482# to deal in the Software without restriction, including without limitation 

2483# the rights to use, copy, modify, merge, publish, distribute, sublicense, 

2484# and/or sell copies of the Software, and to permit persons to whom the 

2485# Software is furnished to do so, subject to the following conditions: 

2486# 

2487# The above copyright notice and this permission notice shall be included 

2488# in all copies or substantial portions of the Software. 

2489# 

2490# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 

2491# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 

2492# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 

2493# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 

2494# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 

2495# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 

2496# OTHER DEALINGS IN THE SOFTWARE.