Esempio n. 1
0
def test_generate_latlon_include_lat_endpts():
    lats, lons, clats, clons = Utils.generate_latlon(3, 5, include_endpts=True)
    np.testing.assert_equal(lats[:, 0], [-90, 0, 90])
    assert clats[0] == -90
    assert clats[-1] == 90

    lats, lons, clats, clons = Utils.generate_latlon(4, 5, include_endpts=True)
    np.testing.assert_equal(lats[:, 0], [-90, -30, 30, 90])
Esempio n. 2
0
def test_generate_latlon_output_shp():
    nlats = 4
    nlons = 5

    lats, lons, clats, clons = Utils.generate_latlon(nlats, nlons)
    assert lats.shape == (4, 5)
    assert lons.shape == (4, 5)
    assert clats.shape == (5,)
    assert clons.shape == (6,)
Esempio n. 3
0
def test_generate_latlon_center_corner():
    lats, lons, clats, clons = Utils.generate_latlon(4,5,
                                                     lat_bnd=(-45, 45),
                                                     lon_bnd=(0, 180))

    np.testing.assert_equal(lats[:, 0], [-33.75, -11.25, 11.25, 33.75])
    np.testing.assert_equal(lons[0], [0, 36, 72, 108, 144])
    np.testing.assert_equal(clats, [-45, -22.5, 0, 22.5, 45])
    np.testing.assert_equal(clons, [-18, 18, 54, 90, 126, 162])
Esempio n. 4
0
def test_generate_latlon_bnd_limits():
    # TODO: could be parametrized input
    # Defaults
    Utils.generate_latlon(5, 5)

    # Bad lat bounds
    with pytest.raises(ValueError):
        Utils.generate_latlon(5, 5, lat_bnd=(-100, 45))
    with pytest.raises(ValueError):
        Utils.generate_latlon(5, 5, lat_bnd=(-45, 91))

    # Bad lon bounds
    Utils.generate_latlon(5, 5, lon_bnd=(-90, 270))

    with pytest.raises(ValueError):
        Utils.generate_latlon(5, 5, lon_bnd=(-180, 181))
    with pytest.raises(ValueError):
        Utils.generate_latlon(5, 5, lon_bnd=(-181, 40))
    with pytest.raises(ValueError):
        Utils.generate_latlon(5, 5, lon_bnd=(14, 361))