Esempio n. 1
0
def test_calc_latlon_bnd_regular_grid():
    irregular_data = np.array([1, 2, 3, 5, 8, 13, 21], dtype=np.float32)
    regular_data = np.arange(10)
    irreg_bnds = [0.5, 1.5, 2.5, 4, 6.5, 10.5, 17, 25]
    reg_bnds = np.arange(11) - 0.5

    lat_bnds, lon_bnds = Utils.calculate_latlon_bnds(regular_data, irregular_data)
    np.testing.assert_equal(lat_bnds, reg_bnds)
    np.testing.assert_equal(lon_bnds, irreg_bnds)

    lat_bnds, lon_bnds = Utils.calculate_latlon_bnds(irregular_data, regular_data)
    np.testing.assert_equal(lat_bnds, irreg_bnds)
    np.testing.assert_equal(lon_bnds, reg_bnds)
Esempio n. 2
0
def test_calc_latlon_bnd_bounds_half_shift():
    lat_data = np.array([-90, -60, -30, 0, 30, 60, 90])
    lon_data = np.array([0, 90, 180, 270])

    lat_bnds, lon_bnds = Utils.calculate_latlon_bnds(lat_data, lon_data)

    np.testing.assert_equal(lat_bnds, [-90, -75, -45, -15, 15, 45, 75, 90])
    np.testing.assert_equal(lon_bnds, [-45, 45, 135, 225, 315])
Esempio n. 3
0
def test_calc_latlon_bnd_bounds():
    lat_data = np.array([-33.75, -11.25, 11.25, 33.75])
    lon_data = np.array([18, 54, 90, 126, 162])

    lat_bnds, lon_bnds = Utils.calculate_latlon_bnds(lat_data, lon_data)

    np.testing.assert_equal(lat_bnds, [-45, -22.5, 0, 22.5, 45])
    np.testing.assert_equal(lon_bnds, [0, 36, 72, 108, 144, 180])
Esempio n. 4
0
def test_calc_latlon_bnd_monotonic():
    test_data = np.linspace(0, 10, 11)
    with pytest.raises(ValueError):
        _ = Utils.calculate_latlon_bnds(test_data[::-1], test_data)
    with pytest.raises(ValueError):
        _ = Utils.calculate_latlon_bnds(test_data, test_data[::-1])
Esempio n. 5
0
def test_calc_latlon_bnd_1d_input():
    test_data = np.linspace(10, 50, 5)
    with pytest.raises(ValueError):
        _ = Utils.calculate_latlon_bnds(test_data[:, None], test_data)
    with pytest.raises(ValueError):
        _ = Utils.calculate_latlon_bnds(test_data, test_data[:, None])