Skip to content

Commit

Permalink
restore optional numpy
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed May 10, 2020
1 parent a8a90ae commit b5652b8
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/pymap3d/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* Fortran: [Maptran3D](https://github.com/geospace-code/maptran3d)
"""

from .aer import ecef2aer, aer2ecef, geodetic2aer, aer2geodetic, eci2aer, aer2eci
from .aer import ecef2aer, aer2ecef, geodetic2aer, aer2geodetic
from .ellipsoid import Ellipsoid
from .enu import enu2geodetic, geodetic2enu, aer2enu, enu2aer
from .ned import ned2ecef, ned2geodetic, geodetic2ned, ecef2nedv, ned2aer, aer2ned, ecef2ned
Expand Down Expand Up @@ -66,9 +66,10 @@
from .lox import meridian_arc, meridian_dist, loxodrome_inverse, loxodrome_direct, departure, meanm
from .los import lookAtSpheroid
from .timeconv import str2dt
from .eci import eci2ecef, ecef2eci

try:
from .azelradec import radec2azel, azel2radec
from .eci import eci2ecef, ecef2eci
from .aer import eci2aer, aer2eci
except ImportError:
from .vallado import radec2azel, azel2radec
11 changes: 9 additions & 2 deletions src/pymap3d/aer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
from .enu import geodetic2enu, aer2enu, enu2aer
from .ellipsoid import Ellipsoid

from .eci import eci2ecef, ecef2eci

try:
from .eci import eci2ecef, ecef2eci
except ImportError:
eci2ecef = ecef2eci = None

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

Expand Down Expand Up @@ -208,6 +210,8 @@ def eci2aer(
srange : "ndarray"
slant range [meters]
"""
if eci2ecef is None:
raise ImportError("pip install numpy")

xecef, yecef, zecef = eci2ecef(x, y, z, t, use_astropy=use_astropy)

Expand Down Expand Up @@ -265,6 +269,9 @@ def aer2eci(
z : "ndarray"
ECEF z coordinate (meters)
"""
if ecef2eci is None:
raise ImportError("pip install numpy")

x, y, z = aer2ecef(az, el, srange, lat0, lon0, h0, ell, deg=deg)

return ecef2eci(x, y, z, t, use_astropy=use_astropy)
Expand Down
11 changes: 10 additions & 1 deletion src/pymap3d/ecef.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@

from .ellipsoid import Ellipsoid
from .utils import sanitize
from .eci import eci2ecef, ecef2eci

try:
from .eci import eci2ecef, ecef2eci
except ImportError:
eci2ecef = ecef2eci = None

# py < 3.6 compatible
tau = 2 * pi
Expand Down Expand Up @@ -366,6 +370,8 @@ def eci2geodetic(
eci2geodetic() a.k.a. eci2lla()
"""
if eci2ecef is None:
raise ImportError("pip install numpy")

xecef, yecef, zecef = eci2ecef(x, y, z, t, use_astropy=use_astropy)

Expand Down Expand Up @@ -415,6 +421,9 @@ def geodetic2eci(
geodetic2eci() a.k.a lla2eci()
"""
if ecef2eci is None:
raise ImportError("pip install numpy")

x, y, z = geodetic2ecef(lat, lon, alt, ell, deg)

return ecef2eci(x, y, z, t, use_astropy=use_astropy)
Expand Down
6 changes: 6 additions & 0 deletions tests/test_eci.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

@pytest.mark.parametrize("use_astropy", [True, False])
def test_eci2ecef(use_astropy):
pytest.importorskip("numpy")
if use_astropy:
pytest.importorskip("astropy")
# this example from Matlab eci2ecef docs
Expand All @@ -19,6 +20,7 @@ def test_eci2ecef(use_astropy):

@pytest.mark.parametrize("use_astropy", [True, False])
def test_ecef2eci(use_astropy):
pytest.importorskip("numpy")
if use_astropy:
pytest.importorskip("astropy")
# this example from Matlab ecef2eci docs
Expand All @@ -32,6 +34,7 @@ def test_ecef2eci(use_astropy):

@pytest.mark.parametrize("use_astropy", [True, False])
def test_eci2geodetic(use_astropy):
pytest.importorskip("numpy")
if use_astropy:
pytest.importorskip("astropy")

Expand All @@ -45,6 +48,7 @@ def test_eci2geodetic(use_astropy):

@pytest.mark.parametrize("use_astropy", [True, False])
def test_geodetic2eci(use_astropy):
pytest.importorskip("numpy")
if use_astropy:
pytest.importorskip("astropy")

Expand All @@ -59,6 +63,7 @@ def test_geodetic2eci(use_astropy):
@pytest.mark.parametrize("use_astropy", [True, False])
def test_eci2aer(use_astropy):
# test coords from Matlab eci2aer
pytest.importorskip("numpy")
if use_astropy:
pytest.importorskip("astropy")
t = datetime(1969, 7, 20, 21, 17, 40)
Expand All @@ -74,6 +79,7 @@ def test_eci2aer(use_astropy):
@pytest.mark.parametrize("use_astropy", [True, False])
def test_aer2eci(use_astropy):
# test coords from Matlab aer2eci
pytest.importorskip("numpy")
if use_astropy:
pytest.importorskip("astropy")

Expand Down

0 comments on commit b5652b8

Please sign in to comment.