How to use pymap3d - 10 common examples

To help you get started, we’ve selected a few pymap3d examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github scivision / pymap3d / tests / test_vincenty_vreckon.py View on Github external
def test_unit(lat, lon, srange, az, lato, lono):
    lat1, lon1 = vincenty.vreckon(lat, lon, srange, az)

    assert lat1 == approx(lato)
    assert lon1 == approx(lono, rel=0.001)
github scivision / pymap3d / tests / test_vincenty_dist.py View on Github external
def test_unit(lat, lon, lat1, lon1, srange, az):
    dist, az1 = vincenty.vdist(lat, lon, lat1, lon1)
    assert dist == approx(srange, rel=0.005)
    assert az1 == approx(az)
github scivision / pymap3d / tests / test_rsphere.py View on Github external
#!/usr/bin/env python3
import pytest
from pytest import approx
import pymap3d as pm

ell = pm.Ellipsoid()
A = ell.semimajor_axis


def test_geocentric_radius():
    assert pm.geocentric_radius(0) == approx(ell.semimajor_axis)
    assert pm.geocentric_radius(90) == approx(ell.semiminor_axis)
    assert pm.geocentric_radius(45) == approx(6367490.0)
    assert pm.geocentric_radius(30) == approx(6372824.0)


@pytest.mark.parametrize("bad_lat", [-91, 91])
def test_geocentric_radius_badval(bad_lat):
    with pytest.raises(ValueError):
        pm.geocentric_radius(bad_lat)
github scivision / pymap3d / tests / test_aer.py View on Github external
#!/usr/bin/env python3
from math import radians
import pytest
from pytest import approx
import pymap3d as pm

ELL = pm.Ellipsoid()
A = ELL.semimajor_axis
B = ELL.semiminor_axis


@pytest.mark.parametrize("aer,lla,xyz", [((33, 70, 1000), (42, -82, 200), (660930.2, -4701424.0, 4246579.6))])
def test_aer2ecef(aer, lla, xyz):
    x, y, z = pm.aer2ecef(*aer, *lla)
    assert x == approx(xyz[0])
    assert y == approx(xyz[1])
    assert z == approx(xyz[2])

    raer = (radians(aer[0]), radians(aer[1]), aer[2])
    rlla = (radians(lla[0]), radians(lla[1]), lla[2])
    assert pm.aer2ecef(*raer, *rlla, deg=False) == approx(xyz)

    with pytest.raises(ValueError):
github scivision / pymap3d / tests / test_elliposid.py View on Github external
def test_ellipsoid():

    assert pm.ecef2geodetic(*xyz0, ell=pm.Ellipsoid("wgs84")) == approx([42.014670535, -82.0064785, 276.9136916])
    assert pm.ecef2geodetic(*xyz0, ell=pm.Ellipsoid("grs80")) == approx([42.014670536, -82.0064785, 276.9137385])
    assert pm.ecef2geodetic(*xyz0, ell=pm.Ellipsoid("clarke1866")) == approx([42.01680003, -82.0064785, 313.9026793])
    assert pm.ecef2geodetic(*xyz0, ell=pm.Ellipsoid("mars")) == approx([42.009428417, -82.006479, 2.981246e6])
    assert pm.ecef2geodetic(*xyz0, ell=pm.Ellipsoid("venus")) == approx([41.8233663, -82.0064785, 3.17878159e5])
    assert pm.ecef2geodetic(*xyz0, ell=pm.Ellipsoid("moon")) == approx([41.8233663, -82.0064785, 4.630878e6])
github scivision / pymap3d / tests / test_elliposid.py View on Github external
def test_ellipsoid():

    assert pm.ecef2geodetic(*xyz0, ell=pm.Ellipsoid("wgs84")) == approx([42.014670535, -82.0064785, 276.9136916])
    assert pm.ecef2geodetic(*xyz0, ell=pm.Ellipsoid("grs80")) == approx([42.014670536, -82.0064785, 276.9137385])
    assert pm.ecef2geodetic(*xyz0, ell=pm.Ellipsoid("clarke1866")) == approx([42.01680003, -82.0064785, 313.9026793])
    assert pm.ecef2geodetic(*xyz0, ell=pm.Ellipsoid("mars")) == approx([42.009428417, -82.006479, 2.981246e6])
    assert pm.ecef2geodetic(*xyz0, ell=pm.Ellipsoid("venus")) == approx([41.8233663, -82.0064785, 3.17878159e5])
    assert pm.ecef2geodetic(*xyz0, ell=pm.Ellipsoid("moon")) == approx([41.8233663, -82.0064785, 4.630878e6])
