Skip to content

Commit

Permalink
per #1898, add support for setting diag_name and diag_convert_map in …
Browse files Browse the repository at this point in the history
…TCPairs wrapped config file
  • Loading branch information
georgemccabe committed Nov 8, 2022
1 parent 4ad713f commit eab66e8
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 8 deletions.
28 changes: 24 additions & 4 deletions docs/Users_Guide/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7569,22 +7569,22 @@ METplus Configuration Glossary
| *Used by:* PB2NC
TC_PAIRS_CONSENSUS<n>_NAME
Specify the value for nth 'consensus.name' in the MET configuration file for TCPairs.
Specify the value for the nth 'consensus.name' in the MET configuration file for TCPairs.

| *Used by:* TCPairs
TC_PAIRS_CONSENSUS<n>_MEMBERS
Specify the value for nth 'consensus.members' in the MET configuration file for TCPairs.
Specify the value for the nth 'consensus.members' in the MET configuration file for TCPairs.

| *Used by:* TCPairs
TC_PAIRS_CONSENSUS<n>_REQUIRED
Specify the value for nth 'consensus.required' in the MET configuration file for TCPairs.
Specify the value for the nth 'consensus.required' in the MET configuration file for TCPairs.

| *Used by:* TCPairs
TC_PAIRS_CONSENSUS<n>_MIN_REQ
Specify the value for nth 'consensus.min_req' in the MET configuration file for TCPairs.
Specify the value for the nth 'consensus.min_req' in the MET configuration file for TCPairs.

| *Used by:* TCPairs
Expand Down Expand Up @@ -10093,3 +10093,23 @@ METplus Configuration Glossary
See :term:`STAT_ANALYSIS_FCST_VALID_END`.

| *Used by:* StatAnalysis
TC_PAIRS_DIAG_NAME
Specify the value for 'diag_name' in the MET configuration file for TCPairs.

| *Used by:* TCPairs
TC_PAIRS_DIAG_CONVERT_MAP<n>_SOURCE
Specify the value for the nth 'diag_convert_map.source' in the MET configuration file for TCPairs.

| *Used by:* TCPairs
TC_PAIRS_DIAG_CONVERT_MAP<n>_KEY
Specify the value for the nth 'diag_convert_map.key' in the MET configuration file for TCPairs.

| *Used by:* TCPairs
TC_PAIRS_DIAG_CONVERT_MAP<n>_CONVERT
Specify the value for the nth 'diag_convert_map.convert' in the MET configuration file for TCPairs.

| *Used by:* TCPairs
31 changes: 31 additions & 0 deletions docs/Users_Guide/wrappers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8210,6 +8210,10 @@ METplus Configuration
| :term:`TC_PAIRS_CHECK_DUP`
| :term:`TC_PAIRS_INTERP12`
| :term:`TC_PAIRS_MATCH_POINTS`
| :term:`TC_PAIRS_DIAG_NAME`
| :term:`TC_PAIRS_DIAG_CONVERT_MAP<n>_SOURCE`
| :term:`TC_PAIRS_DIAG_CONVERT_MAP<n>_KEY`
| :term:`TC_PAIRS_DIAG_CONVERT_MAP<n>_CONVERT`
|
.. warning:: **DEPRECATED:**
Expand Down Expand Up @@ -8492,6 +8496,33 @@ see :ref:`How METplus controls MET config file settings<metplus-control-met>`.
* - :term:`TC_PAIRS_INTERP12`
- interp12

**${METPLUS_DIAG_NAME}**

.. list-table::
:widths: 5 5
:header-rows: 0

* - METplus Config(s)
- MET Config File
* - :term:`TC_PAIRS_DIAG_NAME`
- diag_name

**${METPLUS_DIAG_CONVERT_MAP_LIST}**

.. list-table::
:widths: 5 5
:header-rows: 0

* - METplus Config(s)
- MET Config File
* - :term:`TC_PAIRS_DIAG_CONVERT_MAP<n>_SOURCE`
- diag_convert_map.source
* - :term:`TC_PAIRS_DIAG_CONVERT_MAP<n>_KEY`
- diag_convert_map.key
* - :term:`TC_PAIRS_DIAG_CONVERT_MAP<n>_CONVERT`
- diag_convert_map.convert


.. _tcrmw_wrapper:

