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 1021 develop climo mean/stdev field #1039

Merged
merged 2 commits into from
Jul 27, 2021
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 @@ -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;}}'}),
Expand Down Expand Up @@ -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',
Expand All @@ -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;'
Expand All @@ -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', },
{
Expand Down Expand Up @@ -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',
Expand All @@ -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;'
Expand Down
16 changes: 8 additions & 8 deletions internal_tests/pytests/grid_stat/test_grid_stat_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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;}}'}),
Expand Down Expand Up @@ -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',
Expand All @@ -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;'
Expand All @@ -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', },
{
Expand Down Expand Up @@ -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',
Expand All @@ -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;'
Expand Down
16 changes: 8 additions & 8 deletions internal_tests/pytests/point_stat/test_point_stat_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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', },
{
Expand Down Expand Up @@ -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',
Expand All @@ -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;'
Expand All @@ -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', },
{
Expand Down Expand Up @@ -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',
Expand All @@ -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;'
Expand Down
16 changes: 8 additions & 8 deletions internal_tests/pytests/series_analysis/test_series_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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;}}'}),
Expand Down Expand Up @@ -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',
Expand All @@ -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;'
Expand All @@ -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', },
{
Expand Down Expand Up @@ -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',
Expand All @@ -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;'
Expand Down
30 changes: 17 additions & 13 deletions metplus/wrappers/command_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'),
Expand Down