Ejemplo n.º 1
0
def test_coverage_hv_quadrants1c():
    grid = np.zeros([1, 2, 2, 1])
    gsize = np.array([1, 2, 2])
    gmin = -gsize / 2.0
    theta, h, v = [-np.pi / 2], [0], [-0.5]
    cov_map = coverage(grid, gmin, gsize, pgrid, psize, theta, v, h)[0, ..., 0]
    truth = np.array([[0., 0.], [1., 1.]])
    np.testing.assert_equal(truth, cov_map)
Ejemplo n.º 2
0
def test_coverage_hv_quadrants4():
    grid = np.zeros([2, 2, 2, 1])
    gsize = np.array([2, 2, 2])
    gmin = -gsize / 2.0
    obj = np.zeros((2, 2, 2))
    theta, h, v = [0], [0], [-1]
    cov_map = coverage(grid, gmin, gsize, pgrid, psize, theta, v, h)[..., 0]
    obj[0, :, 1] = 1
    np.testing.assert_equal(obj, cov_map)
Ejemplo n.º 3
0
def test_coverage_hv_quadrants1_crop():
    theta, h, v = [0], [-0.5], [0]
    gmin = np.array([-2, 0, -1])
    gsize = np.array([5, 1, 3])
    grid = np.zeros((5, 1, 3, 1))
    cov_map = coverage(grid, gmin, gsize, pgrid, psize, theta, v, h)[:, 0, :,
                                                                     0]
    truth = np.array([[0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]])
    truth = np.moveaxis(truth, 1, 0)
    np.testing.assert_equal(truth, cov_map)
Ejemplo n.º 4
0
def test_theta_coverage():
    probe_grid, probe_size, \
        region, region_corner, region_size = init_coverage()
    theta, v, h, dwell, times = discrete_trajectory(theta_move,
                                                    tmin=0,
                                                    tmax=1,
                                                    tstep=0.5,
                                                    xstep=1 / 32)
    region = np.zeros([4, 16, 16, 1])
    region_corner = [-2 / 16, -8 / 16, -8 / 16]
    region_size = [4 / 16, 16 / 16, 16 / 16]
    cov_map = coverage(region, region_corner, region_size, probe_grid,
                       probe_size, theta, v, h, dwell)[..., 0]
    # np.save('tests/theta_coverage.npy', cov_map)
    truth = np.load('tests/theta_coverage.npy')
    # show_coverage(cov_map)
    print("Computed map\n{}\n".format(cov_map))
    print("True map\n{}\n".format(truth))
Ejemplo n.º 5
0
def test_stationary_coverage():
    """A beam of magnitude 10 at (:, 10, 8)."""
    probe_grid, probe_size, \
        region, region_corner, region_size = init_coverage()
    theta, v, h, dwell, times = discrete_trajectory(stationary,
                                                    tmin=0,
                                                    tmax=10,
                                                    tstep=1,
                                                    xstep=1 / 32)
    cov_map = coverage(region, region_corner, region_size, probe_grid,
                       probe_size, theta, v, h, dwell)[..., 0]

    # show_coverage(cov_map)
    key = cov_map[:, 8, :]
    truth = np.zeros([16, 16])
    truth[8, 10] = 10
    # plt.figure()
    # plt.plot(key[8, :], 'o')
    np.testing.assert_equal(key, truth)
Ejemplo n.º 6
0
def test_vertical_coverage():
    probe_grid, probe_size, \
        region, region_corner, region_size = init_coverage()
    theta, v, h, dwell, times = discrete_trajectory(vertical_move,
                                                    tmin=0,
                                                    tmax=40,
                                                    tstep=1,
                                                    xstep=1 / 32)
    cov_map = coverage(region, region_corner, region_size, probe_grid,
                       probe_size, theta, v, h, dwell)[..., 0]
    # show_coverage(cov_map)
    key = cov_map[:, 4, :]
    truth = np.zeros([16, 16])
    truth[9:12, 8] = 10
    truth[(8, 12), 8] = 5
    # plt.figure()
    # plt.plot(key[:, 8], 'o')
    # print(key[8, :])
    # assert_array_equal(key, truth)
    assert key[8, 8] >= 5 and key[8, 8] < 6
    assert key[12, 8] > 4 and key[12, 8] <= 5
    assert np.all(key[9:12, 8] == 10)
Ejemplo n.º 7
0
def test_horizontal_coverage():
    # NOTE: The forward edge of the smear will be slightly larger. The two
    # edges even out as the time step approaches zero.
    probe_grid, probe_size, \
        region, region_corner, region_size = init_coverage()
    theta, v, h, dwell, times = discrete_trajectory(horizontal_move,
                                                    tmin=0,
                                                    tmax=40,
                                                    tstep=1,
                                                    xstep=1 / 32)
    cov_map = coverage(region, region_corner, region_size, probe_grid,
                       probe_size, theta, v, h, dwell)[..., 0]
    # show_coverage(cov_map)
    key = cov_map[:, 10, :]
    truth = np.zeros([16, 16])
    truth[10, 5:18] = 10
    truth[10, (4, 8)] = 5
    # plt.figure()
    # plt.plot(key[10, :], 'o')
    print(key[10, :])
    # np.testing.assert_equal(key, truth)
    assert key[10, 8] >= 5 and key[10, 8] < 6
    assert key[10, 4] > 4 and key[10, 4] <= 5
    assert np.all(key[10, 5:8] == 10)