Exemplo n.º 1
0
def test_format_thresh():
    # Independently test the formatting
    # of thresholds
    # Test 1
    thresh = '>=5'
    expected_thresh_symbol = '>=5'
    expected_thresh_letter = 'ge5'
    test_thresh_symbol, test_thresh_letter = plot_util.format_thresh(thresh)
    assert (test_thresh_symbol == expected_thresh_symbol)
    assert (test_thresh_letter == expected_thresh_letter)
    # Test 2
    thresh = 'ge5'
    expected_thresh_symbol = '>=5'
    expected_thresh_letter = 'ge5'
    test_thresh_symbol, test_thresh_letter = plot_util.format_thresh(thresh)
    assert (test_thresh_symbol == expected_thresh_symbol)
    assert (test_thresh_letter == expected_thresh_letter)
    # Test 3
    thresh = '>15'
    expected_thresh_symbol = '>15'
    expected_thresh_letter = 'gt15'
    test_thresh_symbol, test_thresh_letter = plot_util.format_thresh(thresh)
    assert (test_thresh_symbol == expected_thresh_symbol)
    assert (test_thresh_letter == expected_thresh_letter)
    # Test 4
    thresh = 'gt15'
    expected_thresh_symbol = '>15'
    expected_thresh_letter = 'gt15'
    test_thresh_symbol, test_thresh_letter = plot_util.format_thresh(thresh)
    assert (test_thresh_symbol == expected_thresh_symbol)
    assert (test_thresh_letter == expected_thresh_letter)
    # Test 5
    thresh = '==1'
    expected_thresh_symbol = '==1'
    expected_thresh_letter = 'eq1'
    test_thresh_symbol, test_thresh_letter = plot_util.format_thresh(thresh)
    assert (test_thresh_symbol == expected_thresh_symbol)
    assert (test_thresh_letter == expected_thresh_letter)
    # Test 6
    thresh = 'eq1'
    expected_thresh_symbol = '==1'
    expected_thresh_letter = 'eq1'
    test_thresh_symbol, test_thresh_letter = plot_util.format_thresh(thresh)
    assert (test_thresh_symbol == expected_thresh_symbol)
    assert (test_thresh_letter == expected_thresh_letter)
    # Test 7
    thresh = '!=0.5'
    expected_thresh_symbol = '!=0.5'
    expected_thresh_letter = 'ne0.5'
    test_thresh_symbol, test_thresh_letter = plot_util.format_thresh(thresh)
    assert (test_thresh_symbol == expected_thresh_symbol)
    assert (test_thresh_letter == expected_thresh_letter)
    # Test 8
    thresh = 'ne0.5'
    expected_thresh_symbol = '!=0.5'
    expected_thresh_letter = 'ne0.5'
    test_thresh_symbol, test_thresh_letter = plot_util.format_thresh(thresh)
    assert (test_thresh_symbol == expected_thresh_symbol)
    assert (test_thresh_letter == expected_thresh_letter)
    # Test 9
    thresh = '<=1000'
    expected_thresh_symbol = '<=1000'
    expected_thresh_letter = 'le1000'
    test_thresh_symbol, test_thresh_letter = plot_util.format_thresh(thresh)
    assert (test_thresh_symbol == expected_thresh_symbol)
    assert (test_thresh_letter == expected_thresh_letter)
    # Test 10
    thresh = 'le1000'
    expected_thresh_symbol = '<=1000'
    expected_thresh_letter = 'le1000'
    test_thresh_symbol, test_thresh_letter = plot_util.format_thresh(thresh)
    assert (test_thresh_symbol == expected_thresh_symbol)
    assert (test_thresh_letter == expected_thresh_letter)
    # Test 11
    thresh = '<0.001'
    expected_thresh_symbol = '<0.001'
    expected_thresh_letter = 'lt0.001'
    test_thresh_symbol, test_thresh_letter = plot_util.format_thresh(thresh)
    assert (test_thresh_symbol == expected_thresh_symbol)
    assert (test_thresh_letter == expected_thresh_letter)
    # Test 12
    thresh = 'lt0.001'
    expected_thresh_symbol = '<0.001'
    expected_thresh_letter = 'lt0.001'
    test_thresh_symbol, test_thresh_letter = plot_util.format_thresh(thresh)
    assert (test_thresh_symbol == expected_thresh_symbol)
    assert (test_thresh_letter == expected_thresh_letter)
Exemplo n.º 2
0
stat_file_base_columns = plot_util.get_stat_file_base_columns(met_version)
nbase_columns = len(stat_file_base_columns)

# Start looping to make plots
for plot_info in plot_info_list:
    fcst_lead = plot_info[0]
    fcst_var_levels = plot_info[1]
    obs_var_levels = obs_var_level_list[
        fcst_var_level_list.index(fcst_var_levels)
    ]
    fcst_var_thresh = plot_info[2]
    obs_var_thresh = obs_var_thresh_list[
        fcst_var_thresh_list.index(fcst_var_thresh)
    ]
    fcst_var_thresh_symbol, fcst_var_thresh_letter = plot_util.format_thresh(
        fcst_var_thresh
    )
    obs_var_thresh_symbol, obs_var_thresh_letter = plot_util.format_thresh(
        obs_var_thresh
    )
    # Build plot title for variable info
    fcst_var_plot_title = 'Fcst: '+fcst_var_name
    obs_var_plot_title = 'Obs: '+obs_var_name
    if 'WV1' in interp_mthd:
        fcst_var_plot_title+=' '+interp_mthd
        obs_var_plot_title+=' '+interp_mthd 
    if fcst_var_thresh != '':
        fcst_var_plot_title+=' '+fcst_var_thresh
    if obs_var_thresh != '':
        obs_var_plot_title+=' '+obs_var_thresh
    if fcst_var_units == '':