pygeodesy 24.10.10__py2.py3-none-any.whl → 24.11.11__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {PyGeodesy-24.10.10.dist-info → PyGeodesy-24.11.11.dist-info}/METADATA +12 -12
- PyGeodesy-24.11.11.dist-info/RECORD +118 -0
- {PyGeodesy-24.10.10.dist-info → PyGeodesy-24.11.11.dist-info}/WHEEL +1 -1
- pygeodesy/__init__.py +14 -14
- pygeodesy/__main__.py +5 -5
- pygeodesy/albers.py +12 -17
- pygeodesy/azimuthal.py +51 -61
- pygeodesy/basics.py +60 -62
- pygeodesy/booleans.py +87 -79
- pygeodesy/cartesianBase.py +6 -6
- pygeodesy/constants.py +23 -19
- pygeodesy/css.py +7 -8
- pygeodesy/datums.py +3 -3
- pygeodesy/deprecated/__init__.py +1 -1
- pygeodesy/deprecated/classes.py +9 -9
- pygeodesy/deprecated/functions.py +6 -6
- pygeodesy/dms.py +250 -270
- pygeodesy/ecef.py +11 -14
- pygeodesy/ellipsoidalBase.py +106 -121
- pygeodesy/ellipsoidalBaseDI.py +114 -118
- pygeodesy/ellipsoidalExact.py +35 -37
- pygeodesy/ellipsoidalNvector.py +4 -4
- pygeodesy/ellipsoidalVincenty.py +2 -2
- pygeodesy/ellipsoids.py +10 -51
- pygeodesy/elliptic.py +14 -14
- pygeodesy/errors.py +28 -28
- pygeodesy/etm.py +92 -68
- pygeodesy/fmath.py +42 -40
- pygeodesy/formy.py +7 -6
- pygeodesy/fsums.py +72 -51
- pygeodesy/geodesici.py +43 -40
- pygeodesy/geodesicw.py +17 -16
- pygeodesy/geodesicx/__init__.py +2 -2
- pygeodesy/geodesicx/gxarea.py +3 -2
- pygeodesy/geodsolve.py +79 -39
- pygeodesy/geohash.py +2 -2
- pygeodesy/geoids.py +32 -31
- pygeodesy/heights.py +2 -2
- pygeodesy/internals.py +201 -147
- pygeodesy/interns.py +23 -20
- pygeodesy/karney.py +62 -13
- pygeodesy/ktm.py +11 -13
- pygeodesy/latlonBase.py +18 -20
- pygeodesy/lazily.py +210 -218
- pygeodesy/lcc.py +4 -4
- pygeodesy/ltp.py +10 -10
- pygeodesy/ltpTuples.py +74 -75
- pygeodesy/mgrs.py +20 -21
- pygeodesy/named.py +15 -10
- pygeodesy/nvectorBase.py +1 -1
- pygeodesy/osgr.py +9 -12
- pygeodesy/points.py +2 -2
- pygeodesy/props.py +35 -14
- pygeodesy/resections.py +9 -10
- pygeodesy/rhumb/__init__.py +1 -1
- pygeodesy/rhumb/bases.py +5 -5
- pygeodesy/rhumb/solve.py +9 -10
- pygeodesy/simplify.py +5 -5
- pygeodesy/solveBase.py +7 -25
- pygeodesy/sphericalBase.py +20 -23
- pygeodesy/sphericalNvector.py +103 -145
- pygeodesy/sphericalTrigonometry.py +68 -73
- pygeodesy/streprs.py +5 -5
- pygeodesy/trf.py +6 -4
- pygeodesy/triaxials.py +46 -9
- pygeodesy/units.py +5 -4
- pygeodesy/ups.py +6 -6
- pygeodesy/utily.py +2 -2
- pygeodesy/utm.py +7 -7
- pygeodesy/vector2d.py +13 -13
- pygeodesy/vector3d.py +19 -21
- pygeodesy/vector3dBase.py +21 -19
- pygeodesy/webmercator.py +4 -4
- pygeodesy/wgrs.py +4 -4
- PyGeodesy-24.10.10.dist-info/RECORD +0 -118
- {PyGeodesy-24.10.10.dist-info → PyGeodesy-24.11.11.dist-info}/top_level.txt +0 -0
pygeodesy/geodsolve.py
CHANGED
|
@@ -14,9 +14,8 @@ from pygeodesy.basics import _xinstanceof
|
|
|
14
14
|
# from pygeodesy.geodesicx import GeodesicAreaExact # _MODS
|
|
15
15
|
from pygeodesy.interns import NN, _UNDER_
|
|
16
16
|
from pygeodesy.karney import Caps, GeodesicError, GeodSolve12Tuple, \
|
|
17
|
-
_sincos2d, _0_0, NAN
|
|
18
|
-
from pygeodesy.lazily import _ALL_DOCS, _ALL_LAZY, _ALL_MODS as _MODS
|
|
19
|
-
_getenv, _PYGEODESY_GEODSOLVE_
|
|
17
|
+
_sincos2d, _Xables, _0_0, NAN
|
|
18
|
+
from pygeodesy.lazily import _ALL_DOCS, _ALL_LAZY, _ALL_MODS as _MODS
|
|
20
19
|
from pygeodesy.named import _name1__
|
|
21
20
|
from pygeodesy.namedTuples import Destination3Tuple, Distance3Tuple
|
|
22
21
|
from pygeodesy.props import Property, Property_RO, property_RO
|
|
@@ -24,7 +23,7 @@ from pygeodesy.solveBase import _SolveGDictBase, _SolveGDictLineBase
|
|
|
24
23
|
from pygeodesy.utily import _unrollon, _Wrap, wrap360
|
|
25
24
|
|
|
26
25
|
__all__ = _ALL_LAZY.geodsolve
|
|
27
|
-
__version__ = '24.
|
|
26
|
+
__version__ = '24.11.02'
|
|
28
27
|
|
|
29
28
|
|
|
30
29
|
class _GeodesicSolveBase(_SolveGDictBase):
|
|
@@ -33,8 +32,8 @@ class _GeodesicSolveBase(_SolveGDictBase):
|
|
|
33
32
|
_Error = GeodesicError
|
|
34
33
|
_Names_Direct = \
|
|
35
34
|
_Names_Inverse = GeodSolve12Tuple._Names_
|
|
36
|
-
_Xable_name =
|
|
37
|
-
_Xable_path =
|
|
35
|
+
_Xable_name = _Xables.GeodSolve.__name__
|
|
36
|
+
_Xable_path = _Xables.GeodSolve()
|
|
38
37
|
|
|
39
38
|
@Property_RO
|
|
40
39
|
def _b_option(self):
|
|
@@ -182,15 +181,6 @@ class GeodesicSolve(_GeodesicSolveBase):
|
|
|
182
181
|
ll2 = _unrollon(ll1, _Wrap.point(ll2))
|
|
183
182
|
return self.InverseLine(ll1.lat, ll1.lon, ll2.lat, ll2.lon, **caps_name)
|
|
184
183
|
|
|
185
|
-
# def _InverseLine2(self, lat1, lon1, lat2, lon2, **caps_name): # in .geodesici
|
|
186
|
-
# '''(INTERNAL) Helper for L{InverseLine} and L{_InverseLine}.
|
|
187
|
-
# '''
|
|
188
|
-
# r = self.Inverse(lat1, lon1, lat2, lon2)
|
|
189
|
-
# gl = GeodesicLineSolve(self, lat1, lon1, r.azi1, **_name1__(caps_name, _or_nameof=self))
|
|
190
|
-
# gl._a13 = r.a12 # gl.SetArc(r.a12)
|
|
191
|
-
# gl._s13 = r.s12 # gl.SetDistance(r.s12)
|
|
192
|
-
# return gl, r
|
|
193
|
-
|
|
194
184
|
def InverseLine(self, lat1, lon1, lat2, lon2, **caps_name): # PYCHOK no cover
|
|
195
185
|
'''Set up a L{GeodesicLineSolve} to compute several points
|
|
196
186
|
on a single geodesic.
|
|
@@ -271,14 +261,14 @@ class GeodesicLineSolve(_GeodesicSolveBase, _SolveGDictLineBase):
|
|
|
271
261
|
'''
|
|
272
262
|
return self._a13
|
|
273
263
|
|
|
274
|
-
def Arc(self):
|
|
264
|
+
def Arc(self): # PYCHOK no cover
|
|
275
265
|
'''Return the arc length to reference point 3 (C{degrees} or C{NAN}).
|
|
276
266
|
|
|
277
267
|
@see: Method L{SetArc} and property L{a13}.
|
|
278
268
|
'''
|
|
279
269
|
return self.a13
|
|
280
270
|
|
|
281
|
-
def ArcPosition(self, a12, outmask=Caps.STANDARD): # PYCHOK
|
|
271
|
+
def ArcPosition(self, a12, outmask=Caps.STANDARD): # PYCHOK no cover
|
|
282
272
|
'''Find the position on the line given B{C{a12}}.
|
|
283
273
|
|
|
284
274
|
@arg a12: Spherical arc length from the first point to the
|
|
@@ -348,7 +338,7 @@ class GeodesicLineSolve(_GeodesicSolveBase, _SolveGDictLineBase):
|
|
|
348
338
|
'''
|
|
349
339
|
return self._s13
|
|
350
340
|
|
|
351
|
-
def SetArc(self, a13):
|
|
341
|
+
def SetArc(self, a13): # PYCHOK no cover
|
|
352
342
|
'''Set reference point 3 in terms relative to the first point.
|
|
353
343
|
|
|
354
344
|
@arg a13: Spherical arc length from the first to the reference
|
|
@@ -363,13 +353,13 @@ class GeodesicLineSolve(_GeodesicSolveBase, _SolveGDictLineBase):
|
|
|
363
353
|
# _update_all(self)
|
|
364
354
|
return self._s13
|
|
365
355
|
|
|
366
|
-
def SetDistance(self, s13):
|
|
356
|
+
def SetDistance(self, s13): # PYCHOK no cover
|
|
367
357
|
'''Set reference point 3 in terms relative to the first point.
|
|
368
358
|
|
|
369
359
|
@arg s13: Distance from the first to the reference point (C{meter}).
|
|
370
360
|
|
|
371
|
-
@return: The arc length C{a13} (C{degrees}) between the first
|
|
372
|
-
|
|
361
|
+
@return: The arc length C{a13} (C{degrees}) between the first and
|
|
362
|
+
the reference point or C{NAN}.
|
|
373
363
|
'''
|
|
374
364
|
if self._s13 != s13:
|
|
375
365
|
self._s13 = s13
|
|
@@ -396,30 +386,32 @@ __all__ += _ALL_DOCS(_GeodesicSolveBase)
|
|
|
396
386
|
|
|
397
387
|
if __name__ == '__main__':
|
|
398
388
|
|
|
399
|
-
|
|
400
|
-
|
|
389
|
+
def _main():
|
|
390
|
+
from pygeodesy import printf
|
|
391
|
+
from sys import argv
|
|
401
392
|
|
|
402
|
-
|
|
403
|
-
|
|
393
|
+
gS = GeodesicSolve(name='Test')
|
|
394
|
+
gS.verbose = '--verbose' in argv # or '-v' in argv
|
|
404
395
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
396
|
+
if not _Xables.X_OK(gS.GeodSolve): # not set
|
|
397
|
+
gS.GeodSolve = _Xables.GeodSolve(_Xables.bin_)
|
|
398
|
+
printf('version: %s', gS.version)
|
|
408
399
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
400
|
+
r = gS.Direct(40.6, -73.8, 51, 5.5e6)
|
|
401
|
+
printf('Direct: %r', r, nl=1)
|
|
402
|
+
printf('Direct3: %r', gS.Direct3(40.6, -73.8, 51, 5.5e6))
|
|
412
403
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
404
|
+
printf('Inverse: %r', gS.Inverse( 40.6, -73.8, 51.6, -0.5), nl=1)
|
|
405
|
+
printf('Inverse1: %r', gS.Inverse1(40.6, -73.8, 51.6, -0.5))
|
|
406
|
+
printf('Inverse3: %r', gS.Inverse3(40.6, -73.8, 51.6, -0.5))
|
|
416
407
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
408
|
+
glS = GeodesicLineSolve(gS, 40.6, -73.8, 51, name='LineTest')
|
|
409
|
+
p = glS.Position(5.5e6)
|
|
410
|
+
printf('Position: %5s %r', p == r, p, nl=1)
|
|
411
|
+
p = glS.ArcPosition(49.475527)
|
|
412
|
+
printf('ArcPosition: %5s %r', p == r, p)
|
|
422
413
|
|
|
414
|
+
_main()
|
|
423
415
|
|
|
424
416
|
# % python3 -m pygeodesy.geodsolve
|
|
425
417
|
|
|
@@ -436,6 +428,21 @@ if __name__ == '__main__':
|
|
|
436
428
|
# ArcPosition: False GDict(a12=49.475527, azi1=51.0, azi2=107.189397, lat1=40.6, lat2=51.884565, lon1=-73.8, lon2=-1.141174, m12=4844148.669561, M12=0.650911, M21=0.651229, s12=5499999.948497, S12=39735074737272.734375)
|
|
437
429
|
|
|
438
430
|
|
|
431
|
+
# % python3 -m pygeodesy.geodsolve
|
|
432
|
+
|
|
433
|
+
# version: /opt/local/bin/GeodSolve: GeographicLib version 2.3
|
|
434
|
+
|
|
435
|
+
# Direct: GDict(a12=49.475527, azi1=51.0, azi2=107.189397, lat1=40.6, lat2=51.884565, lon1=-73.8, lon2=-1.141173, m12=4844148.703101, M12=0.650911, M21=0.651229, s12=5500000.0, S12=39735075134877.078125)
|
|
436
|
+
# Direct3: Destination3Tuple(lat=51.884565, lon=-1.141173, final=107.189397)
|
|
437
|
+
|
|
438
|
+
# Inverse: GDict(a12=49.94131, azi1=51.198883, azi2=107.821777, lat1=40.6, lat2=51.6, lon1=-73.8, lon2=-0.5, m12=4877684.602706, M12=0.64473, M21=0.645046, s12=5551759.400319, S12=40041368848742.53125)
|
|
439
|
+
# Inverse1: 49.94131021789904
|
|
440
|
+
# Inverse3: Distance3Tuple(distance=5551759.400319, initial=51.198883, final=107.821777)
|
|
441
|
+
|
|
442
|
+
# Position: False GDict(a12=49.475527, azi1=51.0, azi2=107.189397, lat1=40.6, lat2=51.884565, lon1=-73.8, lon2=-1.141173, s12=5500000.0)
|
|
443
|
+
# ArcPosition: False GDict(a12=49.475527, azi1=51.0, azi2=107.189397, lat1=40.6, lat2=51.884565, lon1=-73.8, lon2=-1.141174, s12=5499999.948497)
|
|
444
|
+
|
|
445
|
+
|
|
439
446
|
# % python3 -m pygeodesy.geodsolve --verbose
|
|
440
447
|
|
|
441
448
|
# GeodesicSolve 'Test' 1: /opt/local/bin/GeodSolve --version (invoke)
|
|
@@ -462,6 +469,39 @@ if __name__ == '__main__':
|
|
|
462
469
|
# Position: True GDict(a12=49.475527, azi1=51.0, azi2=107.189397, lat1=40.6, lat2=51.884565, lon1=-73.8, lon2=-1.141173, m12=4844148.703101, M12=0.650911, M21=0.651229, s12=5500000.0, S12=39735075134877.09375)
|
|
463
470
|
# ArcPosition: False GDict(a12=49.475527, azi1=51.0, azi2=107.189397, lat1=40.6, lat2=51.884565, lon1=-73.8, lon2=-1.141174, m12=4844148.669561, M12=0.650911, M21=0.651229, s12=5499999.948497, S12=39735074737272.734375)
|
|
464
471
|
|
|
472
|
+
|
|
473
|
+
# % python3 -m pygeodesy.geodsolve --verbose
|
|
474
|
+
|
|
475
|
+
# GeodesicSolve 'Test'@1: /opt/local/bin/GeodSolve --version (invoke)
|
|
476
|
+
# GeodesicSolve 'Test'@1: '/opt/local/bin/GeodSolve: GeographicLib version 2.3' (0, stdout/-err)
|
|
477
|
+
# GeodesicSolve 'Test'@1: /opt/local/bin/GeodSolve: GeographicLib version 2.3 (0)
|
|
478
|
+
# version: /opt/local/bin/GeodSolve: GeographicLib version 2.3
|
|
479
|
+
# GeodesicSolve 'Test'@2: /opt/local/bin/GeodSolve -f -E -p 10 \ 40.600000000000001 -73.799999999999997 51.0 5500000.0 (Direct)
|
|
480
|
+
# GeodesicSolve 'Test'@2: '40.600000000000001 -73.799999999999997 51.000000000000000 51.884564505606761 -1.141172861200843 107.189397162605871 5500000.0000000000 49.475527463251460 4844148.7031014860 0.65091056699808614 0.65122865892196569 39735075134877.078' (0, stdout/-err)
|
|
481
|
+
# GeodesicSolve 'Test'@2: lat1=40.600000000000001, lon1=-73.799999999999997, azi1=51.0, lat2=51.884564505606761, lon2=-1.141172861200843, azi2=107.189397162605871, s12=5500000.0, a12=49.47552746325146, m12=4844148.703101486, M12=0.65091056699808614, M21=0.65122865892196569, S12=39735075134877.078 (0)
|
|
482
|
+
|
|
483
|
+
# Direct: GDict(a12=49.475527, azi1=51.0, azi2=107.189397, lat1=40.6, lat2=51.884565, lon1=-73.8, lon2=-1.141173, m12=4844148.703101, M12=0.650911, M21=0.651229, s12=5500000.0, S12=39735075134877.078125)
|
|
484
|
+
# GeodesicSolve 'Test'@3: /opt/local/bin/GeodSolve -f -E -p 10 \ 40.600000000000001 -73.799999999999997 51.0 5500000.0 (Direct3)
|
|
485
|
+
# GeodesicSolve 'Test'@3: '40.600000000000001 -73.799999999999997 51.000000000000000 51.884564505606761 -1.141172861200843 107.189397162605871 5500000.0000000000 49.475527463251460 4844148.7031014860 0.65091056699808614 0.65122865892196569 39735075134877.078' (0, stdout/-err)
|
|
486
|
+
# GeodesicSolve 'Test'@3: lat1=40.600000000000001, lon1=-73.799999999999997, azi1=51.0, lat2=51.884564505606761, lon2=-1.141172861200843, azi2=107.189397162605871, s12=5500000.0, a12=49.47552746325146, m12=4844148.703101486, M12=0.65091056699808614, M21=0.65122865892196569, S12=39735075134877.078 (0)
|
|
487
|
+
# Direct3: Destination3Tuple(lat=51.884565, lon=-1.141173, final=107.189397)
|
|
488
|
+
# GeodesicSolve 'Test'@4: /opt/local/bin/GeodSolve -f -E -p 10 -i \ 40.600000000000001 -73.799999999999997 51.600000000000001 -0.5 (Inverse)
|
|
489
|
+
# GeodesicSolve 'Test'@4: '40.600000000000001 -73.799999999999997 51.198882845579824 51.600000000000001 -0.500000000000000 107.821776735514248 5551759.4003186813 49.941310217899037 4877684.6027061967 0.64472969205948238 0.64504567852134398 40041368848742.531' (0, stdout/-err)
|
|
490
|
+
# GeodesicSolve 'Test'@4: lat1=40.600000000000001, lon1=-73.799999999999997, azi1=51.198882845579824, lat2=51.600000000000001, lon2=-0.5, azi2=107.821776735514248, s12=5551759.4003186813, a12=49.941310217899037, m12=4877684.6027061967, M12=0.64472969205948238, M21=0.64504567852134398, S12=40041368848742.531 (0)
|
|
491
|
+
|
|
492
|
+
# Inverse: GDict(a12=49.94131, azi1=51.198883, azi2=107.821777, lat1=40.6, lat2=51.6, lon1=-73.8, lon2=-0.5, m12=4877684.602706, M12=0.64473, M21=0.645046, s12=5551759.400319, S12=40041368848742.53125)
|
|
493
|
+
# GeodesicSolve 'Test'@5: /opt/local/bin/GeodSolve -f -E -p 10 -i \ 40.600000000000001 -73.799999999999997 51.600000000000001 -0.5 (Inverse1)
|
|
494
|
+
# GeodesicSolve 'Test'@5: '40.600000000000001 -73.799999999999997 51.198882845579824 51.600000000000001 -0.500000000000000 107.821776735514248 5551759.4003186813 49.941310217899037 4877684.6027061967 0.64472969205948238 0.64504567852134398 40041368848742.531' (0, stdout/-err)
|
|
495
|
+
# GeodesicSolve 'Test'@5: lat1=40.600000000000001, lon1=-73.799999999999997, azi1=51.198882845579824, lat2=51.600000000000001, lon2=-0.5, azi2=107.821776735514248, s12=5551759.4003186813, a12=49.941310217899037, m12=4877684.6027061967, M12=0.64472969205948238, M21=0.64504567852134398, S12=40041368848742.531 (0)
|
|
496
|
+
# Inverse1: 49.94131021789904
|
|
497
|
+
# GeodesicSolve 'Test'@6: /opt/local/bin/GeodSolve -f -E -p 10 -i \ 40.600000000000001 -73.799999999999997 51.600000000000001 -0.5 (Inverse3)
|
|
498
|
+
# GeodesicSolve 'Test'@6: '40.600000000000001 -73.799999999999997 51.198882845579824 51.600000000000001 -0.500000000000000 107.821776735514248 5551759.4003186813 49.941310217899037 4877684.6027061967 0.64472969205948238 0.64504567852134398 40041368848742.531' (0, stdout/-err)
|
|
499
|
+
# GeodesicSolve 'Test'@6: lat1=40.600000000000001, lon1=-73.799999999999997, azi1=51.198882845579824, lat2=51.600000000000001, lon2=-0.5, azi2=107.821776735514248, s12=5551759.4003186813, a12=49.941310217899037, m12=4877684.6027061967, M12=0.64472969205948238, M21=0.64504567852134398, S12=40041368848742.531 (0)
|
|
500
|
+
# Inverse3: Distance3Tuple(distance=5551759.400319, initial=51.198883, final=107.821777)
|
|
501
|
+
|
|
502
|
+
# Position: False GDict(a12=49.475527, azi1=51.0, azi2=107.189397, lat1=40.6, lat2=51.884565, lon1=-73.8, lon2=-1.141173, s12=5500000.0)
|
|
503
|
+
# ArcPosition: False GDict(a12=49.475527, azi1=51.0, azi2=107.189397, lat1=40.6, lat2=51.884565, lon1=-73.8, lon2=-1.141174, s12=5499999.948497)
|
|
504
|
+
|
|
465
505
|
# **) MIT License
|
|
466
506
|
#
|
|
467
507
|
# Copyright (C) 2016-2024 -- mrJean1 at Gmail -- All Rights Reserved.
|
pygeodesy/geohash.py
CHANGED
|
@@ -7,7 +7,7 @@ Class L{Geohash} and several functions to encode, decode and inspect
|
|
|
7
7
|
C{geohashes} and optional L{Geohashed} caches.
|
|
8
8
|
|
|
9
9
|
Originally transcoded from JavaScript originals by I{(C) Chris Veness
|
|
10
|
-
2011-
|
|
10
|
+
2011-2024} and published under the same MIT Licence**, see
|
|
11
11
|
U{Geohashes<https://www.Movable-Type.co.UK/scripts/geohash.html>}.
|
|
12
12
|
|
|
13
13
|
@see: U{Geohash<https://WikiPedia.org/wiki/Geohash>}, I{Karney}'s C++
|
|
@@ -38,7 +38,7 @@ from pygeodesy.units import Degrees_, Int, Lat_, Lon_, Meter, Precision_, Str
|
|
|
38
38
|
from math import fabs, ldexp, log10, radians
|
|
39
39
|
|
|
40
40
|
__all__ = _ALL_LAZY.geohash
|
|
41
|
-
__version__ = '24.
|
|
41
|
+
__version__ = '24.10.12'
|
|
42
42
|
|
|
43
43
|
_formy = _MODS.into(formy=__name__)
|
|
44
44
|
_MASK5 = 16, 8, 4, 2, 1 # PYCHOK used!
|
pygeodesy/geoids.py
CHANGED
|
@@ -15,7 +15,7 @@ The L{GeoidG2012B} and L{GeoidPGM} interpolators both depend on U{scipy
|
|
|
15
15
|
require those packages to be installed.
|
|
16
16
|
|
|
17
17
|
In addition, each geoid interpolator needs C{grid knots} (down)loaded from
|
|
18
|
-
a C{geoid} model file, I{specific to the interpolator}
|
|
18
|
+
a C{geoid} model file, I{specific to the interpolator}. More details below
|
|
19
19
|
and in the documentation of the interpolator class. For each interpolator,
|
|
20
20
|
there are several interpolation choices, like I{linear}, I{cubic}, etc.
|
|
21
21
|
|
|
@@ -42,7 +42,7 @@ C{>>> h = ginterpolator(ll)}
|
|
|
42
42
|
|
|
43
43
|
or
|
|
44
44
|
|
|
45
|
-
C{>>>
|
|
45
|
+
C{>>> h1, h2, h3, ... = ginterpolator(ll1, ll2, ll3, ...)}
|
|
46
46
|
|
|
47
47
|
or a list, tuple, generator, etc. of C{LatLon}s
|
|
48
48
|
|
|
@@ -106,9 +106,9 @@ from pygeodesy.streprs import attrs, Fmt, fstr, pairs
|
|
|
106
106
|
from pygeodesy.units import Height, Int_, Lat, Lon
|
|
107
107
|
# from pygeodesy.utily import _Wrap # from .heights
|
|
108
108
|
|
|
109
|
-
from math import floor
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
from math import floor as _floor
|
|
110
|
+
# from os import SEEK_CUR, SEEK_SET # _MODS
|
|
111
|
+
# import os.path # _MODS
|
|
112
112
|
from struct import calcsize as _calcsize, unpack as _unpack
|
|
113
113
|
try:
|
|
114
114
|
from StringIO import StringIO as _BytesIO # reads bytes
|
|
@@ -118,7 +118,7 @@ except ImportError: # Python 3+
|
|
|
118
118
|
from io import BytesIO as _BytesIO # PYCHOK expected
|
|
119
119
|
|
|
120
120
|
__all__ = _ALL_LAZY.geoids
|
|
121
|
-
__version__ = '24.
|
|
121
|
+
__version__ = '24.11.05'
|
|
122
122
|
|
|
123
123
|
_assert_ = 'assert'
|
|
124
124
|
_bHASH_ = b'#'
|
|
@@ -159,7 +159,7 @@ class _GeoidBase(_HeightBase):
|
|
|
159
159
|
_smooth = 0 # used only for RectBivariateSpline
|
|
160
160
|
_stdev = None # fixed in GeoidKarney
|
|
161
161
|
_u2B = 0 # np.itemsize or undefined
|
|
162
|
-
_yx_hits = None # cache hits, ala Karney
|
|
162
|
+
_yx_hits = None # cache hits, ala Karney's
|
|
163
163
|
|
|
164
164
|
# _lat_d = _0_0 # increment, +tive
|
|
165
165
|
# _lat_lo = _0_0 # lower lat, south
|
|
@@ -463,7 +463,7 @@ class _GeoidBase(_HeightBase):
|
|
|
463
463
|
|
|
464
464
|
def _load(self, g, dtype, n, offset=0):
|
|
465
465
|
# numpy.fromfile, like .frombuffer
|
|
466
|
-
g.seek(offset,
|
|
466
|
+
g.seek(offset, _MODS.os.SEEK_SET)
|
|
467
467
|
return self.numpy.fromfile(g, dtype, n)
|
|
468
468
|
|
|
469
469
|
@Property_RO
|
|
@@ -545,8 +545,8 @@ class _GeoidBase(_HeightBase):
|
|
|
545
545
|
def _open(self, geoid, datum, kind, name, smooth):
|
|
546
546
|
# open the geoid file
|
|
547
547
|
try:
|
|
548
|
-
self._geoid =
|
|
549
|
-
self._sizeB =
|
|
548
|
+
self._geoid = _MODS.os.path.basename(geoid)
|
|
549
|
+
self._sizeB = _MODS.os.path.getsize(geoid)
|
|
550
550
|
g = open(geoid, _rb_)
|
|
551
551
|
except (IOError, OSError) as x:
|
|
552
552
|
raise GeoidError(geoid=geoid, cause=x)
|
|
@@ -988,21 +988,21 @@ class GeoidKarney(_GeoidBase):
|
|
|
988
988
|
p = self._pgm
|
|
989
989
|
if 0 < x < (p.nlon - 2) and 0 < y < (p.nlat - 2):
|
|
990
990
|
# read 4x4 ushorts, drop the 4 corners
|
|
991
|
-
|
|
992
|
-
e =
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
b =
|
|
991
|
+
S = _MODS.os.SEEK_SET
|
|
992
|
+
e = self._4endian
|
|
993
|
+
g = self._egm
|
|
994
|
+
n = self._4u2B
|
|
995
|
+
R = self._Ru2B
|
|
996
|
+
b = self._seek(y - 1, x - 1)
|
|
997
997
|
v = _unpack(e, g.read(n))[1:3]
|
|
998
998
|
b += R
|
|
999
|
-
g.seek(b,
|
|
999
|
+
g.seek(b, S)
|
|
1000
1000
|
v += _unpack(e, g.read(n))
|
|
1001
1001
|
b += R
|
|
1002
|
-
g.seek(b,
|
|
1002
|
+
g.seek(b, S)
|
|
1003
1003
|
v += _unpack(e, g.read(n))
|
|
1004
1004
|
b += R
|
|
1005
|
-
g.seek(b,
|
|
1005
|
+
g.seek(b, S)
|
|
1006
1006
|
v += _unpack(e, g.read(n))[1:3]
|
|
1007
1007
|
j = 1
|
|
1008
1008
|
|
|
@@ -1021,7 +1021,7 @@ class GeoidKarney(_GeoidBase):
|
|
|
1021
1021
|
def _ev(self, lat, lon): # PYCHOK expected
|
|
1022
1022
|
# interpolate the geoid height at grid (lat, lon)
|
|
1023
1023
|
fy, fx = self._g2yx2(lat, lon)
|
|
1024
|
-
y, x = int(
|
|
1024
|
+
y, x = int(_floor(fy)), int(_floor(fx))
|
|
1025
1025
|
fy -= y
|
|
1026
1026
|
fx -= x
|
|
1027
1027
|
H = self._ev2d(fy, fx, y, x) # PYCHOK ._ev2k or ._ev3k
|
|
@@ -1223,7 +1223,7 @@ class GeoidKarney(_GeoidBase):
|
|
|
1223
1223
|
p, g = self._pgm, self._egm
|
|
1224
1224
|
if g:
|
|
1225
1225
|
b = p.skip + (y * p.nlon + x) * self._u2B
|
|
1226
|
-
g.seek(b,
|
|
1226
|
+
g.seek(b, _MODS.os.SEEK_SET)
|
|
1227
1227
|
return b # position
|
|
1228
1228
|
raise GeoidError('closed file', txt=repr(p.egm)) # IOError
|
|
1229
1229
|
|
|
@@ -1551,11 +1551,11 @@ class _PGM(_Gpars):
|
|
|
1551
1551
|
t, c = 0, self._tmpfile()
|
|
1552
1552
|
# reading (s - n) rows, forward
|
|
1553
1553
|
for y in range(n, s): # PYCHOK y unused
|
|
1554
|
-
g.seek(z,
|
|
1554
|
+
g.seek(z, _MODS.os.SEEK_SET)
|
|
1555
1555
|
# Python 2 tmpfile.write returns None
|
|
1556
1556
|
t += c.write(g.read(r)) or r
|
|
1557
1557
|
if p: # wrap around to start of row
|
|
1558
|
-
g.seek(-q,
|
|
1558
|
+
g.seek(-q, _MODS.os.SEEK_CUR)
|
|
1559
1559
|
# assert(g.tell() == (z - w * self.u2B))
|
|
1560
1560
|
# Python 2 tmpfile.write returns None
|
|
1561
1561
|
t += c.write(g.read(p)) or p
|
|
@@ -1582,7 +1582,7 @@ class _PGM(_Gpars):
|
|
|
1582
1582
|
self.knots = k
|
|
1583
1583
|
self.skip = 0 # no header lines in c
|
|
1584
1584
|
|
|
1585
|
-
c.seek(0,
|
|
1585
|
+
c.seek(0, _MODS.os.SEEK_SET)
|
|
1586
1586
|
# c = open(c.name, _rb_) # reopen for numpy 1.8.0-
|
|
1587
1587
|
return c
|
|
1588
1588
|
|
|
@@ -1606,10 +1606,11 @@ class _PGM(_Gpars):
|
|
|
1606
1606
|
try:
|
|
1607
1607
|
from tempfile import NamedTemporaryFile as tmpfile
|
|
1608
1608
|
except ImportError: # Python 2.7.16-
|
|
1609
|
-
from os import tmpfile
|
|
1610
|
-
t =
|
|
1611
|
-
|
|
1612
|
-
f
|
|
1609
|
+
from _MODS.os import tmpfile
|
|
1610
|
+
t = _MODS.os.path.basename(self.pgm)
|
|
1611
|
+
t = _MODS.os.path.splitext(t)[0]
|
|
1612
|
+
f = tmpfile(mode='w+b', prefix=t or 'egm')
|
|
1613
|
+
f.seek(0, _MODS.os.SEEK_SET) # force overwrite
|
|
1613
1614
|
return f
|
|
1614
1615
|
|
|
1615
1616
|
@Property_RO
|
|
@@ -1620,7 +1621,7 @@ class _PGM(_Gpars):
|
|
|
1620
1621
|
|
|
1621
1622
|
|
|
1622
1623
|
class PGMError(GeoidError):
|
|
1623
|
-
'''
|
|
1624
|
+
'''An issue while parsing or cropping an C{egm*.pgm} geoid dataset.
|
|
1624
1625
|
'''
|
|
1625
1626
|
pass
|
|
1626
1627
|
|
|
@@ -1649,7 +1650,7 @@ def egmGeoidHeights(GeoidHeights_dat):
|
|
|
1649
1650
|
dat = _BytesIO(dat)
|
|
1650
1651
|
|
|
1651
1652
|
try:
|
|
1652
|
-
dat.seek(0,
|
|
1653
|
+
dat.seek(0, _MODS.os.SEEK_SET) # reset
|
|
1653
1654
|
except AttributeError as x:
|
|
1654
1655
|
raise GeoidError(GeoidHeights_dat=type(dat), cause=x)
|
|
1655
1656
|
|
|
@@ -1666,7 +1667,7 @@ __all__ += _ALL_DOCS(_GeoidBase)
|
|
|
1666
1667
|
|
|
1667
1668
|
if __name__ == '__main__': # MCCABE 14
|
|
1668
1669
|
|
|
1669
|
-
from pygeodesy.internals import printf, _secs2str, _sys
|
|
1670
|
+
from pygeodesy.internals import printf, _secs2str, _versions, _sys
|
|
1670
1671
|
from time import time
|
|
1671
1672
|
|
|
1672
1673
|
_crop = ()
|
pygeodesy/heights.py
CHANGED
|
@@ -91,7 +91,7 @@ from pygeodesy.units import _isDegrees, Float_, Int_
|
|
|
91
91
|
# from math import radians # from .points
|
|
92
92
|
|
|
93
93
|
__all__ = _ALL_LAZY.heights
|
|
94
|
-
__version__ = '24.
|
|
94
|
+
__version__ = '24.11.02'
|
|
95
95
|
|
|
96
96
|
_error_ = 'error'
|
|
97
97
|
_formy = _MODS.into(formy=__name__)
|
|
@@ -1031,7 +1031,7 @@ class HeightIDWkarney(_HeightIDW):
|
|
|
1031
1031
|
<https://WikiPedia.org/wiki/Inverse_distance_weighting>} (IDW) and the
|
|
1032
1032
|
I{angular} distance in C{degrees} from I{Karney}'s U{geographiclib
|
|
1033
1033
|
<https://PyPI.org/project/geographiclib>} method U{Geodesic.Inverse
|
|
1034
|
-
<https://
|
|
1034
|
+
<https://GeographicLib.SourceForge.io/Python/doc/code.html#
|
|
1035
1035
|
geographiclib.geodesic.Geodesic.Inverse>}.
|
|
1036
1036
|
'''
|
|
1037
1037
|
def __init__(self, knots, beta=2, datum=None, **name__wrap):
|