TCRMW
Expand Down
24 changes: 22 additions & 2 deletions internal/tests/pytests/wrappers/tc_pairs/test_tc_pairs_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,14 +467,14 @@ def test_tc_pairs_storm_id_lists(metplus_config, config_overrides,
'TC_PAIRS_DIAG_SOURCE1': 'TCDIAG',
},
{'DIAG_ARG': '-diag TCDIAG /some/path/2014121318.dat'}),
# 42 -diag argument with models
# 43 -diag argument with models
('VALID', {
'TC_PAIRS_DIAG_TEMPLATE1': '/some/path/{valid?fmt=%Y%m%d%H}.dat',
'TC_PAIRS_DIAG_SOURCE1': 'TCDIAG',
'TC_PAIRS_DIAG_MODELS1': 'OFCL, SHIP',
},
{'DIAG_ARG': '-diag TCDIAG /some/path/2014121318.dat model=OFCL,SHIP'}),
# 43 2 -diag arguments
# 44 2 -diag arguments
('VALID', {
'TC_PAIRS_DIAG_TEMPLATE1': '/some/path/{valid?fmt=%Y%m%d%H}.dat',
'TC_PAIRS_DIAG_SOURCE1': 'TCDIAG',
Expand All @@ -485,6 +485,26 @@ def test_tc_pairs_storm_id_lists(metplus_config, config_overrides,
{'DIAG_ARG': ('-diag TCDIAG /some/path/2014121318.dat '
'-diag LSDIAG_RT /some/path/rt_2014121318.dat '
'model=OFCL,SHIP')}),
# 45
('VALID', {'TC_PAIRS_DIAG_NAME': 'TC_DIAG, TC_DIAG2', },
{'METPLUS_DIAG_NAME': 'diag_name = ["TC_DIAG", "TC_DIAG2"];'}),
# 46
('VALID', {'TC_PAIRS_DIAG_CONVERT_MAP1_SOURCE': 'TCDIAG', },
{'METPLUS_DIAG_CONVERT_MAP_LIST': 'diag_convert_map = [{source = "TCDIAG";}];'}),
# 47
('VALID', {'TC_PAIRS_DIAG_CONVERT_MAP1_KEY': '(10C),(10KT),(10M/S)', },
{'METPLUS_DIAG_CONVERT_MAP_LIST': 'diag_convert_map = [{key = ["(10C)", "(10KT)", "(10M/S)"];}];'}),
# 48
('VALID', {'TC_PAIRS_DIAG_CONVERT_MAP1_CONVERT': 'x/10', },
{'METPLUS_DIAG_CONVERT_MAP_LIST': 'diag_convert_map = [{convert(x) = x/10;}];'}),
# 49
('VALID', {
'TC_PAIRS_DIAG_CONVERT_MAP1_SOURCE': 'TCDIAG',
'TC_PAIRS_DIAG_CONVERT_MAP1_KEY': '(10C),(10KT),(10M/S)',
'TC_PAIRS_DIAG_CONVERT_MAP1_CONVERT': 'x/10',
},
{'METPLUS_DIAG_CONVERT_MAP_LIST': 'diag_convert_map = [{source = "TCDIAG";key = ["(10C)", "(10KT)", "(10M/S)"];convert(x) = x/10;}];'}),
]
)
@pytest.mark.wrapper
Expand Down
26 changes: 25 additions & 1 deletion metplus/wrappers/tc_pairs_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class TCPairsWrapper(CommandBuilder):
'METPLUS_CHECK_DUP',
'METPLUS_INTERP12',
'METPLUS_MATCH_POINTS',
'METPLUS_DIAG_NAME',
'METPLUS_DIAG_CONVERT_MAP_LIST',
]

WILDCARDS = {
Expand Down Expand Up @@ -178,6 +180,10 @@ def create_c_dict(self):

self.add_met_config(name='match_points', data_type='bool')

self.add_met_config(name='diag_name', data_type='list')

self._handle_diag_convert_map()

# if unset, set match_points to TRUE to match old default in wrapped
if not self.env_var_dict.get('METPLUS_MATCH_POINTS'):
self.env_var_dict['METPLUS_MATCH_POINTS'] = 'match_points = TRUE;'
Expand Down Expand Up @@ -413,7 +419,25 @@ def _handle_consensus(self):
if not return_code:
self.isOK = False

return return_code
def _handle_diag_convert_map(self):
dict_items = {
'source': 'string',
'key': 'list',
'convert': ('string', 'remove_quotes'),
}
return_code = add_met_config_dict_list(config=self.config,
app_name=self.app_name,
output_dict=self.env_var_dict,
dict_name='diag_convert_map',
dict_items=dict_items)
if not return_code:
self.isOK = False
return

# change "convert =" to "convert(x) ="
value = self.env_var_dict.get('METPLUS_DIAG_CONVERT_MAP_LIST', '')
value = value.replace('convert =', 'convert(x) =')
self.env_var_dict['METPLUS_DIAG_CONVERT_MAP_LIST'] = value

def _handle_diag(self, c_dict):
diag_indices = list(
Expand Down
7 changes: 7 additions & 0 deletions parm/met_config/TCPairsConfig_wrapped
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ watch_warn = {
time_offset = -14400;
}


//diag_name =
${METPLUS_DIAG_NAME}

//diag_convert_map = {
${METPLUS_DIAG_CONVERT_MAP_LIST}

//
// Indicate a version number for the contents of this configuration file.
// The value should generally not be modified.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,9 @@ TC_PAIRS_MISSING_VAL = -9999

#TC_PAIRS_INTERP12 =

#TC_PAIRS_MATCH_POINTS =
#TC_PAIRS_MATCH_POINTS =

#TC_PAIRS_DIAG_NAME =
#TC_PAIRS_DIAG_CONVERT_MAP1_SOURCE =
#TC_PAIRS_DIAG_CONVERT_MAP1_KEY =
#TC_PAIRS_DIAG_CONVERT_MAP1_CONVERT =
5 changes: 5 additions & 0 deletions parm/use_cases/met_tool_wrapper/TCPairs/TCPairs_tropical.conf
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,8 @@ TC_PAIRS_DLAND_FILE = MET_BASE/tc_data/dland_global_tenth_degree.nc
#TC_PAIRS_INTERP12 =

#TC_PAIRS_MATCH_POINTS =

#TC_PAIRS_DIAG_NAME =
#TC_PAIRS_DIAG_CONVERT_MAP1_SOURCE =
#TC_PAIRS_DIAG_CONVERT_MAP1_KEY =
#TC_PAIRS_DIAG_CONVERT_MAP1_CONVERT =

0 comments on commit eab66e8

Please sign in to comment.