Skip to content

Commit

Permalink
per #896, add support for setting all output_stats values in SeriesAn…
Browse files Browse the repository at this point in the history
…alysis wrapped MET config file while preserving legacy setting of env vars for cts and cnt separately and using output_stats.cnt values to generate images, ci-run-all-diff
  • Loading branch information
georgemccabe committed Dec 16, 2021
1 parent 2e5f4b6 commit b01ac4d
Show file tree
Hide file tree
Showing 5 changed files with 219 additions and 51 deletions.
70 changes: 63 additions & 7 deletions docs/Users_Guide/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3732,17 +3732,13 @@ METplus Configuration Glossary
.. warning:: **DEPRECATED:** Please use :term:`MAKE_PLOTS_INPUT_DIR` instead.

SERIES_ANALYSIS_STAT_LIST
Specify a list of statistics to be computed by the MET series_analysis tool. Sets the 'cnt' value in the output_stats dictionary in the MET SeriesAnalysis config file

| *Used by:* SeriesAnalysis
.. warning:: **DEPRECATED:** Please use :term:`SERIES_ANALYSIS_OUTPUT_STATS_CNT` instead.

SERIES_ANALYSIS_CTS_LIST
Specify a list of contingency table statistics to be computed by the MET series_analysis tool. Sets the 'cts' value in the output_stats dictionary in the MET SeriesAnalysis config file

| *Used by:* SeriesAnalysis
.. warning:: **DEPRECATED:** Please use :term:`SERIES_ANALYSIS_OUTPUT_STATS_CTS` instead.

STAT_LIST
.. warning:: **DEPRECATED:** Please use :term:`SERIES_ANALYSIS_STAT_LIST` instead.
.. warning:: **DEPRECATED:** Please use :term:`SERIES_ANALYSIS_OUTPUT_STATS_CNT` instead.

STORM_ID
.. warning:: **DEPRECATED:** Please use :term:`TC_PAIRS_STORM_ID` or :term:`TC_STAT_STORM_ID`.
Expand Down Expand Up @@ -8597,3 +8593,63 @@ METplus Configuration Glossary
Specify the value for 'interp12' in the MET configuration file for TCPairs.

| *Used by:* TCPairs
SERIES_ANALYSIS_OUTPUT_STATS_FHO
Specify the value for 'output_stats.fho' in the MET configuration file for SeriesAnalysis.

| *Used by:* SeriesAnalysis
SERIES_ANALYSIS_OUTPUT_STATS_CTC
Specify the value for 'output_stats.ctc' in the MET configuration file for SeriesAnalysis.

| *Used by:* SeriesAnalysis
SERIES_ANALYSIS_OUTPUT_STATS_CTS
Specify the value for 'output_stats.cts' in the MET configuration file for SeriesAnalysis.

| *Used by:* SeriesAnalysis
SERIES_ANALYSIS_OUTPUT_STATS_MCTC
Specify the value for 'output_stats.mctc' in the MET configuration file for SeriesAnalysis.

| *Used by:* SeriesAnalysis
SERIES_ANALYSIS_OUTPUT_STATS_MCTS
Specify the value for 'output_stats.mcts' in the MET configuration file for SeriesAnalysis.

| *Used by:* SeriesAnalysis
SERIES_ANALYSIS_OUTPUT_STATS_CNT
Specify the value for 'output_stats.cnt' in the MET configuration file for SeriesAnalysis. Also used to generate plots for each value in the list.

| *Used by:* SeriesAnalysis
SERIES_ANALYSIS_OUTPUT_STATS_SL1L2
Specify the value for 'output_stats.sl1l2' in the MET configuration file for SeriesAnalysis.

| *Used by:* SeriesAnalysis
SERIES_ANALYSIS_OUTPUT_STATS_SAL1L2
Specify the value for 'output_stats.sal1l2' in the MET configuration file for SeriesAnalysis.

| *Used by:* SeriesAnalysis
SERIES_ANALYSIS_OUTPUT_STATS_PCT
Specify the value for 'output_stats.pct' in the MET configuration file for SeriesAnalysis.

| *Used by:* SeriesAnalysis
SERIES_ANALYSIS_OUTPUT_STATS_PSTD
Specify the value for 'output_stats.pstd' in the MET configuration file for SeriesAnalysis.

| *Used by:* SeriesAnalysis
SERIES_ANALYSIS_OUTPUT_STATS_PJC
Specify the value for 'output_stats.pjc' in the MET configuration file for SeriesAnalysis.

| *Used by:* SeriesAnalysis
SERIES_ANALYSIS_OUTPUT_STATS_PRC
Specify the value for 'output_stats.prc' in the MET configuration file for SeriesAnalysis.

