Пример #1
0
    def test_compute_delta_in_moving_frame_north():
        wgs84 = FrameE(name='WGS84')
        point_a = wgs84.GeoPoint(latitude=1, longitude=2, z=0, degrees=True)
        point_b = wgs84.GeoPoint(latitude=1.005,
                                 longitude=2.0,
                                 z=0,
                                 degrees=True)
        sensor_position = wgs84.GeoPoint(latitude=1.0025,
                                         longitude=2.0,
                                         z=0,
                                         degrees=True)
        path = GeoPath(point_a, point_b)
        ti = np.linspace(0, 1.0, 8)
        ship_positions0 = path.interpolate(ti[:-1])
        ship_positions1 = path.interpolate(ti[1:])
        headings = ship_positions0.delta_to(ship_positions1).azimuth_deg
        assert_array_almost_equal(headings, 0, decimal=8)

        ship_positions = path.interpolate(ti)

        delta0 = delta_L(ship_positions, sensor_position, wander_azimuth=0)
        delta = ship_positions.delta_to(sensor_position)
        assert_array_almost_equal(delta0.pvector, delta.pvector)

        x, y, z = delta.pvector
        azimuth = np.round(np.abs(delta.azimuth_deg))
        # positive angle about down-axis

        print('Ex1, delta north, east, down = {0}'.format(delta.pvector.T))
        print('Ex1, azimuth = {0} deg'.format(azimuth))

        true_x = [
            276.436537069603, 197.45466985931083, 118.47280221160541,
            39.49093416312986, -39.490934249581684, -118.47280298990226,
            -197.454672021303, -276.4365413071498
        ]
        assert_array_almost_equal(x, true_x)
        assert_array_almost_equal(y, 0, decimal=8)
        assert_array_almost_equal(z, 0, decimal=2)
        n2 = len(azimuth) // 2
        assert_array_almost_equal(azimuth[:n2], 0)
        assert_array_almost_equal(azimuth[n2:], 180)
Пример #2
0
    def test_compute_delta_in_moving_frame_east():
        wgs84 = FrameE(name='WGS84')
        point_a = wgs84.GeoPoint(latitude=1, longitude=2, z=0, degrees=True)
        point_b = wgs84.GeoPoint(latitude=1,
                                 longitude=2.005,
                                 z=0,
                                 degrees=True)
        sensor_position = wgs84.GeoPoint(latitude=1.0,
                                         longitude=2.0025,
                                         z=0,
                                         degrees=True)
        path = GeoPath(point_a, point_b)
        ti = np.linspace(0, 1.0, 8)
        ship_positions0 = path.interpolate(ti[:-1])
        ship_positions1 = path.interpolate(ti[1:])
        headings = ship_positions0.delta_to(ship_positions1).azimuth_deg
        assert_array_almost_equal(headings, 90, decimal=4)

        ship_positions = path.interpolate(ti)

        delta = ship_positions.delta_to(sensor_position)

        x, y, z = delta.pvector
        azimuth = np.round(delta.azimuth_deg)
        # positive angle about down-axis

        print('Ex1, delta north, east, down = {0}'.format(delta.pvector.T))
        print('Ex1, azimuth = {0} deg'.format(azimuth))

        true_y = [
            278.2566243359911, 198.7547317612817, 119.25283909376164,
            39.750946370747656, -39.75094637085409, -119.25283909387079,
            -198.75473176137066, -278.2566243360949
        ]
        assert_array_almost_equal(x, 0, decimal=3)
        assert_array_almost_equal(y, true_y)
        assert_array_almost_equal(z, 0, decimal=2)
        n2 = len(azimuth) // 2
        assert_array_almost_equal(azimuth[:n2], 90)
        assert_array_almost_equal(azimuth[n2:], -90)
Пример #3
0
    def test_Ex6_interpolated_position():

        # Position B at time t0 and t2 is given as n_EB_E_t0 and n_EB_E_t1:
        # Enter elements as lat/long in deg:
        wgs84 = FrameE(name="WGS84")
        n_EB_E_t0 = wgs84.GeoPoint(89, 0, degrees=True).to_nvector()
        n_EB_E_t1 = wgs84.GeoPoint(89, 180, degrees=True).to_nvector()

        # The times are given as:
        t0 = 10.0
        t1 = 20.0
        ti = 16.0  # time of interpolation

        # Find the interpolated position at time ti, n_EB_E_ti

        # SOLUTION:
        # Using standard interpolation:
        ti_n = (ti - t0) / (t1 - t0)
        n_EB_E_ti = n_EB_E_t0 + ti_n * (n_EB_E_t1 - n_EB_E_t0)

        # When displaying the resulting position for humans, it is more
        # convenient to see lat, long:
        g_EB_E_ti = n_EB_E_ti.to_geo_point()
        lat_ti, lon_ti = g_EB_E_ti.latitude_deg, g_EB_E_ti.longitude_deg
        msg = "Ex6, Interpolated position: lat, long = {} deg, {} deg"
        print(msg.format(lat_ti, lon_ti))

        assert_array_almost_equal(lat_ti, 89.7999805)
        assert_array_almost_equal(lon_ti, 180.0)

        # Alternative solution
        path = GeoPath(n_EB_E_t0, n_EB_E_t1)

        g_EB_E_ti = path.interpolate(ti_n).to_geo_point()
        lat_ti, lon_ti = g_EB_E_ti.latitude_deg, g_EB_E_ti.longitude_deg
        msg = "Ex6, Interpolated position: lat, long = {} deg, {} deg"
        print(msg.format(lat_ti, lon_ti))

        assert_array_almost_equal(lat_ti, 89.7999805)
        assert_array_almost_equal(lon_ti, 180.0)
Пример #4
0
    def test_Ex6_interpolated_position():

        # Position B at time t0 and t2 is given as n_EB_E_t0 and n_EB_E_t1:
        # Enter elements as lat/long in deg:
        wgs84 = FrameE(name='WGS84')
        n_EB_E_t0 = wgs84.GeoPoint(89, 0, degrees=True).to_nvector()
        n_EB_E_t1 = wgs84.GeoPoint(89, 180, degrees=True).to_nvector()

        # The times are given as:
        t0 = 10.
        t1 = 20.
        ti = 16.  # time of interpolation

        # Find the interpolated position at time ti, n_EB_E_ti

        # SOLUTION:
        # Using standard interpolation:
        ti_n = (ti - t0) / (t1 - t0)
        n_EB_E_ti = n_EB_E_t0 + ti_n * (n_EB_E_t1 - n_EB_E_t0)

        # When displaying the resulting position for humans, it is more
        # convenient to see lat, long:
        g_EB_E_ti = n_EB_E_ti.to_geo_point()
        lat_ti, lon_ti = g_EB_E_ti.latitude_deg, g_EB_E_ti.longitude_deg
        msg = 'Ex6, Interpolated position: lat, long = {} deg, {} deg'
        print(msg.format(lat_ti, lon_ti))

        assert_array_almost_equal(lat_ti, 89.7999805)
        assert_array_almost_equal(lon_ti, 180.)

        # Alternative solution
        path = GeoPath(n_EB_E_t0, n_EB_E_t1)

        g_EB_E_ti = path.interpolate(ti_n).to_geo_point()
        lat_ti, lon_ti = g_EB_E_ti.latitude_deg, g_EB_E_ti.longitude_deg
        msg = 'Ex6, Interpolated position: lat, long = {} deg, {} deg'
        print(msg.format(lat_ti, lon_ti))

        assert_array_almost_equal(lat_ti, 89.7999805)
        assert_array_almost_equal(lon_ti, 180.)