Skip to content

Commit 204dfbf

Browse files
committed
speed import, add pymap3d.{vdist,vreckon}]
Don't automatically import less widespread used modules including: lox los rcurve rsphere this speeds imports for most users
1 parent 9cc82e4 commit 204dfbf

21 files changed

+189
-200
lines changed

Examples/vdist.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

Examples/vdist_stability.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717

1818
def matlab_func(lat1: float, lon1: float, lat2: float, lon2: float) -> typing.Tuple[float, float]:
19-
""" Using Matlab Engine to do same thing as Pymap3d """
19+
"""Using Matlab Engine to do same thing as Pymap3d"""
2020
ell = eng.wgs84Ellipsoid()
2121
return eng.distance(lat1, lon1, lat2, lon2, ell, nargout=2)
2222

Examples/vreckon.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@ Abbreviations:
112112
* [NED: North East Down](https://en.wikipedia.org/wiki/North_east_down)
113113
* [radec: right ascension, declination](https://en.wikipedia.org/wiki/Right_ascension)
114114

115+
### command line
116+
117+
Command line convenience functions provided include:
118+
119+
```sh
120+
python -m pymap3d.vdist
121+
python -m pymap3d.vreckon
122+
```
123+
115124
### array vs scalar
116125

117126
Use of pymap3d on embedded systems or other streaming data applications often deal with scalar position data.

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = pymap3d
3-
version = 2.6.1
3+
version = 2.7.0
44
author = Michael Hirsch, Ph.D.
55
author_email = [email protected]
66
description = pure Python (no prereqs) coordinate conversions, following convention of several popular Matlab routines.

src/pymap3d/__init__.py

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"""
3131

3232
from .aer import ecef2aer, aer2ecef, geodetic2aer, aer2geodetic
33-
from .ellipsoid import Ellipsoid
33+
3434
from .enu import enu2geodetic, geodetic2enu, aer2enu, enu2aer
3535
from .ned import ned2ecef, ned2geodetic, geodetic2ned, ecef2nedv, ned2aer, aer2ned, ecef2ned
3636
from .ecef import (
@@ -45,34 +45,7 @@
4545
uvw2enu,
4646
)
4747
from .sidereal import datetime2sidereal, greenwichsrt
48-
from .latitude import (
49-
geod2geoc,
50-
geoc2geod,
51-
geodetic2geocentric,
52-
geocentric2geodetic,
53-
geodetic2isometric,
54-
isometric2geodetic,
55-
geodetic2conformal,
56-
conformal2geodetic,
57-
geodetic2rectifying,
58-
rectifying2geodetic,
59-
geodetic2authalic,
60-
authalic2geodetic,
61-
geodetic2parametric,
62-
parametric2geodetic,
63-
)
64-
from .rcurve import geocentric_radius, rcurve_parallel, rcurve_meridian, rcurve_transverse
65-
from .rsphere import (
66-
rsphere_eqavol,
67-
rsphere_authalic,
68-
rsphere_rectifying,
69-
rsphere_euler,
70-
rsphere_curve,
71-
rsphere_triaxial,
72-
rsphere_biaxial,
73-
)
74-
from .lox import meridian_arc, meridian_dist, loxodrome_inverse, loxodrome_direct, departure, meanm
75-
from .los import lookAtSpheroid
48+
from .ellipsoid import Ellipsoid
7649
from .timeconv import str2dt
7750

7851
try:

src/pymap3d/enu.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,18 @@
22
from __future__ import annotations
33
import typing
44

5+
from math import tau
6+
57
try:
6-
from numpy import asarray, radians, sin, cos, hypot, arctan2 as atan2, degrees, pi, ndarray
8+
from numpy import asarray, radians, sin, cos, hypot, arctan2 as atan2, degrees, ndarray
79
except ImportError:
8-
from math import radians, sin, cos, hypot, atan2, degrees, pi # type: ignore
10+
from math import radians, sin, cos, hypot, atan2, degrees # type: ignore
911

1012
ndarray = typing.Any # type: ignore
1113

1214
from .ecef import geodetic2ecef, ecef2geodetic, enu2ecef, uvw2enu
1315
from .ellipsoid import Ellipsoid
1416

15-
# py < 3.6 compatible
16-
tau = 2 * pi
17-
1817
__all__ = ["enu2aer", "aer2enu", "enu2geodetic", "geodetic2enu"]
1918

2019

src/pymap3d/latitude.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
from __future__ import annotations
44
import typing
5+
56
from .ellipsoid import Ellipsoid
67
from .utils import sanitize
7-
from .rcurve import rcurve_transverse
8+
from . import rcurve
89

910
try:
1011
from numpy import radians, degrees, tan, sin, exp, pi, sqrt, inf, ndarray
@@ -115,7 +116,7 @@ def geodetic2geocentric(
115116
Office, Washington, DC, 1987, pp. 13-18.
116117
"""
117118
geodetic_lat, ell = sanitize(geodetic_lat, ell, deg)
118-
r = rcurve_transverse(geodetic_lat, ell, deg=False)
119+
r = rcurve.transverse(geodetic_lat, ell, deg=False)
119120
geocentric_lat = atan((1 - ell.eccentricity ** 2 * (r / (r + alt_m))) * tan(geodetic_lat))
120121

121122
return degrees(geocentric_lat) if deg else geocentric_lat
@@ -156,7 +157,7 @@ def geocentric2geodetic(
156157
Office, Washington, DC, 1987, pp. 13-18.
157158
"""
158159
geocentric_lat, ell = sanitize(geocentric_lat, ell, deg)
159-
r = rcurve_transverse(geocentric_lat, ell, deg=False)
160+
r = rcurve.transverse(geocentric_lat, ell, deg=False)
160161
geodetic_lat = atan(tan(geocentric_lat) / (1 - ell.eccentricity ** 2 * (r / (r + alt_m))))
161162

162163
return degrees(geodetic_lat) if deg else geodetic_lat

src/pymap3d/lox.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
import typing
1414
from .ellipsoid import Ellipsoid
15-
from .rcurve import rcurve_parallel
16-
from .rsphere import rsphere_rectifying
15+
from . import rcurve
16+
from . import rsphere
1717
from .latitude import (
1818
geodetic2rectifying,
1919
rectifying2geodetic,
@@ -79,7 +79,7 @@ def meridian_arc(lat1, lat2: ndarray, ell: Ellipsoid = None, deg: bool = True) -
7979
rlat1 = geodetic2rectifying(lat1, ell, deg=False)
8080
rlat2 = geodetic2rectifying(lat2, ell, deg=False)
8181

82-
return rsphere_rectifying(ell) * abs(rlat2 - rlat1)
82+
return rsphere.rectifying(ell) * abs(rlat2 - rlat1)
8383

8484

8585
def loxodrome_inverse(
@@ -220,7 +220,7 @@ def loxodrome_direct(
220220

221221
# compute the new points
222222
cosaz = cos(a12)
223-
lat2 = reclat + (rng / rsphere_rectifying(ell)) * cosaz # compute rectifying latitude
223+
lat2 = reclat + (rng / rsphere.rectifying(ell)) * cosaz # compute rectifying latitude
224224
lat2 = rectifying2geodetic(lat2, ell, deg=False) # transform to geodetic latitude
225225

226226
newiso = geodetic2isometric(lat2, ell, deg=False)
@@ -265,7 +265,7 @@ def departure(
265265
if deg:
266266
lon1, lon2, lat = radians(lon1), radians(lon2), radians(lat)
267267

268-
return rcurve_parallel(lat, ell, deg=False) * ((lon2 - lon1) % pi)
268+
return rcurve.parallel(lat, ell, deg=False) * ((lon2 - lon1) % pi)
269269

270270

271271
def meanm(

src/pymap3d/rcurve.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from .ellipsoid import Ellipsoid
1414
from .utils import sanitize
1515

16-
__all__ = ["rcurve_parallel", "rcurve_meridian", "rcurve_transverse", "geocentric_radius"]
16+
__all__ = ["parallel", "meridian", "transverse", "geocentric_radius"]
1717

1818

1919
def geocentric_radius(geodetic_lat: float, ell: Ellipsoid = None, deg: bool = True) -> float:
@@ -36,7 +36,7 @@ def geocentric_radius(geodetic_lat: float, ell: Ellipsoid = None, deg: bool = Tr
3636
)
3737

3838

39-
def rcurve_parallel(lat: ndarray, ell: Ellipsoid = None, deg: bool = True) -> float:
39+
def parallel(lat: ndarray, ell: Ellipsoid = None, deg: bool = True) -> float:
4040
"""
4141
computes the radius of the small circle encompassing the globe at the specified latitude
4242
@@ -58,10 +58,10 @@ def rcurve_parallel(lat: ndarray, ell: Ellipsoid = None, deg: bool = True) -> fl
5858
if deg:
5959
lat = radians(lat)
6060

61-
return cos(lat) * rcurve_transverse(lat, ell, deg=False)
61+
return cos(lat) * transverse(lat, ell, deg=False)
6262

6363

64-
def rcurve_meridian(lat: float, ell: Ellipsoid = None, deg: bool = True) -> float:
64+
def meridian(lat: float, ell: Ellipsoid = None, deg: bool = True) -> float:
6565
"""computes the meridional radius of curvature for the ellipsoid
6666
6767
like Matlab rcurve('meridian', ...)
@@ -91,7 +91,7 @@ def rcurve_meridian(lat: float, ell: Ellipsoid = None, deg: bool = True) -> floa
9191
return f1 / sqrt(f2 ** 3)
9292

9393

94-
def rcurve_transverse(lat: float | ndarray, ell: Ellipsoid = None, deg: bool = True) -> float:
94+
def transverse(lat: float | ndarray, ell: Ellipsoid = None, deg: bool = True) -> float:
9595
"""computes the radius of the curve formed by a plane
9696
intersecting the ellipsoid at the latitude which is
9797
normal to the surface of the ellipsoid

0 commit comments

Comments
 (0)