| *Used by:* SeriesAnalysis
63 changes: 43 additions & 20 deletions docs/Users_Guide/wrappers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5835,6 +5835,18 @@ METplus Configuration
| :term:`SERIES_ANALYSIS_CLIMO_STDEV_DAY_INTERVAL`
| :term:`SERIES_ANALYSIS_CLIMO_STDEV_HOUR_INTERVAL`
| :term:`SERIES_ANALYSIS_HSS_EC_VALUE`
| :term:`SERIES_ANALYSIS_OUTPUT_STATS_FHO`
| :term:`SERIES_ANALYSIS_OUTPUT_STATS_CTC`
| :term:`SERIES_ANALYSIS_OUTPUT_STATS_CTS`
| :term:`SERIES_ANALYSIS_OUTPUT_STATS_MCTC`
| :term:`SERIES_ANALYSIS_OUTPUT_STATS_MCTS`
| :term:`SERIES_ANALYSIS_OUTPUT_STATS_CNT`
| :term:`SERIES_ANALYSIS_OUTPUT_STATS_SL1L2`
| :term:`SERIES_ANALYSIS_OUTPUT_STATS_SAL1L2`
| :term:`SERIES_ANALYSIS_OUTPUT_STATS_PCT`
| :term:`SERIES_ANALYSIS_OUTPUT_STATS_PSTD`
| :term:`SERIES_ANALYSIS_OUTPUT_STATS_PJC`
| :term:`SERIES_ANALYSIS_OUTPUT_STATS_PRC`
|
.. warning:: **DEPRECATED:**
Expand Down Expand Up @@ -6070,49 +6082,60 @@ see :ref:`How METplus controls MET config file settings<metplus-control-met>`.
* - :term:`SERIES_ANALYSIS_VLD_THRESH`
- vld_thresh

**${METPLUS_CTS_LIST}**

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

* - METplus Config(s)
- MET Config File
* - :term:`SERIES_ANALYSIS_CTS_LIST`
- output_stats.cts

**${METPLUS_STAT_LIST}**
**${METPLUS_MET_CONFIG_OVERRIDES}**

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

* - METplus Config(s)
- MET Config File
* - :term:`SERIES_ANALYSIS_STAT_LIST`
- output_stats.cnt
* - :term:`SERIES_ANALYSIS_MET_CONFIG_OVERRIDES`
- n/a

**${METPLUS_MET_CONFIG_OVERRIDES}**
**${METPLUS_HSS_EC_VALUE}**

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

* - METplus Config(s)
- MET Config File
* - :term:`SERIES_ANALYSIS_MET_CONFIG_OVERRIDES`
- n/a
* - :term:`SERIES_ANALYSIS_HSS_EC_VALUE`
- hss_ec_value

**${METPLUS_HSS_EC_VALUE}**
**${METPLUS_OUTPUT_STATS_DICT}**

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

* - METplus Config(s)
- MET Config File
* - :term:`SERIES_ANALYSIS_HSS_EC_VALUE`
- hss_ec_value
* - :term:`SERIES_ANALYSIS_OUTPUT_STATS_FHO`
- output_stats.fho
* - :term:`SERIES_ANALYSIS_OUTPUT_STATS_CTC`
- output_stats.ctc
* - :term:`SERIES_ANALYSIS_OUTPUT_STATS_CTS`
- output_stats.cts
* - :term:`SERIES_ANALYSIS_OUTPUT_STATS_MCTC`
- output_stats.mctc
* - :term:`SERIES_ANALYSIS_OUTPUT_STATS_MCTS`
- output_stats.mcts
* - :term:`SERIES_ANALYSIS_OUTPUT_STATS_CNT`
- output_stats.cnt
* - :term:`SERIES_ANALYSIS_OUTPUT_STATS_SL1L2`
- output_stats.sl1l2
* - :term:`SERIES_ANALYSIS_OUTPUT_STATS_SAL1L2`
- output_stats.sal1l2
* - :term:`SERIES_ANALYSIS_OUTPUT_STATS_PCT`
- output_stats.pct
* - :term:`SERIES_ANALYSIS_OUTPUT_STATS_PSTD`
- output_stats.pstd
* - :term:`SERIES_ANALYSIS_OUTPUT_STATS_PJC`
- output_stats.pjc
* - :term:`SERIES_ANALYSIS_OUTPUT_STATS_PRC`
- output_stats.prc


