示例#1
0
def test_kf_1d_nonzero_mean(uvw_and_known_kf_nonzero_mean):
    """Test kinematic flux calculation in 1D with non-zero-mean time series."""
    u, v, w, kf_true = uvw_and_known_kf_nonzero_mean
    assert_array_equal(kinematic_flux(u, v, perturbation=False),
                       kf_true['uv'])
    assert_array_equal(kinematic_flux(u, w, perturbation=False),
                       kf_true['uw'])
    assert_array_equal(kinematic_flux(v, w, perturbation=False),
                       kf_true['vw'])
示例#2
0
def test_kf_1d_nonzero_mean(uvw_and_known_kf_nonzero_mean):
    """Test kinematic flux calculation in 1D with non-zero-mean time series."""
    u, v, w, kf_true = uvw_and_known_kf_nonzero_mean
    assert_array_equal(kinematic_flux(u, v, perturbation=False),
                       kf_true['uv'])
    assert_array_equal(kinematic_flux(u, w, perturbation=False),
                       kf_true['uw'])
    assert_array_equal(kinematic_flux(v, w, perturbation=False),
                       kf_true['vw'])
示例#3
0
def test_kf_2d_axis_first_nonzero_mean(uvw_and_known_kf_nonzero_mean):
    """Test kinematic flux in 2D with non-zero-mean time series along first axis."""
    u, v, w, kf_true = uvw_and_known_kf_nonzero_mean
    u = np.array([u, u, u]).transpose()
    v = np.array([v, v, v]).transpose()
    w = np.array([w, w, w]).transpose()

    assert_array_equal(kinematic_flux(u, v, perturbation=False, axis=0),
                       kf_true['uv'])
    assert_array_equal(kinematic_flux(u, w, perturbation=False, axis=0),
                       kf_true['uw'])
    assert_array_equal(kinematic_flux(v, w, perturbation=False, axis=0),
                       kf_true['vw'])
示例#4
0
def test_kf_2d_axis_last_nonzero_mean(uvw_and_known_kf_nonzero_mean):
    """Test kinematic flux calculation in 2D with non-zero-mean time series along last axis."""
    u, v, w, kf_true = uvw_and_known_kf_nonzero_mean
    u = np.array([u, u, u])
    v = np.array([v, v, v])
    w = np.array([w, w, w])
    for key in kf_true.keys():
        tmp = kf_true[key]
        kf_true[key] = np.array([tmp, tmp, tmp])
    assert_array_equal(kinematic_flux(u, v, perturbation=False, axis=-1),
                       kf_true['uv'])
    assert_array_equal(kinematic_flux(u, w, perturbation=False, axis=-1),
                       kf_true['uw'])
    assert_array_equal(kinematic_flux(v, w, perturbation=False, axis=-1),
                       kf_true['vw'])
示例#5
0
def test_kf_2d_axis_last_nonzero_mean(uvw_and_known_kf_nonzero_mean):
    """Test kinematic flux calculation in 2D with non-zero-mean time series along last axis."""
    u, v, w, kf_true = uvw_and_known_kf_nonzero_mean
    u = np.array([u, u, u])
    v = np.array([v, v, v])
    w = np.array([w, w, w])
    for key in kf_true.keys():
        tmp = kf_true[key]
        kf_true[key] = np.array([tmp, tmp, tmp])
    assert_array_equal(kinematic_flux(u, v, perturbation=False, axis=-1),
                       kf_true['uv'])
    assert_array_equal(kinematic_flux(u, w, perturbation=False, axis=-1),
                       kf_true['uw'])
    assert_array_equal(kinematic_flux(v, w, perturbation=False, axis=-1),
                       kf_true['vw'])
示例#6
0
def test_kf_1d_zero_mean(uvw_and_known_kf_zero_mean):
    """Test kinematic flux calculation in 1D with zero-mean time series."""
    u, v, w, kf_true = uvw_and_known_kf_zero_mean
    assert_array_equal(kinematic_flux(u, v, perturbation=False), kf_true['uv'])
    assert_array_equal(kinematic_flux(u, w, perturbation=False), kf_true['uw'])
    assert_array_equal(kinematic_flux(v, w, perturbation=False), kf_true['vw'])

    # given u, v, and w have a zero mean, the kf computed with
    # perturbation=True and perturbation=False should be the same
    assert_array_equal(kinematic_flux(u, v, perturbation=False),
                       kinematic_flux(u, v, perturbation=True))
    assert_array_equal(kinematic_flux(u, w, perturbation=False),
                       kinematic_flux(u, w, perturbation=True))
    assert_array_equal(kinematic_flux(v, w, perturbation=False),
                       kinematic_flux(v, w, perturbation=True))
