Example #1
0
def test_get_time_weights():
    """Test ``get_time_weights`` for complex cube."""
    cube = _make_cube()
    weights = get_time_weights(cube)
    assert weights.shape == cube.shape
    np.testing.assert_allclose(
        weights, [[[[15.0, 15.0, 15.0]]], [[[30.0, 30.0, 30.0]]]])
Example #2
0
def test_get_time_weights_1d_time():
    """Test ``get_time_weights`` for 1D time coordinate."""
    time = get_1d_time()
    cube = iris.cube.Cube([0.0, 1.0], var_name='x', units='K',
                          dim_coords_and_dims=[(time, 0)])
    weights = get_time_weights(cube)
    assert weights.shape == cube.shape
    np.testing.assert_allclose(weights, [15.0, 30.0])
Example #3
0
def test_get_time_weights_0d_time():
    """Test ``get_time_weights`` for 0D time coordinate."""
    time = get_0d_time()
    cube = iris.cube.Cube(0.0, var_name='x', units='K',
                          aux_coords_and_dims=[(time, ())])
    weights = get_time_weights(cube)
    assert weights.shape == cube.shape
    np.testing.assert_allclose(weights, 30.0)
Example #4
0
def test_get_time_weights_0d_time_1d_lon():
    """Test ``get_time_weights`` for 0D time and 1D longitude coordinate."""
    time = get_0d_time()
    lons = get_lon_coord()
    cube = iris.cube.Cube([0.0, 0.0, 0.0], var_name='x', units='K',
                          aux_coords_and_dims=[(time, ())],
                          dim_coords_and_dims=[(lons, 0)])
    weights = get_time_weights(cube)
    assert weights.shape == cube.shape
    np.testing.assert_allclose(weights, [30.0, 30.0, 30.0])