Skip to content

Commit

Permalink
feature 749 TCPairs refactor (#937)
Browse files Browse the repository at this point in the history
  • Loading branch information
georgemccabe authored Jun 1, 2021
1 parent 3fca2b4 commit e2f0ded
Show file tree
Hide file tree
Showing 29 changed files with 1,213 additions and 545 deletions.
20 changes: 20 additions & 0 deletions docs/Users_Guide/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7090,3 +7090,23 @@ METplus Configuration Glossary
Specify the value for 'quality_mark_thresh' in the MET configuration file for PB2NC.

| *Used by:* PB2NC
TC_PAIRS_CONSENSUS<n>_NAME
Specify the value for 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.

| *Used by:* TCPairs
TC_PAIRS_CONSENSUS<n>_REQUIRED
Specify the value for 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.

| *Used by:* TCPairs
21 changes: 21 additions & 0 deletions docs/Users_Guide/wrappers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5380,6 +5380,10 @@ METplus Configuration
| :term:`TC_PAIRS_CUSTOM_LOOP_LIST`
| :term:`TC_PAIRS_DESC`
| :term:`TC_PAIRS_MET_CONFIG_OVERRIDES`
| :term:`TC_PAIRS_CONSENSUS<n>_NAME`
| :term:`TC_PAIRS_CONSENSUS<n>_MEMBERS`
| :term:`TC_PAIRS_CONSENSUS<n>_REQUIRED`
| :term:`TC_PAIRS_CONSENSUS<n>_MIN_REQ`
|
.. warning:: **DEPRECATED:**
Expand Down Expand Up @@ -5579,6 +5583,23 @@ see :ref:`How METplus controls MET config file settings<metplus-control-met>`.
* - :term:`TC_PAIRS_MET_CONFIG_OVERRIDES`
- n/a

**${METPLUS_CONSENSUS_LIST}**

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

* - METplus Config(s)
- MET Config File
* - :term:`TC_PAIRS_CONSENSUS<n>_NAME`
- consensus.name
* - :term:`TC_PAIRS_CONSENSUS<n>_MEMBERS`
- consensus.members
* - :term:`TC_PAIRS_CONSENSUS<n>_REQUIRED`
- consensus.required
* - :term:`TC_PAIRS_CONSENSUS<n>_MIN_REQ`
- consensus.min_req

.. _tcrmw_wrapper:

TCRMW
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
63 changes: 58 additions & 5 deletions internal_tests/pytests/met_util/test_met_util.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,73 @@
#!/usr/bin/env python3

import sys
import pytest
import datetime
import os
import subprocess
import shutil
from dateutil.relativedelta import relativedelta
from csv import reader
import pprint

import produtil
import pytest

from metplus.util import met_util as util
from metplus.util import time_util

@pytest.mark.parametrize(
'regex,index,id,expected_result', [
# 0: No ID
(r'^FCST_VAR(\d+)_NAME$', 1, None,
{'1': [None],
'2': [None],
'4': [None]}),
# 1: ID and index 2
(r'(\w+)_VAR(\d+)_NAME', 2, 1,
{'1': ['FCST'],
'2': ['FCST'],
'4': ['FCST']}),
# 2: index 1, ID 2, multiple identifiers
(r'^FCST_VAR(\d+)_(\w+)$', 1, 2,
{'1': ['NAME', 'LEVELS'],
'2': ['NAME'],
'4': ['NAME']}),
# 3: command that StatAnalysis wrapper uses
(r'MODEL(\d+)$', 1, None,
{'1': [None],
'2': [None],}),
# 4: TCPairs conensus logic
(r'^TC_PAIRS_CONSENSUS(\d+)_(\w+)$', 1, 2,
{'1': ['NAME', 'MEMBERS', 'REQUIRED', 'MIN_REQ'],
'2': ['NAME', 'MEMBERS', 'REQUIRED', 'MIN_REQ']}),
]
)
def test_find_indices_in_config_section(metplus_config, regex, index,
id, expected_result):
config = metplus_config()
config.set('config', 'FCST_VAR1_NAME', 'name1')
config.set('config', 'FCST_VAR1_LEVELS', 'level1')
config.set('config', 'FCST_VAR2_NAME', 'name2')
config.set('config', 'FCST_VAR4_NAME', 'name4')
config.set('config', 'MODEL1', 'model1')
config.set('config', 'MODEL2', 'model2')

config.set('config', 'TC_PAIRS_CONSENSUS1_NAME', 'name1')
config.set('config', 'TC_PAIRS_CONSENSUS1_MEMBERS', 'member1')
config.set('config', 'TC_PAIRS_CONSENSUS1_REQUIRED', 'True')
config.set('config', 'TC_PAIRS_CONSENSUS1_MIN_REQ', '1')
config.set('config', 'TC_PAIRS_CONSENSUS2_NAME', 'name2')
config.set('config', 'TC_PAIRS_CONSENSUS2_MEMBERS', 'member2')
config.set('config', 'TC_PAIRS_CONSENSUS2_REQUIRED', 'True')
config.set('config', 'TC_PAIRS_CONSENSUS2_MIN_REQ', '2')


indices = util.find_indices_in_config_section(regex, config,
index_index=index,
id_index=id)

pp = pprint.PrettyPrinter()
print(f'Indices:')
pp.pprint(indices)

assert indices == expected_result

@pytest.mark.parametrize(
'data_type, met_tool, expected_out', [
('FCST', None, ['FCST_',
Expand Down
Loading

0 comments on commit e2f0ded

Please sign in to comment.