示例#7
0
def test_kf_1d_zero_mean(uvw_and_known_kf_zero_mean):
    """Test kinematic flux calculation in 1D with zero-mean time series."""
    u, v, w, kf_true = uvw_and_known_kf_zero_mean
    assert_array_equal(kinematic_flux(u, v, perturbation=False),
                       kf_true['uv'])
    assert_array_equal(kinematic_flux(u, w, perturbation=False),
                       kf_true['uw'])
    assert_array_equal(kinematic_flux(v, w, perturbation=False),
                       kf_true['vw'])

    # given u, v, and w have a zero mean, the kf computed with
    # perturbation=True and perturbation=False should be the same
    assert_array_equal(kinematic_flux(u, v, perturbation=False),
                       kinematic_flux(u, v, perturbation=True))
    assert_array_equal(kinematic_flux(u, w, perturbation=False),
                       kinematic_flux(u, w, perturbation=True))
    assert_array_equal(kinematic_flux(v, w, perturbation=False),
                       kinematic_flux(v, w, perturbation=True))
示例#8
0
def test_kf_2d_axis_first_zero_mean(uvw_and_known_kf_zero_mean):
    """Test kinematic flux calculation in 2D with zero-mean time series along first axis."""
    u, v, w, kf_true = uvw_and_known_kf_zero_mean
    u = np.array([u, u, u]).transpose()
    v = np.array([v, v, v]).transpose()
    w = np.array([w, w, w]).transpose()

    assert_array_equal(kinematic_flux(u, v, perturbation=False, axis=0),
                       kf_true['uv'])
    assert_array_equal(kinematic_flux(u, w, perturbation=False, axis=0),
                       kf_true['uw'])
    assert_array_equal(kinematic_flux(v, w, perturbation=False, axis=0),
                       kf_true['vw'])
    # given u, v, and w have a zero mean, the kf computed with
    # perturbation=True and perturbation=False should be the same
    assert_array_equal(kinematic_flux(u, v, perturbation=False, axis=0),
                       kinematic_flux(u, v, perturbation=True, axis=0))
    assert_array_equal(kinematic_flux(u, w, perturbation=False, axis=0),
                       kinematic_flux(u, w, perturbation=True, axis=0))
    assert_array_equal(kinematic_flux(v, w, perturbation=False, axis=0),
                       kinematic_flux(v, w, perturbation=True, axis=0))
示例#9
0
def test_kf_2d_axis_last_zero_mean(uvw_and_known_kf_zero_mean):
    """Test kinematic flux calculation in 2D with zero-mean time series along last axis."""
    u, v, w, kf_true = uvw_and_known_kf_zero_mean
    u = np.array([u, u, u])
    v = np.array([v, v, v])
    w = np.array([w, w, w])
    for key in kf_true.keys():
        tmp = kf_true[key]
        kf_true[key] = np.array([tmp, tmp, tmp])
    assert_array_equal(kinematic_flux(u, v, perturbation=False, axis=-1),
                       kf_true['uv'])
    assert_array_equal(kinematic_flux(u, w, perturbation=False, axis=-1),
                       kf_true['uw'])
    assert_array_equal(kinematic_flux(v, w, perturbation=False, axis=-1),
                       kf_true['vw'])
    # given u, v, and w have a zero mean, the kf computed with
    # perturbation=True and perturbation=False should be the same
    assert_array_equal(kinematic_flux(u, v, perturbation=False, axis=-1),
                       kinematic_flux(u, v, perturbation=True, axis=-1))
    assert_array_equal(kinematic_flux(u, w, perturbation=False, axis=-1),
                       kinematic_flux(u, w, perturbation=True, axis=-1))
    assert_array_equal(kinematic_flux(v, w, perturbation=False, axis=-1),
                       kinematic_flux(v, w, perturbation=True, axis=-1))
示例#10
0
def test_kf_2d_axis_last_zero_mean(uvw_and_known_kf_zero_mean):
    """Test kinematic flux calculation in 2D with zero-mean time series along last axis."""
    u, v, w, kf_true = uvw_and_known_kf_zero_mean
    u = np.array([u, u, u])
    v = np.array([v, v, v])
    w = np.array([w, w, w])
    for key in kf_true.keys():
        tmp = kf_true[key]
        kf_true[key] = np.array([tmp, tmp, tmp])
    assert_array_equal(kinematic_flux(u, v, perturbation=False, axis=-1),
                       kf_true['uv'])
    assert_array_equal(kinematic_flux(u, w, perturbation=False, axis=-1),
                       kf_true['uw'])
    assert_array_equal(kinematic_flux(v, w, perturbation=False, axis=-1),
                       kf_true['vw'])
    # given u, v, and w have a zero mean, the kf computed with
    # perturbation=True and perturbation=False should be the same
    assert_array_equal(kinematic_flux(u, v, perturbation=False, axis=-1),
                       kinematic_flux(u, v, perturbation=True, axis=-1))
    assert_array_equal(kinematic_flux(u, w, perturbation=False, axis=-1),
                       kinematic_flux(u, w, perturbation=True, axis=-1))
    assert_array_equal(kinematic_flux(v, w, perturbation=False, axis=-1),
                       kinematic_flux(v, w, perturbation=True, axis=-1))