Skip to content

Commit 7e24a35

Browse files
committed
allow ell=None default
This is like Pymap3d 2.8.0 and is better UX
1 parent 1cc1e33 commit 7e24a35

File tree

16 files changed

+163
-94
lines changed

16 files changed

+163
-94
lines changed

src/pymap3d/aer.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ def ecef2eci(x, y, z, time: datetime, force_non_astropy: bool = False) -> tuple:
2121

2222
__all__ = ["aer2ecef", "ecef2aer", "geodetic2aer", "aer2geodetic", "eci2aer", "aer2eci"]
2323

24-
ELL = Ellipsoid.from_name("wgs84")
25-
2624

2725
def ecef2aer(
2826
x,
@@ -31,7 +29,7 @@ def ecef2aer(
3129
lat0,
3230
lon0,
3331
h0,
34-
ell: Ellipsoid = ELL,
32+
ell: Ellipsoid | None = None,
3533
deg: bool = True,
3634
) -> tuple:
3735
"""
@@ -81,7 +79,7 @@ def geodetic2aer(
8179
lat0,
8280
lon0,
8381
h0,
84-
ell: Ellipsoid = ELL,
82+
ell: Ellipsoid | None = None,
8583
deg: bool = True,
8684
) -> tuple:
8785
"""
@@ -129,7 +127,7 @@ def aer2geodetic(
129127
lat0,
130128
lon0,
131129
h0,
132-
ell: Ellipsoid = ELL,
130+
ell: Ellipsoid | None = None,
133131
deg: bool = True,
134132
) -> tuple:
135133
"""
@@ -219,7 +217,7 @@ def aer2eci(
219217
lon0,
220218
h0,
221219
t: datetime,
222-
ell: Ellipsoid = ELL,
220+
ell: Ellipsoid | None = None,
223221
*,
224222
deg: bool = True,
225223
) -> tuple:
@@ -272,7 +270,7 @@ def aer2ecef(
272270
lat0,
273271
lon0,
274272
alt0,
275-
ell: Ellipsoid = ELL,
273+
ell: Ellipsoid | None = None,
276274
deg: bool = True,
277275
) -> tuple:
278276
"""

src/pymap3d/ecef.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,12 @@
2828
"enu2ecef",
2929
]
3030

31-
ELL = Ellipsoid.from_name("wgs84")
32-
3331

3432
def geodetic2ecef(
3533
lat,
3634
lon,
3735
alt,
38-
ell: Ellipsoid = ELL,
36+
ell: Ellipsoid | None = None,
3937
deg: bool = True,
4038
) -> tuple:
4139
"""
@@ -73,6 +71,9 @@ def geodetic2ecef(
7371
lat = radians(lat)
7472
lon = radians(lon)
7573

74+
if ell is None:
75+
ell = Ellipsoid.from_name("wgs84")
76+
7677
# radius of curvature of the prime vertical section
7778
N = ell.semimajor_axis**2 / hypot(ell.semimajor_axis * cos(lat), ell.semiminor_axis * sin(lat))
7879
# Compute cartesian (geocentric) coordinates given (curvilinear) geodetic coordinates.
@@ -87,7 +88,7 @@ def ecef2geodetic(
8788
x,
8889
y,
8990
z,
90-
ell: Ellipsoid = ELL,
91+
ell: Ellipsoid | None = None,
9192
deg: bool = True,
9293
) -> tuple:
9394
"""
@@ -127,6 +128,9 @@ def ecef2geodetic(
127128
except NameError:
128129
pass
129130

131+
if ell is None:
132+
ell = Ellipsoid.from_name("wgs84")
133+
130134
r = sqrt(x**2 + y**2 + z**2)
131135

132136
E = sqrt(ell.semimajor_axis**2 - ell.semiminor_axis**2)
@@ -272,7 +276,7 @@ def ecef2enu(
272276
lat0,
273277
lon0,
274278
h0,
275-
ell: Ellipsoid = ELL,
279+
ell: Ellipsoid | None = None,
276280
deg: bool = True,
277281
) -> tuple:
278282
"""
@@ -398,7 +402,7 @@ def uvw2enu(u, v, w, lat0, lon0, deg: bool = True) -> tuple:
398402
return East, North, Up
399403

400404

401-
def eci2geodetic(x, y, z, t: datetime, ell: Ellipsoid = ELL, *, deg: bool = True) -> tuple:
405+
def eci2geodetic(x, y, z, t: datetime, ell: Ellipsoid | None = None, *, deg: bool = True) -> tuple:
402406
"""
403407
convert Earth Centered Internal ECI to geodetic coordinates
404408
@@ -436,7 +440,9 @@ def eci2geodetic(x, y, z, t: datetime, ell: Ellipsoid = ELL, *, deg: bool = True
436440
return ecef2geodetic(xecef, yecef, zecef, ell, deg)
437441

438442

439-
def geodetic2eci(lat, lon, alt, t: datetime, ell: Ellipsoid = ELL, *, deg: bool = True) -> tuple:
443+
def geodetic2eci(
444+
lat, lon, alt, t: datetime, ell: Ellipsoid | None = None, *, deg: bool = True
445+
) -> tuple:
440446
"""
441447
convert geodetic coordinates to Earth Centered Internal ECI
442448
@@ -481,7 +487,7 @@ def enu2ecef(
481487
lat0,
482488
lon0,
483489
h0,
484-
ell: Ellipsoid = ELL,
490+
ell: Ellipsoid | None = None,
485491
deg: bool = True,
486492
) -> tuple:
487493
"""

src/pymap3d/enu.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
__all__ = ["enu2aer", "aer2enu", "enu2geodetic", "geodetic2enu", "enu2ecefv"]
1717

18-
ELL = Ellipsoid.from_name("wgs84")
19-
2018

2119
def enu2aer(e, n, u, deg: bool = True) -> tuple:
2220
"""
@@ -118,7 +116,7 @@ def enu2geodetic(
118116
lat0,
119117
lon0,
120118
h0,
121-
ell: Ellipsoid = ELL,
119+
ell: Ellipsoid | None = None,
122120
deg: bool = True,
123121
) -> tuple:
124122
"""
@@ -166,7 +164,7 @@ def geodetic2enu(
166164
lat0,
167165
lon0,
168166
h0,
169-
ell: Ellipsoid = ELL,
167+
ell: Ellipsoid | None = None,
170168
deg: bool = True,
171169
) -> tuple:
172170
"""

0 commit comments

Comments
 (0)