[Git][debian-gis-team/pymap3d][master] 5 commits: New upstream version 2.4.1

Antonio Valentino gitlab at salsa.debian.org
Mon May 11 08:16:18 BST 2020



Antonio Valentino pushed to branch master at Debian GIS Project / pymap3d


Commits:
fca03275 by Antonio Valentino at 2020-05-11T06:45:33+00:00
New upstream version 2.4.1
- - - - -
512363bc by Antonio Valentino at 2020-05-11T06:45:34+00:00
Update upstream source from tag 'upstream/2.4.1'

Update to upstream version '2.4.1'
with Debian dir 558c158d7dca167c98476ab75992dd0a461a38bd
- - - - -
aaee23aa by Antonio Valentino at 2020-05-11T06:46:10+00:00
New upstream release

- - - - -
93c8eeb5 by Antonio Valentino at 2020-05-11T06:54:57+00:00
Set compat to 13

- - - - -
e9bb5db6 by Antonio Valentino at 2020-05-11T06:55:38+00:00
Set distribution to unstable

- - - - -


14 changed files:

- debian/changelog
- debian/control
- setup.cfg
- src/pymap3d/__init__.py
- src/pymap3d/aer.py
- src/pymap3d/azelradec.py
- src/pymap3d/ecef.py
- src/pymap3d/eci.py
- src/pymap3d/sidereal.py
- src/pymap3d/vallado.py
- tests/test_eci.py
- tests/test_look_spheroid.py
- tests/test_astropy.py → tests/test_sidereal.py
- tests/test_sky.py


Changes:

=====================================
debian/changelog
=====================================
@@ -1,3 +1,10 @@
+pymap3d (2.4.1-1) unstable; urgency=medium
+
+  * New upstream release.
+  * Set compat to 13.
+
+ -- Antonio Valentino <antonio.valentino at tiscali.it>  Mon, 11 May 2020 06:55:07 +0000
+
 pymap3d (2.4.0-1) unstable; urgency=medium
 
   * New upstream release.


=====================================
debian/control
=====================================
@@ -5,7 +5,7 @@ Section: python
 Testsuite: autopkgtest-pkg-python
 Priority: optional
 Rules-Requires-Root: no
-Build-Depends: debhelper-compat (= 12),
+Build-Depends: debhelper-compat (= 13),
                dh-python,
                python3-all,
                python3-astropy,


=====================================
setup.cfg
=====================================
@@ -1,6 +1,6 @@
 [metadata]
 name = pymap3d
-version = 2.4.0
+version = 2.4.1
 author = Michael Hirsch, Ph.D.
 author_email = scivision at users.noreply.github.com
 description = pure Python (no prereqs) coordinate conversions, following convention of several popular Matlab routines.


=====================================
src/pymap3d/__init__.py
=====================================
@@ -31,12 +31,12 @@ Companion packages exist for:
 * 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
 from .ecef import geodetic2ecef, ecef2geodetic, eci2geodetic, geodetic2eci, ecef2enuv, enu2ecef, ecef2enu, enu2uvw, uvw2enu
