Skip to content

Commit 9cc82e4

Browse files
committed
Merge branch 'dschurman-dschurman/fix/ecef-alt-valueerror'
2 parents 853b0be + 1e5b3d8 commit 9cc82e4

File tree

4 files changed

+35
-3
lines changed

4 files changed

+35
-3
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "pymap3d"
3-
version = "2.5.1"
3+
version = "2.6.1"
44
description = "pure Python (no prereqs) coordinate conversions, following convention of several popular Matlab routines."
55
readme = "README.md"
66
requires-python = ">=3.7"

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.0
3+
version = 2.6.1
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/ecef.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def ecef2geodetic(
187187
try:
188188
if inside.any(): # type: ignore
189189
# avoid all false assignment bug
190-
alt[inside] = -alt
190+
alt[inside] = -alt[inside]
191191
except (TypeError, AttributeError):
192192
if inside:
193193
alt = -alt

src/pymap3d/tests/test_geodetic.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,38 @@ def test_3d_ecef2geodetic():
5555
assert [lat, lon, alt] == approx(lla0, rel=1e-4)
5656

5757

58+
def test_array_ecef2geodetic():
59+
"""
60+
tests ecef2geodetic can handle numpy array data in addition to singular floats
61+
"""
62+
np = pytest.importorskip("numpy")
63+
# test values with no points inside ellipsoid
64+
lla0_array = (
65+
np.array([lla0[0], lla0[0]]),
66+
np.array([lla0[1], lla0[1]]),
67+
np.array([lla0[2], lla0[2]]),
68+
)
69+
xyz = pm.geodetic2ecef(*lla0_array)
70+
lats, lons, alts = pm.ecef2geodetic(*xyz)
71+
72+
assert lats == approx(lla0_array[0])
73+
assert lons == approx(lla0_array[1])
74+
assert alts == approx(lla0_array[2])
75+
76+
# test values with some (but not all) points inside ellipsoid
77+
lla0_array_inside = (
78+
np.array([lla0[0], lla0[0]]),
79+
np.array([lla0[1], lla0[1]]),
80+
np.array([lla0[2], -lla0[2]]),
81+
)
82+
xyz = pm.geodetic2ecef(*lla0_array_inside)
83+
lats, lons, alts = pm.ecef2geodetic(*xyz)
84+
85+
assert lats == approx(lla0_array_inside[0])
86+
assert lons == approx(lla0_array_inside[1])
87+
assert alts == approx(lla0_array_inside[2])
88+
89+
5890
def test_xarray():
5991
xarray = pytest.importorskip("xarray")
6092
xr_lla = xarray.DataArray(list(lla0))

0 commit comments

Comments
 (0)