SeriesByInit
Expand Down
65 changes: 65 additions & 0 deletions internal_tests/pytests/series_analysis/test_series_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,71 @@ def set_minimum_config_settings(config):
'CLIMO_STDEV_FILE': '"/some/climo_stdev/file.txt"'}),
({'SERIES_ANALYSIS_HSS_EC_VALUE': '0.5', },
{'METPLUS_HSS_EC_VALUE': 'hss_ec_value = 0.5;'}),
# output_stats
({'SERIES_ANALYSIS_OUTPUT_STATS_FHO': 'RMSE,FBAR,OBAR', },
{'METPLUS_OUTPUT_STATS_DICT': 'output_stats = {fho = ["RMSE", "FBAR", "OBAR"];}'}),
({'SERIES_ANALYSIS_OUTPUT_STATS_CTC': 'RMSE,FBAR,OBAR', },
{'METPLUS_OUTPUT_STATS_DICT': 'output_stats = {ctc = ["RMSE", "FBAR", "OBAR"];}'}),
({'SERIES_ANALYSIS_OUTPUT_STATS_CTS': 'RMSE,FBAR,OBAR', },
{'METPLUS_OUTPUT_STATS_DICT': 'output_stats = {cts = ["RMSE", "FBAR", "OBAR"];}'}),
({'SERIES_ANALYSIS_OUTPUT_STATS_MCTC': 'RMSE,FBAR,OBAR', },
{'METPLUS_OUTPUT_STATS_DICT': 'output_stats = {mctc = ["RMSE", "FBAR", "OBAR"];}'}),
({'SERIES_ANALYSIS_OUTPUT_STATS_MCTS': 'RMSE,FBAR,OBAR', },
{'METPLUS_OUTPUT_STATS_DICT': 'output_stats = {mcts = ["RMSE", "FBAR", "OBAR"];}'}),
({'SERIES_ANALYSIS_OUTPUT_STATS_CNT': 'RMSE,FBAR,OBAR', },
{'METPLUS_OUTPUT_STATS_DICT': 'output_stats = {cnt = ["RMSE", "FBAR", "OBAR"];}'}),
({'SERIES_ANALYSIS_OUTPUT_STATS_SL1L2': 'RMSE,FBAR,OBAR', },
{'METPLUS_OUTPUT_STATS_DICT': 'output_stats = {sl1l2 = ["RMSE", "FBAR", "OBAR"];}'}),
({'SERIES_ANALYSIS_OUTPUT_STATS_SAL1L2': 'RMSE,FBAR,OBAR', },
{'METPLUS_OUTPUT_STATS_DICT': 'output_stats = {sal1l2 = ["RMSE", "FBAR", "OBAR"];}'}),
({'SERIES_ANALYSIS_OUTPUT_STATS_PCT': 'RMSE,FBAR,OBAR', },
{'METPLUS_OUTPUT_STATS_DICT': 'output_stats = {pct = ["RMSE", "FBAR", "OBAR"];}'}),
({'SERIES_ANALYSIS_OUTPUT_STATS_PSTD': 'RMSE,FBAR,OBAR', },
{'METPLUS_OUTPUT_STATS_DICT': 'output_stats = {pstd = ["RMSE", "FBAR", "OBAR"];}'}),
({'SERIES_ANALYSIS_OUTPUT_STATS_PJC': 'RMSE,FBAR,OBAR', },
{'METPLUS_OUTPUT_STATS_DICT': 'output_stats = {pjc = ["RMSE", "FBAR", "OBAR"];}'}),
({'SERIES_ANALYSIS_OUTPUT_STATS_PRC': 'RMSE,FBAR,OBAR', },
{'METPLUS_OUTPUT_STATS_DICT': 'output_stats = {prc = ["RMSE", "FBAR", "OBAR"];}'}),
({
'SERIES_ANALYSIS_OUTPUT_STATS_FHO': 'RMSE1,FBAR,OBAR',
'SERIES_ANALYSIS_OUTPUT_STATS_CTC': 'RMSE2,FBAR,OBAR',
'SERIES_ANALYSIS_OUTPUT_STATS_CTS': 'RMSE3,FBAR,OBAR',
'SERIES_ANALYSIS_OUTPUT_STATS_MCTC': 'RMSE4,FBAR,OBAR',
'SERIES_ANALYSIS_OUTPUT_STATS_MCTS': 'RMSE5,FBAR,OBAR',
'SERIES_ANALYSIS_OUTPUT_STATS_CNT': 'RMSE6,FBAR,OBAR',
'SERIES_ANALYSIS_OUTPUT_STATS_SL1L2': 'RMSE7,FBAR,OBAR',
'SERIES_ANALYSIS_OUTPUT_STATS_SAL1L2': 'RMSE8,FBAR,OBAR',
'SERIES_ANALYSIS_OUTPUT_STATS_PCT': 'RMSE9,FBAR,OBAR',
'SERIES_ANALYSIS_OUTPUT_STATS_PSTD': 'RMSE10,FBAR,OBAR',
'SERIES_ANALYSIS_OUTPUT_STATS_PJC': 'RMSE11,FBAR,OBAR',
'SERIES_ANALYSIS_OUTPUT_STATS_PRC': 'RMSE12,FBAR,OBAR',
},
{'METPLUS_OUTPUT_STATS_DICT': ('output_stats = {'
'fho = ["RMSE1", "FBAR", "OBAR"];'
'ctc = ["RMSE2", "FBAR", "OBAR"];'
'cts = ["RMSE3", "FBAR", "OBAR"];'
'mctc = ["RMSE4", "FBAR", "OBAR"];'
'mcts = ["RMSE5", "FBAR", "OBAR"];'
'cnt = ["RMSE6", "FBAR", "OBAR"];'
'sl1l2 = ["RMSE7", "FBAR", "OBAR"];'
'sal1l2 = ["RMSE8", "FBAR", "OBAR"];'
'pct = ["RMSE9", "FBAR", "OBAR"];'
'pstd = ["RMSE10", "FBAR", "OBAR"];'
'pjc = ["RMSE11", "FBAR", "OBAR"];'
'prc = ["RMSE12", "FBAR", "OBAR"];}')}),
]
)
def test_series_analysis_single_field(metplus_config, config_overrides,
Expand Down
56 changes: 46 additions & 10 deletions metplus/wrappers/series_analysis_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,32 @@ class SeriesAnalysisWrapper(RuntimeFreqWrapper):
'METPLUS_CLIMO_STDEV_DICT',
'METPLUS_BLOCK_SIZE',
'METPLUS_VLD_THRESH',
'METPLUS_CTS_LIST',
'METPLUS_STAT_LIST',
'METPLUS_OUTPUT_STATS_DICT',
'METPLUS_HSS_EC_VALUE',
]

