def test_wind_components_northeast() -> None:
    """Ensure correct results when testing wind speed of 45 degrees
    """
    # Setup
    theta = 45
    speed = 10

    # Exercise
    u_calc, v_calc = meteogram.convert_to_wind_components(theta=theta,
                                                          speed=speed)

    # Verify
    u_desired = -7.0710  # could use np.sqrt here but prefer to be exact
    v_desired = -7.0710
    assert_almost_equal(u_calc, u_desired, 4)
    assert_almost_equal(v_calc, v_desired, 4)
def test_wind_components_no_wind() -> None:
    """Ensure correct results when testing wind speed of 45 degrees
    """
    # Setup
    theta = 45
    speed = 0

    # Exercise
    u_calc, v_calc = meteogram.convert_to_wind_components(theta=theta,
                                                          speed=speed)

    # Verify
    u_desired = 0
    v_desired = 0
    assert_almost_equal(u_calc, u_desired)
    assert_almost_equal(v_calc, v_desired)
def test_wind_components_north() -> None:
    """Ensure correct results when testing wind coming from 0 degrees
    """
    # Setup
    theta = 0
    speed = 1

    # Exercise
    u_calc, v_calc = meteogram.convert_to_wind_components(theta=theta,
                                                          speed=speed)

    # Verify
    u_desired = 0
    v_desired = -1
    assert_almost_equal(u_calc, u_desired)
    assert_almost_equal(v_calc, v_desired)
def test_wind_components() -> None:
    """Test wind components in a loop
    
    This makes all the previous tests irrelevant, and still isn't great
    """
    # Setup
    speed = np.array([10, 10, 10, 0])
    direction = np.array([0, 45, 360, 45])

    # Exercise
    u, v = meteogram.convert_to_wind_components(theta=direction, speed=speed)

    # Verify
    true_u = np.array([0, -7.0701, 0, 0])
    true_v = np.array([-10, -7.0701, -10, 0])
    assert_array_almost_equal(u, true_u, 3)
    assert_array_almost_equal(v, true_v, 3)