From 48b8e59459c4db3a4f185f25007610639a03486b Mon Sep 17 00:00:00 2001 From: Sam Gardner Date: Tue, 14 Nov 2023 17:51:11 -0600 Subject: [PATCH] don't conglomerate tests --- tests/calc/test_indices.py | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/tests/calc/test_indices.py b/tests/calc/test_indices.py index 6fbace61136..361edcd3dbd 100644 --- a/tests/calc/test_indices.py +++ b/tests/calc/test_indices.py @@ -185,6 +185,10 @@ def test_corfidi_motion(): 38.32734963, -11.90040377] * units('kt') assert_almost_equal(motion_full.flatten(), truth_full, 8) + +def test_corfidi_motion_override_llj(): + """Test corfidi MCS motion with overridden LLJ""" + data = get_upper_air_data(datetime(2016, 5, 22, 0), 'DDC') motion_override = concatenate(corfidi_storm_motion(data['pressure'], data['u_wind'], data['v_wind'], u_llj=0 * units('kt'), @@ -193,15 +197,35 @@ def test_corfidi_motion(): 35.45121012, 20.97402126] * units('kt') assert_almost_equal(motion_override.flatten(), truth_override, 8) + with pytest.raises(ValueError): + corfidi_storm_motion(data['pressure'], data['u_wind'], + data['v_wind'], u_llj=10 * units('kt')) + + with pytest.raises(ValueError): + corfidi_storm_motion(data['pressure'], data['u_wind'], + data['v_wind'], v_llj=10 * units('kt')) + + +def test_corfidi_corfidi_llj_unaivalable(): + """Test corfidi MCS motion where the LLJ is unailable.""" + data = get_upper_air_data(datetime(2016, 5, 22, 0), 'DDC') with pytest.raises(ValueError): corfidi_storm_motion(data['pressure'][6:], data['u_wind'][6:], data['v_wind'][6:]) + +def test_corfidi_corfidi_cloudlayer_trimmed(): + """Test corfidi MCS motion where sounding does not include the entire cloud layer.""" + data = get_upper_air_data(datetime(2016, 5, 22, 0), 'DDC') motion_no_top = concatenate(corfidi_storm_motion(data['pressure'][:37], data['u_wind'][:37], data['v_wind'][:37])) truth_no_top = [20.40419260, -21.43467629, 37.93224569, -9.99492754] * units('kt') assert_almost_equal(motion_no_top.flatten(), truth_no_top, 8) + +def test_corfidi_motion_with_nans(): + """Test corfidi MCS motion with observed sounding with nans.""" + data = get_upper_air_data(datetime(2016, 5, 22, 0), 'DDC') u_with_nans = data['u_wind'] u_with_nans[6:10] = np.nan v_with_nans = data['v_wind'] @@ -212,14 +236,6 @@ def test_corfidi_motion(): 37.14543575, -12.42974709] * units('kt') assert_almost_equal(motion_with_nans.flatten(), truth_with_nans, 8) - with pytest.raises(ValueError): - corfidi_storm_motion(data['pressure'], data['u_wind'], - data['v_wind'], u_llj=10 * units('kt')) - - with pytest.raises(ValueError): - corfidi_storm_motion(data['pressure'], data['u_wind'], - data['v_wind'], v_llj=10 * units('kt')) - def test_bunkers_motion_with_nans(): """Test Bunkers storm motion with observed sounding."""