Skip to content

Commit

Permalink
per #2006, fix priority of obs_window config variables so that wrappe…
Browse files Browse the repository at this point in the history
…r-specific version is preferred over generic OBS_WINDOW_BEGIN/END
  • Loading branch information
georgemccabe committed Feb 27, 2023
1 parent f383f79 commit 01ff8cc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,18 @@ def test_met_dictionary_in_var_options(metplus_config):
'OBS_WINDOW_BEGIN': '-2700',
'OBS_WINDOW_END': '2700'
}),
# test that {app}_OBS_WINDOW are preferred over
# OBS_{app}_WINDOW and generic OBS_WINDOW
({'OBS_POINT_STAT_WINDOW_BEGIN': '-2700',
'OBS_POINT_STAT_WINDOW_END': '2700',
'POINT_STAT_OBS_WINDOW_BEGIN': '-1800',
'POINT_STAT_OBS_WINDOW_END': '1800',
'OBS_WINDOW_BEGIN': '-900',
'OBS_WINDOW_END': '900',
},
{'METPLUS_OBS_WINDOW_DICT':
'obs_window = {beg = -1800;end = 1800;}',
}),
({'POINT_STAT_CLIMO_CDF_CDF_BINS': '1', },
{'METPLUS_CLIMO_CDF_DICT': 'climo_cdf = {cdf_bins = 1.0;}'}),
Expand Down
26 changes: 15 additions & 11 deletions metplus/util/met_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,28 +165,32 @@ def add_met_config_dict(config, app_name, output_dict, dict_name, items):

if 'dict' not in data_type:
children = None
# handle legacy OBS_WINDOW variables that put OBS_ before app name
# i.e. OBS_GRID_STAT_WINDOW_[BEGIN/END]
metplus_configs.append(metplus_name)

# if variable ends with _BEG, read _BEGIN first
if metplus_name.endswith('BEG'):
metplus_configs.append(f'{metplus_name}IN')

if dict_name == 'obs_window':
suffix = 'BEGIN' if name == 'beg' else name.upper()

# handle legacy OBS_WINDOW variables that put OBS_ before
# app name i.e. OBS_GRID_STAT_WINDOW_[BEGIN/END]
metplus_configs.append(
f"OBS_{app_name}_WINDOW_{suffix}".upper()
)

# also add support for legacy PB2NC_WINDOW_[BEGIN/END]
metplus_configs.append(
f"{app_name}_WINDOW_{suffix}".upper()
)
if app_name.lower() == 'pb2nc':
metplus_configs.append(
f"{app_name}_WINDOW_{suffix}".upper()
)

# also add OBS_WINDOW_[BEGIN/END]
metplus_configs.append(f"OBS_WINDOW_{suffix}")

# if variable ends with _BEG, read _BEGIN first
if metplus_name.endswith('BEG'):
metplus_configs.append(f'{metplus_name}IN')
metplus_configs.append(f"{dict_name}_{name}".upper())
if name == 'beg':
metplus_configs.append(f"{dict_name}_{name}IN".upper())

metplus_configs.append(metplus_name)
# add other variable names to search if expected name is unset
if nicknames:
for nickname in nicknames:
Expand Down

0 comments on commit 01ff8cc

Please sign in to comment.