-from .sidereal import datetime2sidereal
+from .sidereal import datetime2sidereal, greenwichsrt
 from .latitude import (
     geod2geoc,
     geoc2geod,
@@ -70,5 +70,6 @@ from .timeconv import str2dt
 try:
     from .azelradec import radec2azel, azel2radec
     from .eci import eci2ecef, ecef2eci
+    from .aer import eci2aer, aer2eci
 except ImportError:
     from .vallado import radec2azel, azel2radec


=====================================
src/pymap3d/aer.py
=====================================
@@ -165,7 +165,16 @@ def aer2geodetic(
 
 
 def eci2aer(
-    x: "ndarray", y: "ndarray", z: "ndarray", lat0: "ndarray", lon0: "ndarray", h0: "ndarray", t: datetime
+    x: "ndarray",
+    y: "ndarray",
+    z: "ndarray",
+    lat0: "ndarray",
+    lon0: "ndarray",
+    h0: "ndarray",
+    t: datetime,
+    *,
+    deg: bool = True,
+    use_astropy: bool = True
 ) -> typing.Tuple["ndarray", "ndarray", "ndarray"]:
     """
     takes Earth Centered Inertial x,y,z ECI coordinates of point and gives az, el, slant range from Observer
@@ -187,6 +196,10 @@ def eci2aer(
          observer altitude above geodetic ellipsoid (meters)
     t : datetime.datetime
         Observation time
+    deg : bool, optional
+        true: degrees, false: radians
+    use_astropy: bool, optional
+        use Astropy (recommended)
 
     Returns
     -------
@@ -198,11 +211,11 @@ def eci2aer(
          slant range [meters]
     """
     if eci2ecef is None:
-        raise ImportError("pip install astropy")
+        raise ImportError("pip install numpy")
 
-    xecef, yecef, zecef = eci2ecef(x, y, z, t)
+    xecef, yecef, zecef = eci2ecef(x, y, z, t, use_astropy=use_astropy)
 
-    return ecef2aer(xecef, yecef, zecef, lat0, lon0, h0)
+    return ecef2aer(xecef, yecef, zecef, lat0, lon0, h0, deg=deg)
 
 
 def aer2eci(
@@ -214,7 +227,9 @@ def aer2eci(
     h0: "ndarray",
     t: datetime,
     ell=None,
+    *,
     deg: bool = True,
+    use_astropy: bool = True
 ) -> typing.Tuple["ndarray", "ndarray", "ndarray"]:
     """
     gives ECI of a point from an observer at az, el, slant range
@@ -239,6 +254,8 @@ def aer2eci(
           reference ellipsoid
     deg : bool, optional
           degrees input/output  (False: radians in/out)
+    use_astropy : bool, optional
+        use AstroPy (recommended)
 
     Returns
     -------
@@ -255,9 +272,9 @@ def aer2eci(
     if ecef2eci is None:
         raise ImportError("pip install numpy")
 
-    x, y, z = aer2ecef(az, el, srange, lat0, lon0, h0, ell, deg)
+    x, y, z = aer2ecef(az, el, srange, lat0, lon0, h0, ell, deg=deg)
 
-    return ecef2eci(x, y, z, t)
+    return ecef2eci(x, y, z, t, use_astropy=use_astropy)
 
 
 def aer2ecef(


=====================================
src/pymap3d/azelradec.py
=====================================
@@ -20,7 +20,7 @@ if typing.TYPE_CHECKING:
 
 
 def azel2radec(
-    az_deg: "ndarray", el_deg: "ndarray", lat_deg: "ndarray", lon_deg: "ndarray", time: datetime, usevallado: bool = False
+    az_deg: "ndarray", el_deg: "ndarray", lat_deg: "ndarray", lon_deg: "ndarray", time: datetime, *, use_astropy: bool = True
 ) -> typing.Tuple["ndarray", "ndarray"]:
     """
     viewing angle (az, el) to sky coordinates (ra, dec)
@@ -37,8 +37,8 @@ def azel2radec(
               observer longitude [-180, 180] (degrees)
     time : datetime.datetime or str
            time of observation
-    usevallado : bool, optional
-                 default use astropy. If true, use Vallado algorithm
+    use_astropy : bool, optional
+                 default use astropy.
 
     Returns
     -------
@@ -48,20 +48,21 @@ def azel2radec(
          ecliptic declination (degrees)
     """
 
-    if usevallado or Time is None:  # non-AstroPy method, less accurate
-        return vazel2radec(az_deg, el_deg, lat_deg, lon_deg, time)
+    if use_astropy and Time is not None:
 
-    obs = EarthLocation(lat=lat_deg * u.deg, lon=lon_deg * u.deg)
+        obs = EarthLocation(lat=lat_deg * u.deg, lon=lon_deg * u.deg)
 
-    direc = AltAz(location=obs, obstime=Time(str2dt(time)), az=az_deg * u.deg, alt=el_deg * u.deg)
+        direc = AltAz(location=obs, obstime=Time(str2dt(time)), az=az_deg * u.deg, alt=el_deg * u.deg)
 
-    sky = SkyCoord(direc.transform_to(ICRS()))
+        sky = SkyCoord(direc.transform_to(ICRS()))
 
-    return sky.ra.deg, sky.dec.deg
+        return sky.ra.deg, sky.dec.deg
+
+    return vazel2radec(az_deg, el_deg, lat_deg, lon_deg, time)
 
 
 def radec2azel(
-    ra_deg: "ndarray", dec_deg: "ndarray", lat_deg: "ndarray", lon_deg: "ndarray", time: datetime, usevallado: bool = False
+    ra_deg: "ndarray", dec_deg: "ndarray", lat_deg: "ndarray", lon_deg: "ndarray", time: datetime, *, use_astropy: bool = False
 ) -> typing.Tuple["ndarray", "ndarray"]:
     """
     sky coordinates (ra, dec) to viewing angle (az, el)
@@ -78,8 +79,8 @@ def radec2azel(
               observer longitude [-180, 180] (degrees)
     time : datetime.datetime or str
            time of observation
-    usevallado : bool, optional
-                 default use astropy. If true, use Vallado algorithm
+    use_astropy : bool, optional
+                 default use astropy.
 
     Returns
     -------
@@ -89,13 +90,11 @@ def radec2azel(
              elevation [degrees above horizon (neglecting aberration)]
     """
 
-    if usevallado or Time is None:
-        return vradec2azel(ra_deg, dec_deg, lat_deg, lon_deg, time)
-
-    obs = EarthLocation(lat=lat_deg * u.deg, lon=lon_deg * u.deg)
-
-    points = SkyCoord(Angle(ra_deg, unit=u.deg), Angle(dec_deg, unit=u.deg), equinox="J2000.0")
+    if use_astropy and Time is not None:
+        obs = EarthLocation(lat=lat_deg * u.deg, lon=lon_deg * u.deg)
+        points = SkyCoord(Angle(ra_deg, unit=u.deg), Angle(dec_deg, unit=u.deg), equinox="J2000.0")
+        altaz = points.transform_to(AltAz(location=obs, obstime=Time(str2dt(time))))
 
-    altaz = points.transform_to(AltAz(location=obs, obstime=Time(str2dt(time))))
+        return altaz.az.degree, altaz.alt.degree
 
-    return altaz.az.degree, altaz.alt.degree
+    return vradec2azel(ra_deg, dec_deg, lat_deg, lon_deg, time)


=====================================
src/pymap3d/ecef.py
=====================================
@@ -1,17 +1,21 @@
 """ Transforms involving ECEF: earth-centered, earth-fixed frame """
 try:
     from numpy import radians, sin, cos, tan, arctan as atan, hypot, degrees, arctan2 as atan2, sqrt, pi, vectorize
-    from .eci import eci2ecef, ecef2eci
 except ImportError:
     from math import radians, sin, cos, tan, atan, hypot, degrees, atan2, sqrt, pi
 
-    vectorize = eci2ecef = None
+    vectorize = None
 import typing
 from datetime import datetime
 
 from .ellipsoid import Ellipsoid
 from .utils import sanitize
 
+try:
+    from .eci import eci2ecef, ecef2eci
+except ImportError:
+    eci2ecef = ecef2eci = None
+
 # py < 3.6 compatible
 tau = 2 * pi
 
@@ -331,7 +335,7 @@ def uvw2enu(
 
 
 def eci2geodetic(
-    x: "ndarray", y: "ndarray", z: "ndarray", t: datetime, ell: Ellipsoid = None, deg: bool = True
+    x: "ndarray", y: "ndarray", z: "ndarray", t: datetime, ell: Ellipsoid = None, *, deg: bool = True, use_astropy: bool = True
 ) -> typing.Tuple["ndarray", "ndarray", "ndarray"]:
     """
     convert Earth Centered Internal ECI to geodetic coordinates
@@ -348,10 +352,12 @@ def eci2geodetic(
         ECI z-location [meters]
     t : datetime.datetime, "ndarray"
         UTC time
-    ell : Ellipsoid (optional)
+    ell : Ellipsoid, optional
         planet ellipsoid model
-    deg : bool (optional)
+    deg : bool, optional
         if True, degrees. if False, radians
+    use_astropy : bool, optional
+        use AstroPy (recommended)
 
     Results
     -------
@@ -365,15 +371,22 @@ def eci2geodetic(
     eci2geodetic() a.k.a. eci2lla()
     """
     if eci2ecef is None:
-        raise ImportError("pip install astropy")
+        raise ImportError("pip install numpy")
 
-    xecef, yecef, zecef = eci2ecef(x, y, z, t)
+    xecef, yecef, zecef = eci2ecef(x, y, z, t, use_astropy=use_astropy)
 
     return ecef2geodetic(xecef, yecef, zecef, ell, deg)
 
 
 def geodetic2eci(
-    lat: "ndarray", lon: "ndarray", alt: "ndarray", t: datetime, ell: Ellipsoid = None, deg: bool = True
+    lat: "ndarray",
+    lon: "ndarray",
+    alt: "ndarray",
+    t: datetime,
+    ell: Ellipsoid = None,
+    *,
+    deg: bool = True,
+    use_astropy: bool = True
 ) -> typing.Tuple["ndarray", "ndarray", "ndarray"]:
     """
     convert geodetic coordinates to Earth Centered Internal ECI
@@ -390,10 +403,12 @@ def geodetic2eci(
         altitude above ellipsoid  (meters)
     t : datetime.datetime, "ndarray"
         UTC time
-    ell : Ellipsoid (optional)
+    ell : Ellipsoid, optional
         planet ellipsoid model
-    deg : bool (optional)
+    deg : bool, optional
         if True, degrees. if False, radians
+    use_astropy: bool, optional
+        use AstroPy (recommended)
 
     Results
     -------
@@ -407,11 +422,11 @@ def geodetic2eci(
     geodetic2eci() a.k.a lla2eci()
     """
     if ecef2eci is None:
-        raise ImportError("pip install astropy")
+        raise ImportError("pip install numpy")
 
     x, y, z = geodetic2ecef(lat, lon, alt, ell, deg)
 
-    return ecef2eci(x, y, z, t)
+    return ecef2eci(x, y, z, t, use_astropy=use_astropy)
 
 
 def enu2ecef(


=====================================
src/pymap3d/eci.py
=====================================
@@ -2,6 +2,7 @@
 
 from datetime import datetime
 import typing
+from numpy import array, ndarray, sin, cos, column_stack, empty, atleast_1d
 
 try:
     from astropy.coordinates import GCRS, ITRS, EarthLocation, CartesianRepresentation
@@ -10,13 +11,14 @@ try:
 except ImportError:
     Time = None
 
-__all__ = ["eci2ecef", "ecef2eci"]
+from .sidereal import greenwichsrt, juliandate
 
-if typing.TYPE_CHECKING:
-    from numpy import ndarray
+__all__ = ["eci2ecef", "ecef2eci"]
 
 
-def eci2ecef(x: "ndarray", y: "ndarray", z: "ndarray", time: datetime) -> typing.Tuple["ndarray", "ndarray", "ndarray"]:
+def eci2ecef(
+    x: "ndarray", y: "ndarray", z: "ndarray", time: datetime, *, use_astropy: bool = True
+) -> typing.Tuple["ndarray", "ndarray", "ndarray"]:
     """
     Observer => Point  ECI  =>  ECEF
 
@@ -32,6 +34,8 @@ def eci2ecef(x: "ndarray", y: "ndarray", z: "ndarray", time: datetime) -> typing
         ECI z-location [meters]
     time : datetime.datetime
         time of obsevation (UTC)
+    use_astropy: bool, optional
+        use AstroPy (much more accurate)
 
     Results
     -------
@@ -43,16 +47,36 @@ def eci2ecef(x: "ndarray", y: "ndarray", z: "ndarray", time: datetime) -> typing
         z ECEF coordinate
     """
 
-    if Time is None:
-        raise ImportError("pip install astropy")
+    if use_astropy and Time is not None:
+        gcrs = GCRS(CartesianRepresentation(x * u.m, y * u.m, z * u.m), obstime=time)
+        itrs = gcrs.transform_to(ITRS(obstime=time))
+
+        x_ecef = itrs.x.value
+        y_ecef = itrs.y.value
+        z_ecef = itrs.z.value
+    else:
+        x = atleast_1d(x)
+        y = atleast_1d(y)
+        z = atleast_1d(z)
+        gst = atleast_1d(greenwichsrt(juliandate(time)))
+        assert x.shape == y.shape == z.shape
+        assert x.size == gst.size
 
-    gcrs = GCRS(CartesianRepresentation(x * u.m, y * u.m, z * u.m), obstime=time)
-    itrs = gcrs.transform_to(ITRS(obstime=time))
+        eci = column_stack((x.ravel(), y.ravel(), z.ravel()))
+        ecef = empty((x.size, 3))
+        for i in range(eci.shape[0]):
+            ecef[i, :] = R3(gst[i]) @ eci[i, :].T
 
-    return itrs.x.value, itrs.y.value, itrs.z.value
+        x_ecef = ecef[:, 0].reshape(x.shape)
+        y_ecef = ecef[:, 1].reshape(y.shape)
+        z_ecef = ecef[:, 2].reshape(z.shape)
 
+    return x_ecef, y_ecef, z_ecef
 
-def ecef2eci(x: "ndarray", y: "ndarray", z: "ndarray", time: datetime) -> typing.Tuple["ndarray", "ndarray", "ndarray"]:
+
+def ecef2eci(
+    x: "ndarray", y: "ndarray", z: "ndarray", time: datetime, *, use_astropy: bool = True
+) -> typing.Tuple["ndarray", "ndarray", "ndarray"]:
     """
     Point => Point   ECEF => ECI
 
@@ -69,6 +93,8 @@ def ecef2eci(x: "ndarray", y: "ndarray", z: "ndarray", time: datetime) -> typing
         target z ECEF coordinate
     time : datetime.datetime
         time of observation
+    use_astropy: bool, optional
+        use AstroPy (much more accurate)
 
     Results
     -------
@@ -80,11 +106,34 @@ def ecef2eci(x: "ndarray", y: "ndarray", z: "ndarray", time: datetime) -> typing
         z ECI coordinate
     """
 
-    if Time is None:
-        raise ImportError("pip install astropy")
-
-    itrs = ITRS(CartesianRepresentation(x * u.m, y * u.m, z * u.m), obstime=time)
-    gcrs = itrs.transform_to(GCRS(obstime=time))
-    ecef = EarthLocation(*gcrs.cartesian.xyz)
-
-    return ecef.x.value, ecef.y.value, ecef.z.value
+    if use_astropy and Time is not None:
+        itrs = ITRS(CartesianRepresentation(x * u.m, y * u.m, z * u.m), obstime=time)
+        gcrs = itrs.transform_to(GCRS(obstime=time))
+        eci = EarthLocation(*gcrs.cartesian.xyz)
+
+        x_eci = eci.x.value
+        y_eci = eci.y.value
+        z_eci = eci.z.value
+    else:
+        x = atleast_1d(x)
+        y = atleast_1d(y)
+        z = atleast_1d(z)
+        gst = atleast_1d(greenwichsrt(juliandate(time)))
+        assert x.shape == y.shape == z.shape
+        assert x.size == gst.size
+
+        ecef = column_stack((x.ravel(), y.ravel(), z.ravel()))
+        eci = empty((x.size, 3))
+        for i in range(x.size):
+            eci[i, :] = R3(gst[i]).T @ ecef[i, :]
+
+        x_eci = eci[:, 0].reshape(x.shape)
+        y_eci = eci[:, 1].reshape(y.shape)
+        z_eci = eci[:, 2].reshape(z.shape)
+
+    return x_eci, y_eci, z_eci
+
+
+def R3(x: float) -> "ndarray":
+    """Rotation matrix for ECI"""
+    return array([[cos(x), sin(x), 0], [-sin(x), cos(x), 0], [0, 0, 1]])


=====================================
src/pymap3d/sidereal.py
=====================================
@@ -17,12 +17,12 @@ The "usevallado" datetime to julian runs 4 times faster than astropy.
 However, AstroPy is more accurate.
 """
 
-__all__ = ["datetime2sidereal", "juliandate", "julian2sidereal"]
+__all__ = ["datetime2sidereal", "juliandate", "greenwichsrt"]
 
 
-def datetime2sidereal(time: datetime, lon_radians: float, usevallado: bool = True) -> float:
+def datetime2sidereal(time: datetime, lon_radians: float, *, use_astropy: bool = True) -> float:
     """
-    Convert ``datetime`` to sidereal time
+    Convert ``datetime`` to local sidereal time
 
     from D. Vallado "Fundamentals of Astrodynamics and Applications"
 
@@ -31,34 +31,33 @@ def datetime2sidereal(time: datetime, lon_radians: float, usevallado: bool = Tru
         time to convert
     lon_radians : float
         longitude (radians)
-    usevallado : bool, optional
-        use vallado instead of AstroPy (default is Vallado)
+    use_astropy : bool, optional
+        use AstroPy for conversion (False is Vallado)
 
     Results
     -------
 
     tsr : float
-        Sidereal time
+        Local sidereal time
     """
     if isinstance(time, (tuple, list)):
         return [datetime2sidereal(t, lon_radians) for t in time]
 
-    usevallado = usevallado or Time is None
-    if usevallado:
+    if use_astropy and Time is not None:
+        tsr = Time(time).sidereal_time(kind="apparent", longitude=Longitude(lon_radians, unit=u.radian)).radian
+    else:
         jd = juliandate(str2dt(time))
         # %% Greenwich Sidereal time RADIANS
-        gst = julian2sidereal(jd)
+        gst = greenwichsrt(jd)
         # %% Algorithm 15 p. 188 rotate GST to LOCAL SIDEREAL TIME
         tsr = gst + lon_radians
-    else:
-        tsr = Time(time).sidereal_time(kind="apparent", longitude=Longitude(lon_radians, unit=u.radian)).radian
 
     return tsr
 
 
 def juliandate(time: datetime) -> float:
     """
-    Python datetime to Julian time
+    Python datetime to Julian time (days since Jan 1, 4713 BCE)
 
     from D.Vallado Fundamentals of Astrodynamics and Applications p.187
      and J. Meeus Astronomical Algorithms 1991 Eqn. 7.1 pg. 61
@@ -73,7 +72,7 @@ def juliandate(time: datetime) -> float:
     -------
 
     jd : float
-        Julian date
+        Julian date (days since Jan 1, 4713 BCE)
     """
     if isinstance(time, (tuple, list)):
         return list(map(juliandate, time))
@@ -92,7 +91,7 @@ def juliandate(time: datetime) -> float:
     return int(365.25 * (year + 4716)) + int(30.6001 * (month + 1)) + time.day + B - 1524.5 + C
 
 
-def julian2sidereal(Jdate: float) -> float:
+def greenwichsrt(Jdate: float) -> float:
     """
     Convert Julian time to sidereal time
 
@@ -102,7 +101,7 @@ def julian2sidereal(Jdate: float) -> float:
     ----------
 
     Jdate: float
-        Julian centuries from J2000.0
+        Julian date (since Jan 1, 4713 BCE)
 
     Results
     -------
@@ -111,7 +110,7 @@ def julian2sidereal(Jdate: float) -> float:
         Sidereal time
     """
     if isinstance(Jdate, (tuple, list)):
-        return list(map(julian2sidereal, Jdate))
+        return list(map(greenwichsrt, Jdate))
 
     # %% Vallado Eq. 3-42 p. 184, Seidelmann 3.311-1
     tUT1 = (Jdate - 2451545.0) / 36525.0


=====================================
src/pymap3d/vallado.py
=====================================
@@ -23,7 +23,7 @@ if typing.TYPE_CHECKING:
 
 
 def azel2radec(
-    az_deg: "ndarray", el_deg: "ndarray", lat_deg: "ndarray", lon_deg: "ndarray", time: datetime, usevallado: bool = True
+    az_deg: "ndarray", el_deg: "ndarray", lat_deg: "ndarray", lon_deg: "ndarray", time: datetime, *, use_astropy: bool = True
 ) -> typing.Tuple["ndarray", "ndarray"]:
     """
     converts azimuth, elevation to right ascension, declination
@@ -41,6 +41,8 @@ def azel2radec(
         observer WGS84 longitude [degrees]
     time : datetime.datetime
         time of observation
+    use_astropy : bool, optional
+        use AstroPy
 
     Results
     -------
@@ -66,14 +68,14 @@ def azel2radec(
 
     lha = atan2(-(sin(az) * cos(el)) / cos(dec), (sin(el) - sin(lat) * sin(dec)) / (cos(dec) * cos(lat)))
 
-    lst = datetime2sidereal(time, lon)  # lon, ra in RADIANS
+    lst = datetime2sidereal(time, lon, use_astropy=use_astropy)  # lon, ra in RADIANS
 
     """ by definition right ascension [0, 360) degrees """
     return degrees(lst - lha) % 360, degrees(dec)
 
 
 def radec2azel(
-    ra_deg: "ndarray", dec_deg: "ndarray", lat_deg: "ndarray", lon_deg: "ndarray", time: datetime, usevallado: bool = True
+    ra_deg: "ndarray", dec_deg: "ndarray", lat_deg: "ndarray", lon_deg: "ndarray", time: datetime, *, use_astropy: bool = True
 ) -> typing.Tuple["ndarray", "ndarray"]:
     """
     converts right ascension, declination to azimuth, elevation
@@ -91,6 +93,8 @@ def radec2azel(
         observer WGS84 longitude [degrees]
     time : datetime.datetime
         time of observation
+    use_astropy : bool, optional
+        use Astropy if available
 
     Results
     -------
@@ -112,7 +116,7 @@ def radec2azel(
     lat = radians(lat_deg)
     lon = radians(lon_deg)
 
-    lst = datetime2sidereal(time, lon)  # RADIANS
+    lst = datetime2sidereal(time, lon, use_astropy=use_astropy)  # RADIANS
     # %% Eq. 4-11 p. 267 LOCAL HOUR ANGLE
     lha = lst - ra
     # %% #Eq. 4-12 p. 267


=====================================
tests/test_eci.py
=====================================
@@ -4,66 +4,93 @@ from datetime import datetime
 import pymap3d as pm
 
 
-def test_eci2ecef():
-
-    pytest.importorskip("astropy")
+ at 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
     eci = [-2981784, 5207055, 3161595]
     utc = datetime(2019, 1, 4, 12)
-    ecef = pm.eci2ecef(*eci, utc)
-    assert ecef == approx([-5.7627e6, -1.6827e6, 3.1560e6], rel=0.01)
+    ecef = pm.eci2ecef(*eci, utc, use_astropy=use_astropy)
 
+    rel = 0.0001 if use_astropy else 0.02
+    assert ecef == approx([-5.7627e6, -1.6827e6, 3.1560e6], rel=rel)
 
-def test_ecef2eci():
 
-    pytest.importorskip("astropy")
+ at 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
     ecef = [-5762640, -1682738, 3156028]
     utc = datetime(2019, 1, 4, 12)
-    eci = pm.ecef2eci(*ecef, utc)
-    print(eci)
-    assert eci == approx([-2.9818e6, 5.2070e6, 3.1616e6], rel=0.01)
+    eci = pm.ecef2eci(*ecef, utc, use_astropy=use_astropy)
+
+    rel = 0.0001 if use_astropy else 0.01
+    assert eci == approx([-2.9818e6, 5.2070e6, 3.1616e6], rel=rel)
 
 
-def test_eci2geodetic():
-    pytest.importorskip("astropy")
+ at pytest.mark.parametrize("use_astropy", [True, False])
+def test_eci2geodetic(use_astropy):
+    pytest.importorskip("numpy")
+    if use_astropy:
+        pytest.importorskip("astropy")
 
     eci = [-2981784, 5207055, 3161595]
     utc = datetime(2019, 1, 4, 12)
-    lla = pm.eci2geodetic(*eci, utc)
-    assert lla == approx([27.881, -163.722, 408850.65], rel=0.001)
+    lla = pm.eci2geodetic(*eci, utc, use_astropy=use_astropy)
+
+    rel = 0.0001 if use_astropy else 0.01
+    assert lla == approx([27.881, -163.722, 408850.65], rel=rel)
 
 
-def test_geodetic2eci():
-    pytest.importorskip("astropy")
+ at pytest.mark.parametrize("use_astropy", [True, False])
+def test_geodetic2eci(use_astropy):
+    pytest.importorskip("numpy")
+    if use_astropy:
+        pytest.importorskip("astropy")
 
     lla = [27.881, -163.722, 408850.65]
     utc = datetime(2019, 1, 4, 12)
-    eci = pm.geodetic2eci(*lla, utc)
-    assert eci == approx([-2981784, 5207055, 3161595], rel=0.001)
+    eci = pm.geodetic2eci(*lla, utc, use_astropy=use_astropy)
 
+    rel = 0.0001 if use_astropy else 0.01
+    assert eci == approx([-2981784, 5207055, 3161595], rel=rel)
 
-def test_eci2aer():
+
+ at pytest.mark.parametrize("use_astropy", [True, False])
+def test_eci2aer(use_astropy):
     # test coords from Matlab eci2aer
-    pytest.importorskip("astropy")
+    pytest.importorskip("numpy")
+    if use_astropy:
+        pytest.importorskip("astropy")
     t = datetime(1969, 7, 20, 21, 17, 40)
 
     eci = [-3.8454e8, -0.5099e8, -0.3255e8]
     lla = [28.4, -80.5, 2.7]
 
-    aer = pm.eci2aer(*eci, *lla, t)
-    assert aer == approx([162.55, 55.12, 384013940.9], rel=0.001)
+    aer = pm.eci2aer(*eci, *lla, t, use_astropy=use_astropy)
+    rel = 0.0001 if use_astropy else 0.01
+    assert aer == approx([162.55, 55.12, 384013940.9], rel=rel)
 
 
-def test_aer2eci():
+ at pytest.mark.parametrize("use_astropy", [True, False])
+def test_aer2eci(use_astropy):
     # test coords from Matlab aer2eci
-    pytest.importorskip("astropy")
+    pytest.importorskip("numpy")
+    if use_astropy:
+        pytest.importorskip("astropy")
 
     aer = [162.55, 55.12, 384013940.9]
     lla = [28.4, -80.5, 2.7]
     t = datetime(1969, 7, 20, 21, 17, 40)
 
-    assert pm.aer2eci(*aer, *lla, t) == approx([-3.8454e8, -0.5099e8, -0.3255e8], rel=0.001)
+    eci = pm.aer2eci(*aer, *lla, t, use_astropy=use_astropy)
+
+    rel = 0.001 if use_astropy else 0.06
+    assert eci == approx([-3.8454e8, -0.5099e8, -0.3255e8], rel=rel)
 
     with pytest.raises(ValueError):
         pm.aer2eci(aer[0], aer[1], -1, *lla, t)


=====================================
tests/test_look_spheroid.py
=====================================
@@ -4,26 +4,44 @@ from pytest import approx
 import pymap3d as pm
 from math import nan
 
-lla0 = (42, -82, 200)
-az = [0.0, 10.0, 125.0]
 
+ at pytest.mark.parametrize(
+    "az,tilt,lat,lon,sr",
+    [
+        (0, 0, 10, -20, 1e3),
+        (0, 90, nan, nan, nan),
+        (0, 45, 10.009041667, -20, 1.41432515e3),
+        (45, 45, 10.00639336, -19.993549978, 1.414324795e3),
+        (125, 45, 9.99481382, -19.992528, 1.414324671e3),
+    ],
+)
+def test_losint(az, tilt, lat, lon, sr):
 
-def test_losint():
+    lla0 = (10, -20, 1e3)
+    lat1, lon1, sr1 = pm.lookAtSpheroid(*lla0, az, tilt=tilt)
 
-    lat, lon, sr = pm.lookAtSpheroid(*lla0, az[1], tilt=0.0)
+    nan_ok = True if tilt == 90 else False
 
-    assert (lat, lon, sr) == approx(lla0)
-    assert isinstance(lat, float)
-    assert isinstance(lon, float)
-    assert isinstance(sr, float)
+    assert lat1 == approx(lat, nan_ok=nan_ok)
+    assert lon1 == approx(lon, nan_ok=nan_ok)
+    assert sr1 == approx(sr, nan_ok=nan_ok)
+    assert isinstance(lat1, float)
+    assert isinstance(lon1, float)
+    assert isinstance(sr1, float)
+
+
+def test_badval():
 
     with pytest.raises(ValueError):
-        pm.lookAtSpheroid(lla0[0], lla0[1], -1, az, 0)
+        pm.lookAtSpheroid(0, 0, -1, 0, 0)
 
 
 def test_array():
     np = pytest.importorskip("numpy")
+
+    az = [0.0, 10.0, 125.0]
     tilt = [30.0, 45.0, 90.0]
+    lla0 = (42, -82, 200)
     lat, lon, sr = pm.lookAtSpheroid(*lla0, az, tilt)
 
     truth = np.array([[42.00103959, lla0[1], 230.9413173], [42.00177328, -81.9995808, 282.84715651], [nan, nan, nan]])


=====================================
tests/test_astropy.py → tests/test_sidereal.py
=====================================
@@ -13,19 +13,12 @@ sra = 2.90658
 ha = 45.482789587392013
 
 
- at pytest.mark.parametrize("time", [t0, [t0]], ids=("scalar", "list"))
-def test_sidereal(time):
-    pytest.importorskip("astropy")
+ at pytest.mark.parametrize("time, use_astropy", [(t0, False), (t0, True), ([t0], False), ([t0], True)])
+def test_sidereal(time, use_astropy):
+    if use_astropy:
+        pytest.importorskip("astropy")
     # http://www.jgiesen.de/astro/astroJS/siderealClock/
-    tsr = pmd.datetime2sidereal(time, radians(lon), False)
-    if isinstance(tsr, list):
-        tsr = tsr[0]
-    assert tsr == approx(sra, rel=1e-5)
-
-
- at pytest.mark.parametrize("time", [t0, [t0]], ids=("scalar", "list"))
-def test_sidereal_vallado(time):
-    tsr = pmd.datetime2sidereal(time, radians(lon), True)
+    tsr = pmd.datetime2sidereal(time, radians(lon), use_astropy=use_astropy)
     if isinstance(tsr, list):
         tsr = tsr[0]
     assert tsr == approx(sra, rel=1e-5)
@@ -33,7 +26,6 @@ def test_sidereal_vallado(time):
 
 def test_anglesep():
     pytest.importorskip("astropy")
-
     assert pmh.anglesep(35, 23, 84, 20) == approx(ha)
 
 


=====================================
tests/test_sky.py
=====================================
@@ -10,29 +10,29 @@ t0 = datetime(2014, 4, 6, 8)
 radec = (166.5032081149338, 55.000011165405752)
 
 
- at pytest.mark.parametrize("usevallado", [True, False])
-def test_azel2radec(usevallado):
-    radec1 = pm.azel2radec(*azel, lat, lon, t0, usevallado=usevallado)
+ at pytest.mark.parametrize("use_astropy", [True, False])
+def test_azel2radec(use_astropy):
+    radec1 = pm.azel2radec(*azel, lat, lon, t0, use_astropy=use_astropy)
     assert radec1 == approx(radec, rel=0.01)
 
 
- at pytest.mark.parametrize("usevallado", [True, False])
-def test_numpy_azel2radec(usevallado):
+ at pytest.mark.parametrize("use_astropy", [True, False])
+def test_numpy_azel2radec(use_astropy):
     pytest.importorskip("numpy")
-    radec1 = pm.azel2radec([180.1, 180.1], [80, 80], lat, lon, t0, usevallado=usevallado)
+    radec1 = pm.azel2radec([180.1, 180.1], [80, 80], lat, lon, t0, use_astropy=use_astropy)
     assert radec1 == approx(radec, rel=0.01)
 
 
- at pytest.mark.parametrize("usevallado", [True, False])
-def test_radec2azel(usevallado):
-    azel1 = pm.radec2azel(*radec, lat, lon, t0, usevallado=usevallado)
+ at pytest.mark.parametrize("use_astropy", [True, False])
+def test_radec2azel(use_astropy):
+    azel1 = pm.radec2azel(*radec, lat, lon, t0, use_astropy=use_astropy)
     assert azel1 == approx(azel, rel=0.01)
 
 
- at pytest.mark.parametrize("usevallado", [True, False])
-def test_numpy_radec2azel(usevallado):
+ at pytest.mark.parametrize("use_astropy", [True, False])
+def test_numpy_radec2azel(use_astropy):
     pytest.importorskip("numpy")
-    azel1 = pm.radec2azel([166.503208, 166.503208], [55, 55], lat, lon, t0, usevallado=usevallado)
+    azel1 = pm.radec2azel([166.503208, 166.503208], [55, 55], lat, lon, t0, use_astropy=use_astropy)
     assert azel1 == approx(azel, rel=0.01)
 
 



View it on GitLab: https://salsa.debian.org/debian-gis-team/pymap3d/-/compare/21b7ff11cbb1c2fde17412fe2cf6ee14eb6711b5...e9bb5db6825a661efc5dd1386985f513c725ed38

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/pymap3d/-/compare/21b7ff11cbb1c2fde17412fe2cf6ee14eb6711b5...e9bb5db6825a661efc5dd1386985f513c725ed38
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20200511/b7e9efd1/attachment-0001.html>


More information about the Pkg-grass-devel mailing list