Ejemplo n.º 1
0
def test_convergence_asym():
    """Test convergence calculation with a complicated field."""
    u = np.array([[2, 4, 8], [0, 2, 2], [4, 6, 8]]) * units('m/s')
    v = np.array([[6, 4, 8], [2, 6, 0], [2, 2, 6]]) * units('m/s')
    c = h_convergence(u, v, 1 * units.meters, 2 * units.meters, dim_order='yx')
    true_c = np.array([[0., 4., 0.], [1., 0.5, -0.5], [2., 0., 5.]]) / units.sec
    assert_array_equal(c, true_c)

    # Now try for xy ordered
    c = h_convergence(u.T, v.T, 1 * units.meters, 2 * units.meters, dim_order='xy')
    assert_array_equal(c, true_c.T)
Ejemplo n.º 2
0
def test_convergence():
    """Test convergence for simple case."""
    a = np.arange(3)
    u = np.c_[a, a, a] * units('m/s')
    c = h_convergence(u, u, 1 * units.meter, 1 * units.meter, dim_order='xy')
    true_c = np.ones_like(u) / units.sec
    assert_array_equal(c, true_c)
Ejemplo n.º 3
0
def test_zero_convergence():
    """Test convergence calculation when zeros should be returned."""
    a = np.arange(3)
    u = np.c_[a, a, a] * units('m/s')
    c = h_convergence(u, u.T, 1 * units.meter, 1 * units.meter, dim_order='xy')
    true_c = 2. * np.ones_like(u) / units.sec
    assert_array_equal(c, true_c)
Ejemplo n.º 4
0
def test_convergence():
    """Test convergence for simple case."""
    a = np.arange(3)
    u = np.c_[a, a, a] * units('m/s')
    c = h_convergence(u, u, 1 * units.meter, 1 * units.meter)
    true_c = np.ones_like(u) / units.sec
    assert_array_equal(c, true_c)
Ejemplo n.º 5
0
def test_zero_convergence():
    """Test convergence calculation when zeros should be returned."""
    a = np.arange(3)
    u = np.c_[a, a, a] * units('m/s')
    c = h_convergence(u, u.T, 1 * units.meter, 1 * units.meter)
    true_c = 2. * np.ones_like(u) / units.sec
    assert_array_equal(c, true_c)
Ejemplo n.º 6
0
def test_convergence():
    """Test that convergence wrapper works (deprecated in 0.7)."""
    a = np.arange(3)
    u = np.c_[a, a, a] * units('m/s')
    with pytest.warns(MetpyDeprecationWarning):
        c = h_convergence(u, u, 1 * units.meter, 1 * units.meter, dim_order='xy')
    true_c = np.ones_like(u) / units.sec
    assert_array_equal(c, true_c)