From 081f73f586c127b5df9f676facbb80f2b9bf4b67 Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Fri, 11 Mar 2022 13:10:16 -0700 Subject: [PATCH] bugfix 1486 pb2nc window variables (#1507) --- internal_tests/pytests/pb2nc/test_pb2nc_wrapper.py | 6 ++++++ metplus/util/met_config.py | 6 ++++++ metplus/wrappers/command_builder.py | 2 ++ 3 files changed, 14 insertions(+) diff --git a/internal_tests/pytests/pb2nc/test_pb2nc_wrapper.py b/internal_tests/pytests/pb2nc/test_pb2nc_wrapper.py index 2b7e9ed0fa..909baa88d4 100644 --- a/internal_tests/pytests/pb2nc/test_pb2nc_wrapper.py +++ b/internal_tests/pytests/pb2nc/test_pb2nc_wrapper.py @@ -189,6 +189,12 @@ def test_find_input_files(metplus_config, offsets, offset_to_find): 'OBS_PB2NC_WINDOW_END': '1800', }, {'METPLUS_OBS_WINDOW_DICT': 'obs_window = {beg = -1800;end = 1800;}'}), + # test legacy PB2NC_WINDOW_[BEGIN/END] + ({'PB2NC_WINDOW_BEGIN': '-1800', }, + {'METPLUS_OBS_WINDOW_DICT': 'obs_window = {beg = -1800;}'}), + + ({'PB2NC_WINDOW_END': '1800', }, + {'METPLUS_OBS_WINDOW_DICT': 'obs_window = {end = 1800;}'}), ({'PB2NC_MASK_GRID': 'FULL', }, {'METPLUS_MASK_DICT': 'mask = {grid = "FULL";}'}), diff --git a/metplus/util/met_config.py b/metplus/util/met_config.py index 55e753883d..2b99e54101 100644 --- a/metplus/util/met_config.py +++ b/metplus/util/met_config.py @@ -165,6 +165,12 @@ def add_met_config_dict(config, app_name, output_dict, dict_name, items): 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() + ) + # also add OBS_WINDOW_[BEGIN/END] metplus_configs.append(f"OBS_WINDOW_{suffix}") diff --git a/metplus/wrappers/command_builder.py b/metplus/wrappers/command_builder.py index 29214acfc2..c0c7d0475e 100755 --- a/metplus/wrappers/command_builder.py +++ b/metplus/wrappers/command_builder.py @@ -328,9 +328,11 @@ def handle_obs_window_legacy(self, c_dict): ('END', 5400)] app = self.app_name.upper() + # check {app}_WINDOW_{edge} to support PB2NC_WINDOW_[BEGIN/END] for edge, default_val in edges: input_list = [f'OBS_{app}_WINDOW_{edge}', f'{app}_OBS_WINDOW_{edge}', + f'{app}_WINDOW_{edge}', f'OBS_WINDOW_{edge}', ] output_key = f'OBS_WINDOW_{edge}'