github scivision / pymap3d / tests / test_ned.py View on Github external
#!/usr/bin/env python
import pytest
from pytest import approx
import pymap3d as pm

lla0 = (42, -82, 200)
aer0 = (33, 70, 1000)

ELL = pm.Ellipsoid()
A = ELL.semimajor_axis
B = ELL.semiminor_axis


def test_ecef_ned():
    enu = pm.aer2enu(*aer0)
    ned = (enu[1], enu[0], -enu[2])
    xyz = pm.aer2ecef(*aer0, *lla0)

    n, e, d = pm.ecef2ned(*xyz, *lla0)
    assert n == approx(ned[0])
    assert e == approx(ned[1])
    assert d == approx(ned[2])

    assert pm.ned2ecef(*ned, *lla0) == approx(xyz)
github scivision / pymap3d / tests / test_geodetic.py View on Github external
#!/usr/bin/env python
import pytest
from pytest import approx
from math import radians, nan, sqrt, isnan

import pymap3d as pm

lla0 = (42, -82, 200)
rlla0 = (radians(lla0[0]), radians(lla0[1]), lla0[2])

xyz0 = (660675.2518247, -4700948.68316, 4245737.66222)

ELL = pm.Ellipsoid()
A = ELL.semimajor_axis
B = ELL.semiminor_axis

atol_dist = 1e-6  # 1 micrometer


@pytest.mark.parametrize("lla", [(42, -82, 200), ([42], [-82], [200])], ids=("scalar", "list"))
def test_scalar_geodetic2ecef(lla):
    """
    verify we can handle the wide variety of input data type users might use
    """
    if isinstance(lla[0], list):
        pytest.importorskip("numpy")

    x0, y0, z0 = pm.geodetic2ecef(*lla)
github scivision / pymap3d / tests / test_elliposid.py View on Github external
def test_ellipsoid():

    assert pm.ecef2geodetic(*xyz0, ell=pm.Ellipsoid("wgs84")) == approx([42.014670535, -82.0064785, 276.9136916])
    assert pm.ecef2geodetic(*xyz0, ell=pm.Ellipsoid("grs80")) == approx([42.014670536, -82.0064785, 276.9137385])
    assert pm.ecef2geodetic(*xyz0, ell=pm.Ellipsoid("clarke1866")) == approx([42.01680003, -82.0064785, 313.9026793])
    assert pm.ecef2geodetic(*xyz0, ell=pm.Ellipsoid("mars")) == approx([42.009428417, -82.006479, 2.981246e6])
    assert pm.ecef2geodetic(*xyz0, ell=pm.Ellipsoid("venus")) == approx([41.8233663, -82.0064785, 3.17878159e5])
    assert pm.ecef2geodetic(*xyz0, ell=pm.Ellipsoid("moon")) == approx([41.8233663, -82.0064785, 4.630878e6])
github scivision / pymap3d / tests / test_elliposid.py View on Github external
def test_ellipsoid():

    assert pm.ecef2geodetic(*xyz0, ell=pm.Ellipsoid("wgs84")) == approx([42.014670535, -82.0064785, 276.9136916])
    assert pm.ecef2geodetic(*xyz0, ell=pm.Ellipsoid("grs80")) == approx([42.014670536, -82.0064785, 276.9137385])
    assert pm.ecef2geodetic(*xyz0, ell=pm.Ellipsoid("clarke1866")) == approx([42.01680003, -82.0064785, 313.9026793])
    assert pm.ecef2geodetic(*xyz0, ell=pm.Ellipsoid("mars")) == approx([42.009428417, -82.006479, 2.981246e6])
    assert pm.ecef2geodetic(*xyz0, ell=pm.Ellipsoid("venus")) == approx([41.8233663, -82.0064785, 3.17878159e5])
    assert pm.ecef2geodetic(*xyz0, ell=pm.Ellipsoid("moon")) == approx([41.8233663, -82.0064785, 4.630878e6])