Beispiel #1
0
def test_losint():

    pytest.importorskip('pytest', minversion='3.5')

    az = [0., 10., 125.]

    lat, lon, sr = pm.lookAtSpheroid(*lla0, az, tilt=0.)
    assert (lat[0] == lat).all() and (lon[0] == lon).all() and (sr[0]
                                                                == sr).all()

    assert (lat[0], lon[0], sr[0]) == approx(lla0)

    with pytest.raises(ValueError):
        pm.lookAtSpheroid(lla0[0], lla0[1], -1, az, 0)


# %%
    tilt = [30., 45., 90.]
    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]])

    assert np.column_stack((lat, lon, sr)) == approx(truth, nan_ok=True)
def test_losint():

    lat, lon, sr = pm.lookAtSpheroid(*lla0, az[1], tilt=0.0)

    assert (lat, lon, sr) == approx(lla0)

    with pytest.raises(ValueError):
        pm.lookAtSpheroid(lla0[0], lla0[1], -1, az, 0)
def test_array():
    np = pytest.importorskip("numpy")
    tilt = [30.0, 45.0, 90.0]
    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]])

    assert np.column_stack((lat, lon, sr)) == approx(truth, nan_ok=True)
Beispiel #4
0
def test_losint():
    az = [0., 10., 125.]

    lat, lon, sr = pm.lookAtSpheroid(*lla0, az, tilt=0.)
    assert (lat[0] == lat).all() and (lon[0] == lon).all() and (sr[0] == sr).all()

    assert (lat[0], lon[0], sr[0]) == approx(lla0)

    with pytest.raises(ValueError):
        pm.lookAtSpheroid(lla0[0], lla0[1], -1, az, 0)

# %%
    tilt = [30., 45., 90.]
    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]])

    assert np.column_stack((lat, lon, sr)) == approx(truth, nan_ok=True)
Beispiel #5
0
def test_losint(az, tilt, lat, lon, sr):

    lla0 = (10, -20, 1e3)
    lat1, lon1, sr1 = pm.lookAtSpheroid(*lla0, az, tilt=tilt)

    nan_ok = True if tilt == 90 else False

    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)
Beispiel #6
0
def check_swath(out_path, track_list, sensor_angle, altitude_m):
    """
    Compute individual sensor cones by intersecting line of sight with Earth at random track points. Only use to check
    that get_sensor_swath is working correctly
    """
    check_az = np.arange(0, 360, 5)

    check_list = []

    # pick 3 points from each path and check swath with pymap
    for track in track_list:
        for _ in range(3):
            lonlat = random.choice(track)

            check = []
            for az in check_az:
                lat, lon, _ = pymap3d.lookAtSpheroid(lonlat[1], lonlat[0], altitude_m, az, sensor_angle)
                check.append([lon[()], lat[()]])

            check_list.append(check)

    write_track_geojson(out_path, check_list, {"test": "test"})
Beispiel #7
0
def test_badval():

    with pytest.raises(ValueError):
        pm.lookAtSpheroid(0, 0, -1, 0, 0)