Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix #2006 (develop) Fix priority of obs_window config variables #2062

Merged
merged 1 commit into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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