Skip to content

Commit 9faae32

Browse files
committed
los speedup
1 parent 7e9dd2a commit 9faae32

File tree

14 files changed

+342
-292
lines changed

14 files changed

+342
-292
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ full = [
4141
line-length = 100
4242

4343
[tool.pytest.ini_options]
44-
addopts = "-ra -v"
44+
addopts = "-ra"

scripts/benchmark_vincenty.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def bench_vreckon(N: int) -> float:
3131
az = np.random.random(N)
3232

3333
tic = time.monotonic()
34-
a, b = vreckon(*ll0, sr, az)
34+
a, b = vreckon(ll0[0], ll0[1], sr, az)
3535

3636
return time.monotonic() - tic
3737

@@ -41,7 +41,7 @@ def bench_vdist(N: int) -> float:
4141
lon = np.random.random(N)
4242

4343
tic = time.monotonic()
44-
asr, aaz = vdist(*ll0, lat, lon)
44+
asr, aaz = vdist(ll0[0], ll0[1], lat, lon)
4545

4646
return time.monotonic() - tic
4747

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.5.1
3+
version = 2.6.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/aer.py

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ def ecef2aer(
2323
x: ndarray,
2424
y: ndarray,
2525
z: ndarray,
26-
lat0: float,
27-
lon0: float,
28-
h0: float,
26+
lat0: ndarray,
27+
lon0: ndarray,
28+
h0: ndarray,
2929
ell: Ellipsoid = None,
3030
deg: bool = True,
3131
) -> tuple[ndarray, ndarray, ndarray]:
@@ -72,9 +72,9 @@ def geodetic2aer(
7272
lat: ndarray,
7373
lon: ndarray,
7474
h: ndarray,
75-
lat0: float,
76-
lon0: float,
77-
h0: float,
75+
lat0: ndarray,
76+
lon0: ndarray,
77+
h0: ndarray,
7878
ell: Ellipsoid = None,
7979
deg: bool = True,
8080
) -> tuple[ndarray, ndarray, ndarray]:
@@ -117,15 +117,15 @@ def geodetic2aer(
117117

118118

119119
def aer2geodetic(
120-
az: float,
121-
el: float,
122-
srange: float,
123-
lat0: float,
124-
lon0: float,
125-
h0: float,
120+
az: ndarray,
121+
el: ndarray,
122+
srange: ndarray,
123+
lat0: ndarray,
124+
lon0: ndarray,
125+
h0: ndarray,
126126
ell: Ellipsoid = None,
127127
deg: bool = True,
128-
) -> tuple[float | ndarray, float | ndarray, float | ndarray]:
128+
) -> tuple[ndarray, ndarray, ndarray]:
129129
"""
130130
gives geodetic coordinates of a point with az, el, range
131131
from an observer at lat0, lon0, h0
@@ -167,12 +167,12 @@ def aer2geodetic(
167167

168168

169169
def eci2aer(
170-
x: float,
171-
y: float,
172-
z: float,
173-
lat0: float,
174-
lon0: float,
175-
h0: float,
170+
x: ndarray,
171+
y: ndarray,
172+
z: ndarray,
173+
lat0: ndarray,
174+
lon0: ndarray,
175+
h0: ndarray,
176176
t: datetime,
177177
*,
178178
deg: bool = True,
@@ -221,18 +221,18 @@ def eci2aer(
221221

222222

223223
def aer2eci(
224-
az: float,
225-
el: float,
226-
srange: float,
227-
lat0: float,
228-
lon0: float,
229-
h0: float,
224+
az: ndarray,
225+
el: ndarray,
226+
srange: ndarray,
227+
lat0: ndarray,
228+
lon0: ndarray,
229+
h0: ndarray,
230230
t: datetime,
231231
ell=None,
232232
*,
233233
deg: bool = True,
234234
use_astropy: bool = True
235-
) -> tuple[float | ndarray, float | ndarray, float | ndarray]:
235+
) -> tuple[ndarray, ndarray, ndarray]:
236236
"""
237237
gives ECI of a point from an observer at az, el, slant range
238238
@@ -280,15 +280,15 @@ def aer2eci(
280280

281281

282282
def aer2ecef(
283-
az: float,
284-
el: float,
285-
srange: float,
286-
lat0: float,
287-
lon0: float,
288-
alt0: float,
283+
az: ndarray,
284+
el: ndarray,
285+
srange: ndarray,
286+
lat0: ndarray,
287+
lon0: ndarray,
288+
alt0: ndarray,
289289
ell: Ellipsoid = None,
290290
deg: bool = True,
291-
) -> tuple[float, float, float]:
291+
) -> tuple[ndarray, ndarray, ndarray]:
292292
"""
293293
converts target azimuth, elevation, range from observer at lat0,lon0,alt0 to ECEF coordinates.
294294

src/pymap3d/ecef.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@
4949

5050

5151
def geodetic2ecef(
52-
lat: float | ndarray,
53-
lon: float | ndarray,
54-
alt: float | ndarray,
52+
lat: ndarray,
53+
lon: ndarray,
54+
alt: ndarray,
5555
ell: Ellipsoid = None,
5656
deg: bool = True,
57-
) -> tuple[float | ndarray, float | ndarray, float | ndarray]:
57+
) -> tuple[ndarray, ndarray, ndarray]:
5858
"""
5959
point transformation from Geodetic of specified ellipsoid (default WGS-84) to ECEF
6060
@@ -103,12 +103,12 @@ def geodetic2ecef(
103103

104104

105105
def ecef2geodetic(
106-
x: float | ndarray,
107-
y: float | ndarray,
108-
z: float | ndarray,
106+
x: ndarray,
107+
y: ndarray,
108+
z: ndarray,
109109
ell: Ellipsoid = None,
110110
deg: bool = True,
111-
) -> tuple[float | ndarray, float | ndarray, float | ndarray]:
111+
) -> tuple[ndarray, ndarray, ndarray]:
112112
"""
113113
convert ECEF (meters) to geodetic coordinates
114114
@@ -248,9 +248,9 @@ def ecef2enu(
248248
x: ndarray,
249249
y: ndarray,
250250
z: ndarray,
251-
lat0: float,
252-
lon0: float,
253-
h0: float,
251+
lat0: ndarray,
252+
lon0: ndarray,
253+
h0: ndarray,
254254
ell: Ellipsoid = None,
255255
deg: bool = True,
256256
) -> tuple[ndarray, ndarray, ndarray]:
@@ -292,13 +292,13 @@ def ecef2enu(
292292

293293

294294
def enu2uvw(
295-
east: float,
296-
north: float,
297-
up: float,
298-
lat0: float,
299-
lon0: float,
295+
east: ndarray,
296+
north: ndarray,
297+
up: ndarray,
298+
lat0: ndarray,
299+
lon0: ndarray,
300300
deg: bool = True,
301-
) -> tuple[float, float, float]:
301+
) -> tuple[ndarray, ndarray, ndarray]:
302302
"""
303303
Parameters
304304
----------
@@ -332,7 +332,7 @@ def enu2uvw(
332332

333333

334334
def uvw2enu(
335-
u: float, v: float, w: float, lat0: float, lon0: float, deg: bool = True
335+
u: ndarray, v: ndarray, w: ndarray, lat0: ndarray, lon0: ndarray, deg: bool = True
336336
) -> tuple[ndarray, ndarray, ndarray]:
337337
"""
338338
Parameters
@@ -374,7 +374,7 @@ def eci2geodetic(
374374
*,
375375
deg: bool = True,
376376
use_astropy: bool = True
377-
) -> tuple[float | ndarray, float | ndarray, float | ndarray]:
377+
) -> tuple[ndarray, ndarray, ndarray]:
378378
"""
379379
convert Earth Centered Internal ECI to geodetic coordinates
380380
@@ -417,9 +417,9 @@ def eci2geodetic(
417417

418418

419419
def geodetic2eci(
420-
lat: float | ndarray,
421-
lon: float | ndarray,
422-
alt: float | ndarray,
420+
lat: ndarray,
421+
lon: ndarray,
422+
alt: ndarray,
423423
t: datetime,
424424
ell: Ellipsoid = None,
425425
*,
@@ -468,15 +468,15 @@ def geodetic2eci(
468468

469469

470470
def enu2ecef(
471-
e1: float,
472-
n1: float,
473-
u1: float,
474-
lat0: float,
475-
lon0: float,
476-
h0: float,
471+
e1: ndarray,
472+
n1: ndarray,
473+
u1: ndarray,
474+
lat0: ndarray,
475+
lon0: ndarray,
476+
h0: ndarray,
477477
ell: Ellipsoid = None,
478478
deg: bool = True,
479-
) -> tuple[float, float, float]:
479+
) -> tuple[ndarray, ndarray, ndarray]:
480480
"""
481481
ENU to ECEF
482482

src/pymap3d/enu.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ def enu2aer(
7373
return az, elev, slantRange
7474

7575

76-
def aer2enu(az: float, el: float, srange: float, deg: bool = True) -> tuple[float, float, float]:
76+
def aer2enu(
77+
az: ndarray, el: ndarray, srange: float | ndarray, deg: bool = True
78+
) -> tuple[ndarray, ndarray, ndarray]:
7779
"""
7880
Azimuth, Elevation, Slant range to target to East, North, Up
7981
@@ -104,7 +106,7 @@ def aer2enu(az: float, el: float, srange: float, deg: bool = True) -> tuple[floa
104106
try:
105107
if (asarray(srange) < 0).any():
106108
raise ValueError("Slant range [0, Infinity)")
107-
except UnboundLocalError:
109+
except NameError:
108110
if srange < 0:
109111
raise ValueError("Slant range [0, Infinity)")
110112

@@ -114,15 +116,15 @@ def aer2enu(az: float, el: float, srange: float, deg: bool = True) -> tuple[floa
114116

115117

116118
def enu2geodetic(
117-
e: float,
118-
n: float,
119-
u: float,
120-
lat0: float,
121-
lon0: float,
122-
h0: float,
119+
e: ndarray,
120+
n: ndarray,
121+
u: ndarray,
122+
lat0: ndarray,
123+
lon0: ndarray,
124+
h0: ndarray,
123125
ell: Ellipsoid = None,
124126
deg: bool = True,
125-
) -> tuple[float | ndarray, float | ndarray, float | ndarray]:
127+
) -> tuple[ndarray, ndarray, ndarray]:
126128
"""
127129
East, North, Up to target to geodetic coordinates
128130
@@ -165,9 +167,9 @@ def geodetic2enu(
165167
lat: ndarray,
166168
lon: ndarray,
167169
h: ndarray,
168-
lat0: float,
169-
lon0: float,
170-
h0: float,
170+
lat0: ndarray,
171+
lon0: ndarray,
172+
h0: ndarray,
171173
ell: Ellipsoid = None,
172174
deg: bool = True,
173175
) -> tuple[ndarray, ndarray, ndarray]:

0 commit comments

Comments
 (0)