# handle deprecated env vars used pre v4.0.0
DEPRECATED_WRAPPER_ENV_VAR_KEYS = [
'CLIMO_MEAN_FILE',
'CLIMO_STDEV_FILE',
'METPLUS_CTS_LIST',
'METPLUS_STAT_LIST',
]

# variable names of output_stats dictionary
OUTPUT_STATS = [
'fho',
'ctc',
'cts',
'mctc',
'mcts',
'cnt',
'sl1l2',
'sal1l2',
'pct',
'pstd',
'pjc',
'prc',
]

def __init__(self, config, instance=None, config_overrides=None):
Expand Down Expand Up @@ -116,23 +133,42 @@ def create_c_dict(self):
data_type='string',
extra_args={'remove_quotes': True})

# get stat list to loop over
c_dict['STAT_LIST'] = util.getlist(
self.config.getstr('config',
'SERIES_ANALYSIS_STAT_LIST',
'')
)
# handle all output_stats dictionary values
output_stats_dict = {}
for key in self.OUTPUT_STATS:
nicknames = [
f'SERIES_ANALYSIS_OUTPUT_STATS_{key.upper()}',
f'SERIES_ANALYSIS_{key.upper()}_LIST',
f'SERIES_ANALYSIS_{key.upper()}'
]
# add legacy support for STAT_LIST for cnt
if key == 'cnt':
nicknames.append('SERIES_ANALYSIS_STAT_LIST')
# read cnt stat list to get stats to loop over for plotting
self.add_met_config(name='cnt',
data_type='list',
env_var_name='STAT_LIST',
metplus_configs=nicknames)
c_dict['STAT_LIST'] = util.getlist(
self.get_env_var_value('METPLUS_STAT_LIST')
)

value = ('list', None, None, nicknames)
output_stats_dict[key] = value
self.add_met_config_dict('output_stats', output_stats_dict)

if not c_dict['STAT_LIST']:
self.log_error("Must set SERIES_ANALYSIS_STAT_LIST to run.")

# set stat list to set output_stats.cnt in MET config file

# set legacy stat list to set output_stats.cnt in MET config file
self.add_met_config(name='cnt',
data_type='list',
env_var_name='METPLUS_STAT_LIST',
metplus_configs=['SERIES_ANALYSIS_STAT_LIST',
'SERIES_ANALYSIS_CNT'])

# set cts list to set output_stats.cts in MET config file
# set legacy cts list to set output_stats.cts in MET config file
self.add_met_config(name='cts',
data_type='list',
env_var_name='METPLUS_CTS_LIST',
Expand Down
16 changes: 2 additions & 14 deletions parm/met_config/SeriesAnalysisConfig_wrapped
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,8 @@ ${METPLUS_VLD_THRESH}
//
// Statistical output types
//
output_stats = {
fho = [];
ctc = [];
${METPLUS_CTS_LIST}
mctc = [];
mcts = [];
${METPLUS_STAT_LIST}
sl1l2 = [];
sal1l2 = [];
pct = [];
pstd = [];
pjc = [];
prc = [];
}
//output_stats = {
${METPLUS_OUTPUT_STATS_DICT}

////////////////////////////////////////////////////////////////////////////////

Expand Down

0 comments on commit b01ac4d

Please sign in to comment.