Skip to content

Commit

Permalink
Merge pull request #1722 from dtcenter/feature_1402_config_cleanup_mo…
Browse files Browse the repository at this point in the history
…del_app

Feature #1402 config cleanup model applications
  • Loading branch information
hankenstein2 authored Aug 3, 2022
2 parents a3fcc80 + 748c098 commit a585524
Show file tree
Hide file tree
Showing 77 changed files with 3,957 additions and 5,421 deletions.
5 changes: 5 additions & 0 deletions docs/Users_Guide/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9648,3 +9648,8 @@ METplus Configuration Glossary
Set the resolution for CyclonePlotter output.

| *Used by:* CyclonePlotter
TC_PAIRS_MATCH_POINTS
Specify the value for 'match_points' in the MET configuration file for TCPairs.

| *Used by:* TCPairs
12 changes: 12 additions & 0 deletions docs/Users_Guide/wrappers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7829,6 +7829,7 @@ METplus Configuration
| :term:`TC_PAIRS_RUN_ONCE`
| :term:`TC_PAIRS_CHECK_DUP`
| :term:`TC_PAIRS_INTERP12`
| :term:`TC_PAIRS_MATCH_POINTS`
|
.. warning:: **DEPRECATED:**
Expand Down Expand Up @@ -8039,6 +8040,17 @@ see :ref:`How METplus controls MET config file settings<metplus-control-met>`.
* - :term:`TC_PAIRS_VALID_END`
- valid_end

**${METPLUS_MATCH_POINTS}**

.. list-table::
:widths: 5 5
:header-rows: 0

* - METplus Config(s)
- MET Config File
* - :term:`TC_PAIRS_MATCH_POINTS`
- match_points

**${METPLUS_DLAND_FILE}**

.. list-table::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# and Ice Mapping System (IMS) and the National Centers for Environmental Prediction (NCEP)
# sea ice analysis. This is a validation and diagnostics use case because it is limited to a
# comparison between IMS analysis to NCEP analysis.
# Written by Lindsay Blank, NCAR. January 2020

####################################################################################################
# Datasets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,9 @@ def test_tc_pairs_storm_id_lists(metplus_config, config_overrides,
# 19: interp12
({'TC_PAIRS_INTERP12': 'replace', },
{'METPLUS_INTERP12': 'interp12 = REPLACE;'}),
# 20 match_points
({'TC_PAIRS_MATCH_POINTS': 'False', },
{'METPLUS_MATCH_POINTS': 'match_points = FALSE;'}),
]
)
Expand All @@ -386,7 +389,7 @@ def test_tc_pairs_loop_order_processes(metplus_config, config_overrides,
env_var_values):
# run using init and valid time variables
for loop_by in ['INIT', 'VALID']:
remove_beg = remove_end = False
remove_beg = remove_end = remove_match_points = False
config = metplus_config()

set_minimum_config_settings(config, loop_by)
Expand Down Expand Up @@ -420,6 +423,12 @@ def test_tc_pairs_loop_order_processes(metplus_config, config_overrides,
)
remove_end = True

if f'METPLUS_MATCH_POINTS' not in env_var_values:
env_var_values[f'METPLUS_MATCH_POINTS'] = (
'match_points = TRUE;'
)
remove_match_points = True

wrapper = TCPairsWrapper(config)
assert wrapper.isOK

Expand Down Expand Up @@ -456,6 +465,8 @@ def test_tc_pairs_loop_order_processes(metplus_config, config_overrides,
del env_var_values[f'METPLUS_{loop_by}_BEG']
if remove_end:
del env_var_values[f'METPLUS_{loop_by}_END']
if remove_match_points:
del env_var_values['METPLUS_MATCH_POINTS']


@pytest.mark.parametrize(
Expand Down Expand Up @@ -510,6 +521,10 @@ def test_tc_pairs_read_all_files(metplus_config, config_overrides,
f'{loop_by.lower()}_end = "{run_times[-1]}";'
)

env_var_values['METPLUS_MATCH_POINTS'] = (
'match_points = TRUE;'
)

wrapper = TCPairsWrapper(config)
assert wrapper.isOK

Expand Down
5 changes: 3 additions & 2 deletions metplus/util/config_metplus.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ def check_default(self, sec, name, default):
raise

# print debug message saying default value was used
if not default:
if default == '':
default_text = 'empty string'
else:
default_text = default
Expand Down Expand Up @@ -1766,7 +1766,8 @@ def skip_field_info_validation(config):
process_list = [item[0] for item in get_process_list(config)]

# if running MTD in single mode, you don't need matching FCST/OBS
if 'MTD' in process_list and config.getbool('config', 'MTD_SINGLE_RUN'):
if ('MTD' in process_list and
config.getbool('config', 'MTD_SINGLE_RUN', False)):
return True

# if running any app other than the reformatters, you need matching FCST/OBS, so don't skip
Expand Down
5 changes: 5 additions & 0 deletions metplus/util/diff_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ def compare_dir(dir_a, dir_b, debug=False, save_diff=False):

for filename in files:
filepath_b = os.path.join(root, filename)

# skip metplus_final.conf
if filepath_b.endswith('metplus_final.conf'):
continue

filepath_a = filepath_b.replace(dir_b, dir_a)
if not os.path.exists(filepath_a):
# check if missing file is actually diff file that was generated
Expand Down
20 changes: 8 additions & 12 deletions metplus/wrappers/cyclone_plotter_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,37 +134,33 @@ def __init__(self, config, instance=None):
else:
self.logger.debug("Getting lons and lats that define the plot's extent")
west_lon = (self.config.getstr('config',
'CYCLONE_PLOTTER_WEST_LON')
'CYCLONE_PLOTTER_WEST_LON', '')
)
east_lon = (self.config.getstr('config',
'CYCLONE_PLOTTER_EAST_LON')
'CYCLONE_PLOTTER_EAST_LON', '')
)
north_lat = (self.config.getstr('config',
'CYCLONE_PLOTTER_NORTH_LAT')
'CYCLONE_PLOTTER_NORTH_LAT', '')
)
south_lat = (self.config.getstr('config',
'CYCLONE_PLOTTER_SOUTH_LAT')
'CYCLONE_PLOTTER_SOUTH_LAT', '')
)

