diff --git a/internal_tests/pytests/ensemble_stat/test_ensemble_stat_wrapper.py b/internal_tests/pytests/ensemble_stat/test_ensemble_stat_wrapper.py index b1bfa40b25..9d9fd28497 100644 --- a/internal_tests/pytests/ensemble_stat/test_ensemble_stat_wrapper.py +++ b/internal_tests/pytests/ensemble_stat/test_ensemble_stat_wrapper.py @@ -376,8 +376,8 @@ def test_handle_climo_file_variables(metplus_config, config_overrides, '["/some/climo_mean/file.txt"];}'), 'CLIMO_MEAN_FILE': '"/some/climo_mean/file.txt"'}), - ({'ENSEMBLE_STAT_CLIMO_MEAN_FIELD': 'CLM_NAME', }, - {'METPLUS_CLIMO_MEAN_DICT': 'climo_mean = {field = ["CLM_NAME"];}'}), + ({'ENSEMBLE_STAT_CLIMO_MEAN_FIELD': '{name="CLM_NAME"; level="(0,0,*,*)";}', }, + {'METPLUS_CLIMO_MEAN_DICT': 'climo_mean = {field = [{name="CLM_NAME"; level="(0,0,*,*)";}];}'}), ({'ENSEMBLE_STAT_CLIMO_MEAN_REGRID_METHOD': 'NEAREST', }, {'METPLUS_CLIMO_MEAN_DICT': 'climo_mean = {regrid = {method = NEAREST;}}'}), @@ -407,7 +407,7 @@ def test_handle_climo_file_variables(metplus_config, config_overrides, ({ 'ENSEMBLE_STAT_CLIMO_MEAN_FILE_NAME': '/some/climo_mean/file.txt', - 'ENSEMBLE_STAT_CLIMO_MEAN_FIELD': 'CLM_NAME', + 'ENSEMBLE_STAT_CLIMO_MEAN_FIELD': '{name="CLM_NAME"; level="(0,0,*,*)";}', 'ENSEMBLE_STAT_CLIMO_MEAN_REGRID_METHOD': 'NEAREST', 'ENSEMBLE_STAT_CLIMO_MEAN_REGRID_WIDTH': '1', 'ENSEMBLE_STAT_CLIMO_MEAN_REGRID_VLD_THRESH': '0.5', @@ -419,7 +419,7 @@ def test_handle_climo_file_variables(metplus_config, config_overrides, }, {'METPLUS_CLIMO_MEAN_DICT': ('climo_mean = {file_name = ' '["/some/climo_mean/file.txt"];' - 'field = ["CLM_NAME"];' + 'field = [{name="CLM_NAME"; level="(0,0,*,*)";}];' 'regrid = {method = NEAREST;width = 1;' 'vld_thresh = 0.5;shape = SQUARE;}' 'time_interp_method = NEAREST;' @@ -433,8 +433,8 @@ def test_handle_climo_file_variables(metplus_config, config_overrides, '["/some/climo_stdev/file.txt"];}'), 'CLIMO_STDEV_FILE': '"/some/climo_stdev/file.txt"'}), - ({'ENSEMBLE_STAT_CLIMO_STDEV_FIELD': 'CLM_NAME', }, - {'METPLUS_CLIMO_STDEV_DICT': 'climo_stdev = {field = ["CLM_NAME"];}'}), + ({'ENSEMBLE_STAT_CLIMO_STDEV_FIELD': '{name="CLM_NAME"; level="(0,0,*,*)";}', }, + {'METPLUS_CLIMO_STDEV_DICT': 'climo_stdev = {field = [{name="CLM_NAME"; level="(0,0,*,*)";}];}'}), ({'ENSEMBLE_STAT_CLIMO_STDEV_REGRID_METHOD': 'NEAREST', }, { @@ -466,7 +466,7 @@ def test_handle_climo_file_variables(metplus_config, config_overrides, ({ 'ENSEMBLE_STAT_CLIMO_STDEV_FILE_NAME': '/some/climo_stdev/file.txt', - 'ENSEMBLE_STAT_CLIMO_STDEV_FIELD': 'CLM_NAME', + 'ENSEMBLE_STAT_CLIMO_STDEV_FIELD': '{name="CLM_NAME"; level="(0,0,*,*)";}', 'ENSEMBLE_STAT_CLIMO_STDEV_REGRID_METHOD': 'NEAREST', 'ENSEMBLE_STAT_CLIMO_STDEV_REGRID_WIDTH': '1', 'ENSEMBLE_STAT_CLIMO_STDEV_REGRID_VLD_THRESH': '0.5', @@ -478,7 +478,7 @@ def test_handle_climo_file_variables(metplus_config, config_overrides, }, {'METPLUS_CLIMO_STDEV_DICT': ('climo_stdev = {file_name = ' '["/some/climo_stdev/file.txt"];' - 'field = ["CLM_NAME"];' + 'field = [{name="CLM_NAME"; level="(0,0,*,*)";}];' 'regrid = {method = NEAREST;width = 1;' 'vld_thresh = 0.5;shape = SQUARE;}' 'time_interp_method = NEAREST;' diff --git a/internal_tests/pytests/grid_stat/test_grid_stat_wrapper.py b/internal_tests/pytests/grid_stat/test_grid_stat_wrapper.py index 00420bdd55..522887abb4 100644 --- a/internal_tests/pytests/grid_stat/test_grid_stat_wrapper.py +++ b/internal_tests/pytests/grid_stat/test_grid_stat_wrapper.py @@ -421,8 +421,8 @@ def test_handle_climo_file_variables(metplus_config, config_overrides, '["/some/climo_mean/file.txt"];}'), 'CLIMO_MEAN_FILE': '"/some/climo_mean/file.txt"'}), - ({'GRID_STAT_CLIMO_MEAN_FIELD': 'CLM_NAME', }, - {'METPLUS_CLIMO_MEAN_DICT': 'climo_mean = {field = ["CLM_NAME"];}'}), + ({'GRID_STAT_CLIMO_MEAN_FIELD': '{name="CLM_NAME"; level="(0,0,*,*)";}', }, + {'METPLUS_CLIMO_MEAN_DICT': 'climo_mean = {field = [{name="CLM_NAME"; level="(0,0,*,*)";}];}'}), ({'GRID_STAT_CLIMO_MEAN_REGRID_METHOD': 'NEAREST', }, {'METPLUS_CLIMO_MEAN_DICT': 'climo_mean = {regrid = {method = NEAREST;}}'}), @@ -452,7 +452,7 @@ def test_handle_climo_file_variables(metplus_config, config_overrides, ({ 'GRID_STAT_CLIMO_MEAN_FILE_NAME': '/some/climo_mean/file.txt', - 'GRID_STAT_CLIMO_MEAN_FIELD': 'CLM_NAME', + 'GRID_STAT_CLIMO_MEAN_FIELD': '{name="CLM_NAME"; level="(0,0,*,*)";}', 'GRID_STAT_CLIMO_MEAN_REGRID_METHOD': 'NEAREST', 'GRID_STAT_CLIMO_MEAN_REGRID_WIDTH': '1', 'GRID_STAT_CLIMO_MEAN_REGRID_VLD_THRESH': '0.5', @@ -464,7 +464,7 @@ def test_handle_climo_file_variables(metplus_config, config_overrides, }, {'METPLUS_CLIMO_MEAN_DICT': ('climo_mean = {file_name = ' '["/some/climo_mean/file.txt"];' - 'field = ["CLM_NAME"];' + 'field = [{name="CLM_NAME"; level="(0,0,*,*)";}];' 'regrid = {method = NEAREST;width = 1;' 'vld_thresh = 0.5;shape = SQUARE;}' 'time_interp_method = NEAREST;' @@ -478,8 +478,8 @@ def test_handle_climo_file_variables(metplus_config, config_overrides, '["/some/climo_stdev/file.txt"];}'), 'CLIMO_STDEV_FILE': '"/some/climo_stdev/file.txt"'}), - ({'GRID_STAT_CLIMO_STDEV_FIELD': 'CLM_NAME', }, - {'METPLUS_CLIMO_STDEV_DICT': 'climo_stdev = {field = ["CLM_NAME"];}'}), + ({'GRID_STAT_CLIMO_STDEV_FIELD': '{name="CLM_NAME"; level="(0,0,*,*)";}', }, + {'METPLUS_CLIMO_STDEV_DICT': 'climo_stdev = {field = [{name="CLM_NAME"; level="(0,0,*,*)";}];}'}), ({'GRID_STAT_CLIMO_STDEV_REGRID_METHOD': 'NEAREST', }, { @@ -511,7 +511,7 @@ def test_handle_climo_file_variables(metplus_config, config_overrides, ({ 'GRID_STAT_CLIMO_STDEV_FILE_NAME': '/some/climo_stdev/file.txt', - 'GRID_STAT_CLIMO_STDEV_FIELD': 'CLM_NAME', + 'GRID_STAT_CLIMO_STDEV_FIELD': '{name="CLM_NAME"; level="(0,0,*,*)";}', 'GRID_STAT_CLIMO_STDEV_REGRID_METHOD': 'NEAREST', 'GRID_STAT_CLIMO_STDEV_REGRID_WIDTH': '1', 'GRID_STAT_CLIMO_STDEV_REGRID_VLD_THRESH': '0.5', @@ -523,7 +523,7 @@ def test_handle_climo_file_variables(metplus_config, config_overrides, }, {'METPLUS_CLIMO_STDEV_DICT': ('climo_stdev = {file_name = ' '["/some/climo_stdev/file.txt"];' - 'field = ["CLM_NAME"];' + 'field = [{name="CLM_NAME"; level="(0,0,*,*)";}];' 'regrid = {method = NEAREST;width = 1;' 'vld_thresh = 0.5;shape = SQUARE;}' 'time_interp_method = NEAREST;' diff --git a/internal_tests/pytests/point_stat/test_point_stat_wrapper.py b/internal_tests/pytests/point_stat/test_point_stat_wrapper.py index f783182362..4867dc9b24 100755 --- a/internal_tests/pytests/point_stat/test_point_stat_wrapper.py +++ b/internal_tests/pytests/point_stat/test_point_stat_wrapper.py @@ -290,8 +290,8 @@ def test_met_dictionary_in_var_options(metplus_config): '["/some/climo_mean/file.txt"];}'), 'CLIMO_MEAN_FILE': '"/some/climo_mean/file.txt"'}), - ({'POINT_STAT_CLIMO_MEAN_FIELD': 'CLM_NAME', }, - {'METPLUS_CLIMO_MEAN_DICT': 'climo_mean = {field = ["CLM_NAME"];}'}), + ({'POINT_STAT_CLIMO_MEAN_FIELD': '{name="CLM_NAME"; level="(0,0,*,*)";}', }, + {'METPLUS_CLIMO_MEAN_DICT': 'climo_mean = {field = [{name="CLM_NAME"; level="(0,0,*,*)";}];}'}), ({'POINT_STAT_CLIMO_MEAN_REGRID_METHOD': 'NEAREST', }, { @@ -323,7 +323,7 @@ def test_met_dictionary_in_var_options(metplus_config): ({ 'POINT_STAT_CLIMO_MEAN_FILE_NAME': '/some/climo_mean/file.txt', - 'POINT_STAT_CLIMO_MEAN_FIELD': 'CLM_NAME', + 'POINT_STAT_CLIMO_MEAN_FIELD': '{name="CLM_NAME"; level="(0,0,*,*)";}', 'POINT_STAT_CLIMO_MEAN_REGRID_METHOD': 'NEAREST', 'POINT_STAT_CLIMO_MEAN_REGRID_WIDTH': '1', 'POINT_STAT_CLIMO_MEAN_REGRID_VLD_THRESH': '0.5', @@ -335,7 +335,7 @@ def test_met_dictionary_in_var_options(metplus_config): }, {'METPLUS_CLIMO_MEAN_DICT': ('climo_mean = {file_name = ' '["/some/climo_mean/file.txt"];' - 'field = ["CLM_NAME"];' + 'field = [{name="CLM_NAME"; level="(0,0,*,*)";}];' 'regrid = {method = NEAREST;width = 1;' 'vld_thresh = 0.5;shape = SQUARE;}' 'time_interp_method = NEAREST;' @@ -349,9 +349,9 @@ def test_met_dictionary_in_var_options(metplus_config): '["/some/climo_stdev/file.txt"];}'), 'CLIMO_STDEV_FILE': '"/some/climo_stdev/file.txt"'}), - ({'POINT_STAT_CLIMO_STDEV_FIELD': 'CLM_NAME', }, + ({'POINT_STAT_CLIMO_STDEV_FIELD': '{name="CLM_NAME"; level="(0,0,*,*)";}', }, { - 'METPLUS_CLIMO_STDEV_DICT': 'climo_stdev = {field = ["CLM_NAME"];}'}), + 'METPLUS_CLIMO_STDEV_DICT': 'climo_stdev = {field = [{name="CLM_NAME"; level="(0,0,*,*)";}];}'}), ({'POINT_STAT_CLIMO_STDEV_REGRID_METHOD': 'NEAREST', }, { @@ -384,7 +384,7 @@ def test_met_dictionary_in_var_options(metplus_config): ({ 'POINT_STAT_CLIMO_STDEV_FILE_NAME': '/some/climo_stdev/file.txt', - 'POINT_STAT_CLIMO_STDEV_FIELD': 'CLM_NAME', + 'POINT_STAT_CLIMO_STDEV_FIELD': '{name="CLM_NAME"; level="(0,0,*,*)";}', 'POINT_STAT_CLIMO_STDEV_REGRID_METHOD': 'NEAREST', 'POINT_STAT_CLIMO_STDEV_REGRID_WIDTH': '1', 'POINT_STAT_CLIMO_STDEV_REGRID_VLD_THRESH': '0.5', @@ -396,7 +396,7 @@ def test_met_dictionary_in_var_options(metplus_config): }, {'METPLUS_CLIMO_STDEV_DICT': ('climo_stdev = {file_name = ' '["/some/climo_stdev/file.txt"];' - 'field = ["CLM_NAME"];' + 'field = [{name="CLM_NAME"; level="(0,0,*,*)";}];' 'regrid = {method = NEAREST;width = 1;' 'vld_thresh = 0.5;shape = SQUARE;}' 'time_interp_method = NEAREST;' diff --git a/internal_tests/pytests/series_analysis/test_series_analysis.py b/internal_tests/pytests/series_analysis/test_series_analysis.py index bcdf600670..904ec8130d 100644 --- a/internal_tests/pytests/series_analysis/test_series_analysis.py +++ b/internal_tests/pytests/series_analysis/test_series_analysis.py @@ -95,8 +95,8 @@ def set_minimum_config_settings(config): '["/some/climo_mean/file.txt"];}'), 'CLIMO_MEAN_FILE': '"/some/climo_mean/file.txt"'}), - ({'SERIES_ANALYSIS_CLIMO_MEAN_FIELD': 'CLM_NAME', }, - {'METPLUS_CLIMO_MEAN_DICT': 'climo_mean = {field = ["CLM_NAME"];}'}), + ({'SERIES_ANALYSIS_CLIMO_MEAN_FIELD': '{name="CLM_NAME"; level="(0,0,*,*)";}', }, + {'METPLUS_CLIMO_MEAN_DICT': 'climo_mean = {field = [{name="CLM_NAME"; level="(0,0,*,*)";}];}'}), ({'SERIES_ANALYSIS_CLIMO_MEAN_REGRID_METHOD': 'NEAREST', }, {'METPLUS_CLIMO_MEAN_DICT': 'climo_mean = {regrid = {method = NEAREST;}}'}), @@ -126,7 +126,7 @@ def set_minimum_config_settings(config): ({ 'SERIES_ANALYSIS_CLIMO_MEAN_FILE_NAME': '/some/climo_mean/file.txt', - 'SERIES_ANALYSIS_CLIMO_MEAN_FIELD': 'CLM_NAME', + 'SERIES_ANALYSIS_CLIMO_MEAN_FIELD': '{name="CLM_NAME"; level="(0,0,*,*)";}', 'SERIES_ANALYSIS_CLIMO_MEAN_REGRID_METHOD': 'NEAREST', 'SERIES_ANALYSIS_CLIMO_MEAN_REGRID_WIDTH': '1', 'SERIES_ANALYSIS_CLIMO_MEAN_REGRID_VLD_THRESH': '0.5', @@ -138,7 +138,7 @@ def set_minimum_config_settings(config): }, {'METPLUS_CLIMO_MEAN_DICT': ('climo_mean = {file_name = ' '["/some/climo_mean/file.txt"];' - 'field = ["CLM_NAME"];' + 'field = [{name="CLM_NAME"; level="(0,0,*,*)";}];' 'regrid = {method = NEAREST;width = 1;' 'vld_thresh = 0.5;shape = SQUARE;}' 'time_interp_method = NEAREST;' @@ -152,8 +152,8 @@ def set_minimum_config_settings(config): '["/some/climo_stdev/file.txt"];}'), 'CLIMO_STDEV_FILE': '"/some/climo_stdev/file.txt"'}), - ({'SERIES_ANALYSIS_CLIMO_STDEV_FIELD': 'CLM_NAME', }, - {'METPLUS_CLIMO_STDEV_DICT': 'climo_stdev = {field = ["CLM_NAME"];}'}), + ({'SERIES_ANALYSIS_CLIMO_STDEV_FIELD': '{name="CLM_NAME"; level="(0,0,*,*)";}', }, + {'METPLUS_CLIMO_STDEV_DICT': 'climo_stdev = {field = [{name="CLM_NAME"; level="(0,0,*,*)";}];}'}), ({'SERIES_ANALYSIS_CLIMO_STDEV_REGRID_METHOD': 'NEAREST', }, { @@ -185,7 +185,7 @@ def set_minimum_config_settings(config): ({ 'SERIES_ANALYSIS_CLIMO_STDEV_FILE_NAME': '/some/climo_stdev/file.txt', - 'SERIES_ANALYSIS_CLIMO_STDEV_FIELD': 'CLM_NAME', + 'SERIES_ANALYSIS_CLIMO_STDEV_FIELD': '{name="CLM_NAME"; level="(0,0,*,*)";}', 'SERIES_ANALYSIS_CLIMO_STDEV_REGRID_METHOD': 'NEAREST', 'SERIES_ANALYSIS_CLIMO_STDEV_REGRID_WIDTH': '1', 'SERIES_ANALYSIS_CLIMO_STDEV_REGRID_VLD_THRESH': '0.5', @@ -197,7 +197,7 @@ def set_minimum_config_settings(config): }, {'METPLUS_CLIMO_STDEV_DICT': ('climo_stdev = {file_name = ' '["/some/climo_stdev/file.txt"];' - 'field = ["CLM_NAME"];' + 'field = [{name="CLM_NAME"; level="(0,0,*,*)";}];' 'regrid = {method = NEAREST;width = 1;' 'vld_thresh = 0.5;shape = SQUARE;}' 'time_interp_method = NEAREST;' diff --git a/metplus/wrappers/command_builder.py b/metplus/wrappers/command_builder.py index b4827e9091..a7f89971f2 100755 --- a/metplus/wrappers/command_builder.py +++ b/metplus/wrappers/command_builder.py @@ -1425,24 +1425,28 @@ def set_met_config_list(self, c_dict, mp_config, met_config_name, return # convert value from config to a list - conf_value = util.getlist(conf_value) - if conf_value or kwargs.get('allow_empty', False): - conf_value = str(conf_value) - # if not removing quotes, escape any quotes found in list items - if not kwargs.get('remove_quotes', False): - conf_value = conf_value.replace('"', '\\"') - - conf_value = conf_value.replace("'", '"') - - if kwargs.get('remove_quotes', False): - conf_value = conf_value.replace('"', '') + conf_values = util.getlist(conf_value) + if conf_values or kwargs.get('allow_empty', False): + out_values = [] + for conf_value in conf_values: + remove_quotes = kwargs.get('remove_quotes', False) + # if not removing quotes, escape any quotes found in list items + if not remove_quotes: + conf_value = conf_value.replace('"', '\\"') + + conf_value = util.remove_quotes(conf_value) + if not remove_quotes: + conf_value = f'"{conf_value}"' + + out_values.append(conf_value) + out_value = f"[{', '.join(out_values)}]" if not c_dict_key: c_key = met_config_name.upper() else: c_key = c_dict_key - conf_value = f'{met_config_name} = {conf_value};' + conf_value = f'{met_config_name} = {out_value};' c_dict[c_key] = conf_value def set_met_config_string(self, c_dict, mp_config, met_config_name, @@ -1794,7 +1798,7 @@ def handle_climo_dict(self): # define layout of climo_mean and climo_stdev dictionaries climo_items = { 'file_name': ('list', '', None), - 'field': ('list', '', None), + 'field': ('list', 'remove_quotes', None), 'regrid': ('dict', '', [ ('method', 'string', 'uppercase,remove_quotes'),