# Check for unconfigured lons and lats needed for defining the extent
if not west_lon:
self.logger.error("Missing CYCLONE_PLOTTER_WEST_LON in config file. ")
sys.exit("Missing the CYCLONE_PLOTTER_WEST_LON please check config file")
self.log_error("Missing CYCLONE_PLOTTER_WEST_LON in config file. ")
else:
self.west_lon = (float(west_lon))
if not east_lon:
self.logger.error("Missing CYCLONE_PLOTTER_EAST_LON in config file. ")
sys.exit("Missing the CYCLONE_PLOTTER_EAST_LON please check config file")
self.log_error("Missing CYCLONE_PLOTTER_EAST_LON in config file. ")
else:
self.east_lon = (float(east_lon))
if not south_lat:
self.logger.error("Missing CYCLONE_PLOTTER_SOUTH_LAT in config file. ")
sys.exit("Missing the CYCLONE_PLOTTER_SOUTH_LAT please check config file")
self.log_error("Missing CYCLONE_PLOTTER_SOUTH_LAT in config file. ")
else:
self.south_lat = float(south_lat)
if not north_lat:
self.logger.error("Missing CYCLONE_PLOTTER_NORTH_LAT in config file. ")
sys.exit("Missing the CYCLONE_PLOTTER_NORTH_LAT please check config file")
self.log_error("Missing CYCLONE_PLOTTER_NORTH_LAT in config file. ")
else:
self.north_lat = float(north_lat)

Expand Down
7 changes: 7 additions & 0 deletions metplus/wrappers/tc_pairs_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class TCPairsWrapper(CommandBuilder):
'METPLUS_VALID_EXC',
'METPLUS_CHECK_DUP',
'METPLUS_INTERP12',
'METPLUS_MATCH_POINTS',
]

WILDCARDS = {
Expand Down Expand Up @@ -177,6 +178,12 @@ def create_c_dict(self):
extra_args={'remove_quotes': True,
'uppercase': True})

self.add_met_config(name='match_points', data_type='bool')

# if unset, set match_points to TRUE to match old default in wrapped
if not self.env_var_dict.get('METPLUS_MATCH_POINTS'):
self.env_var_dict['METPLUS_MATCH_POINTS'] = 'match_points = TRUE;'

c_dict['INIT_INCLUDE'] = getlist(
self.get_wrapper_or_generic_config('INIT_INCLUDE')
)
Expand Down
3 changes: 2 additions & 1 deletion parm/met_config/TCPairsConfig_wrapped
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ anly_track = BDECK;
// Specify if only those track points common to both the ADECK and BDECK
// tracks be written out.
//
match_points = TRUE;
//match_points =
${METPLUS_MATCH_POINTS}

//
// Specify the NetCDF output of the gen_dland tool containing a gridded
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,5 @@ TC_PAIRS_MISSING_VAL = -9999
#TC_PAIRS_CHECK_DUP =

#TC_PAIRS_INTERP12 =

#TC_PAIRS_MATCH_POINTS =
2 changes: 2 additions & 0 deletions parm/use_cases/met_tool_wrapper/TCPairs/TCPairs_tropical.conf
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,5 @@ TC_PAIRS_DLAND_FILE = MET_BASE/tc_data/dland_global_tenth_degree.nc
#TC_PAIRS_CHECK_DUP =

#TC_PAIRS_INTERP12 =

#TC_PAIRS_MATCH_POINTS =
Loading

0 comments on commit a585524

Please sign in to comment.