Skip to content

Commit

Permalink
Per #2827, add support for setting the gradient dictionary in SeriesA…
Browse files Browse the repository at this point in the history
…nalysis (and GridStat) wrapper and added output_stats.grad to SeriesAnalysis.
  • Loading branch information
georgemccabe committed Dec 13, 2024
1 parent 6dfa458 commit b01e334
Show file tree
Hide file tree
Showing 10 changed files with 117 additions and 5 deletions.
25 changes: 25 additions & 0 deletions docs/Users_Guide/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8887,6 +8887,11 @@ METplus Configuration Glossary

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

| *Used by:* SeriesAnalysis
MODE_PS_PLOT_FLAG
Specify the value for 'ps_plot_flag' in the MET configuration file for MODE.

Expand Down Expand Up @@ -13267,3 +13272,23 @@ METplus Configuration Glossary
See :term:`INPUT_THRESH` for details.

| *Used by:* WaveletStat
GRID_STAT_GRADIENT_DX
Specify the value for 'gradient.dx' in the MET configuration file for GridStat.

| *Used by:* GridStat
GRID_STAT_GRADIENT_DY
Specify the value for 'gradient.dy' in the MET configuration file for GridStat.

| *Used by:* GridStat
SERIES_ANALYSIS_GRADIENT_DX
Specify the value for 'gradient.dx' in the MET configuration file for SeriesAnalysis.

| *Used by:* SeriesAnalysis
SERIES_ANALYSIS_GRADIENT_DY
Specify the value for 'gradient.dy' in the MET configuration file for SeriesAnalysis.

| *Used by:* SeriesAnalysis
35 changes: 35 additions & 0 deletions docs/Users_Guide/wrappers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3412,6 +3412,8 @@ METplus Configuration
| :term:`GRID_STAT_TIME_OFFSET_WARNING`
| :term:`GRID_STAT_ALLOW_MISSING_INPUTS`
| :term:`GRID_STAT_INPUT_THRESH`
| :term:`GRID_STAT_GRADIENT_DX`
| :term:`GRID_STAT_GRADIENT_DY`
|
.. warning:: **DEPRECATED**
Expand Down Expand Up @@ -3918,6 +3920,20 @@ ${METPLUS_FOURIER_DICT}
* - :term:`GRID_STAT_FOURIER_WAVE_1D_END`
- fourier.wave_1d_end

${METPLUS_GRADIENT_DICT}
^^^^^^^^^^^^^^^^^^^^^^^^

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

* - METplus Config(s)
- MET Config File
* - :term:`GRID_STAT_GRADIENT_DX`
- gradient.dx
* - :term:`GRID_STAT_GRADIENT_DY`
- gradient.dy

${METPLUS_DISTANCE_MAP_DICT}
""""""""""""""""""""""""""""

Expand Down Expand Up @@ -8131,6 +8147,7 @@ METplus Configuration
| :term:`SERIES_ANALYSIS_OUTPUT_STATS_PSTD`
| :term:`SERIES_ANALYSIS_OUTPUT_STATS_PJC`
| :term:`SERIES_ANALYSIS_OUTPUT_STATS_PRC`
| :term:`SERIES_ANALYSIS_OUTPUT_STATS_GRAD`
| :term:`FCST_SERIES_ANALYSIS_CAT_THRESH`
| :term:`OBS_SERIES_ANALYSIS_CAT_THRESH`
| :term:`FCST_SERIES_ANALYSIS_IS_PROB`
Expand All @@ -8144,6 +8161,8 @@ METplus Configuration
| :term:`SERIES_ANALYSIS_TIME_OFFSET_WARNING`
| :term:`SERIES_ANALYSIS_ALLOW_MISSING_INPUTS`
| :term:`SERIES_ANALYSIS_INPUT_THRESH`
| :term:`SERIES_ANALYSIS_GRADIENT_DX`
| :term:`SERIES_ANALYSIS_GRADIENT_DY`
|
.. warning:: **DEPRECATED:**
Expand Down Expand Up @@ -8550,6 +8569,20 @@ ${METPLUS_MASK_DICT}
* - :term:`SERIES_ANALYSIS_MASK_POLY`
- mask.poly

${METPLUS_GRADIENT_DICT}
^^^^^^^^^^^^^^^^^^^^^^^^

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

* - METplus Config(s)
- MET Config File
* - :term:`SERIES_ANALYSIS_GRADIENT_DX`
- gradient.dx
* - :term:`SERIES_ANALYSIS_GRADIENT_DY`
- gradient.dy

${METPLUS_BLOCK_SIZE}
"""""""""""""""""""""

Expand Down Expand Up @@ -8607,6 +8640,8 @@ ${METPLUS_OUTPUT_STATS_DICT}
- output_stats.pjc
* - :term:`SERIES_ANALYSIS_OUTPUT_STATS_PRC`
- output_stats.prc
* - :term:`SERIES_ANALYSIS_OUTPUT_STATS_GRAD`
- output_stats.grad

${METPLUS_HSS_EC_VALUE}
"""""""""""""""""""""""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,16 @@ def test_grid_stat_is_prob(metplus_config, config_overrides, expected_values):
'time_interp_method = NEAREST;'
'match_month = TRUE;day_interval = 30;'
'hour_interval = 12;}')}),
({'GRID_STAT_GRADIENT_DX': '2', },
{'METPLUS_GRADIENT_DICT': 'gradient = {dx = [2];}'}),
({'GRID_STAT_GRADIENT_DY': '3', },
{'METPLUS_GRADIENT_DICT': 'gradient = {dy = [3];}'}),
({'GRID_STAT_GRADIENT_DX': '4', 'GRID_STAT_GRADIENT_DY': '5',},
{'METPLUS_GRADIENT_DICT': 'gradient = {dx = [4];dy = [5];}'}),
({'GRID_STAT_GRADIENT_DX': '2,3', },
{'METPLUS_GRADIENT_DICT': 'gradient = {dx = [2, 3];}'}),
]
)
@pytest.mark.wrapper_b
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,9 @@ def test_series_analysis_missing_inputs(metplus_config, get_test_data_dir,
({'SERIES_ANALYSIS_OUTPUT_STATS_PRC': 'RMSE,FBAR,OBAR', },
{'METPLUS_OUTPUT_STATS_DICT': 'output_stats = {cnt = ["TOTAL", "RMSE", "FBAR", "OBAR"];prc = ["RMSE", "FBAR", "OBAR"];}'}),
({'SERIES_ANALYSIS_OUTPUT_STATS_GRAD': 'RMSE,FBAR,OBAR', },
{'METPLUS_OUTPUT_STATS_DICT': 'output_stats = {cnt = ["TOTAL", "RMSE", "FBAR", "OBAR"];grad = ["RMSE", "FBAR", "OBAR"];}'}),
({
'SERIES_ANALYSIS_OUTPUT_STATS_FHO': 'RMSE1,FBAR,OBAR',
'SERIES_ANALYSIS_OUTPUT_STATS_CTC': 'RMSE2,FBAR,OBAR',
Expand All @@ -355,6 +358,7 @@ def test_series_analysis_missing_inputs(metplus_config, get_test_data_dir,
'SERIES_ANALYSIS_OUTPUT_STATS_PSTD': 'RMSE10,FBAR,OBAR',
'SERIES_ANALYSIS_OUTPUT_STATS_PJC': 'RMSE11,FBAR,OBAR',
'SERIES_ANALYSIS_OUTPUT_STATS_PRC': 'RMSE12,FBAR,OBAR',
'SERIES_ANALYSIS_OUTPUT_STATS_GRAD': 'RMSE13,FBAR,OBAR',
},
{'METPLUS_OUTPUT_STATS_DICT': ('output_stats = {'
'fho = ["RMSE1", "FBAR", "OBAR"];'
Expand All @@ -368,7 +372,9 @@ def test_series_analysis_missing_inputs(metplus_config, get_test_data_dir,
'pct = ["RMSE9", "FBAR", "OBAR"];'
'pstd = ["RMSE10", "FBAR", "OBAR"];'
'pjc = ["RMSE11", "FBAR", "OBAR"];'
'prc = ["RMSE12", "FBAR", "OBAR"];}')}),
'prc = ["RMSE12", "FBAR", "OBAR"];'
'grad = ["RMSE13", "FBAR", "OBAR"];'
'}')}),
({'SERIES_ANALYSIS_FCST_CAT_THRESH': '>=0.0, >=0.3, >=1.0', },
{'METPLUS_FCST_CAT_THRESH': 'cat_thresh = [>=0.0, >=0.3, >=1.0];'}),
Expand Down Expand Up @@ -620,6 +626,16 @@ def test_series_analysis_missing_inputs(metplus_config, get_test_data_dir,
{}),
({'SERIES_ANALYSIS_AGGR_INPUT_DIR': aggr_dir, 'SERIES_ANALYSIS_AGGR_INPUT_TEMPLATE': aggr_template,},
{}),
({'SERIES_ANALYSIS_GRADIENT_DX': '2', },
{'METPLUS_GRADIENT_DICT': 'gradient = {dx = [2];}'}),
({'SERIES_ANALYSIS_GRADIENT_DY': '3', },
{'METPLUS_GRADIENT_DICT': 'gradient = {dy = [3];}'}),
({'SERIES_ANALYSIS_GRADIENT_DX': '4', 'SERIES_ANALYSIS_GRADIENT_DY': '5', },
{'METPLUS_GRADIENT_DICT': 'gradient = {dx = [4];dy = [5];}'}),
({'SERIES_ANALYSIS_GRADIENT_DX': '2,3', },
{'METPLUS_GRADIENT_DICT': 'gradient = {dx = [2, 3];}'}),
]
)
@pytest.mark.wrapper_a
Expand Down
6 changes: 6 additions & 0 deletions metplus/wrappers/grid_stat_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class GridStatWrapper(CompareGriddedWrapper):
'METPLUS_UGRID_DATASET',
'METPLUS_UGRID_MAX_DISTANCE_KM',
'METPLUS_UGRID_COORDINATES_FILE',
'METPLUS_GRADIENT_DICT',
]

# deprecated env vars that are no longer supported in the wrapped MET conf
Expand Down Expand Up @@ -265,6 +266,11 @@ def create_c_dict(self):
'wave_1d_end': ('list', 'remove_quotes'),
})

self.add_met_config_dict('gradient', {
'dx': ('list', 'remove_quotes'),
'dy': ('list', 'remove_quotes'),
})

self.add_met_config(name='censor_thresh', data_type='list',
extra_args={'remove_quotes': True})

Expand Down
7 changes: 7 additions & 0 deletions metplus/wrappers/series_analysis_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class SeriesAnalysisWrapper(RuntimeFreqWrapper):
'METPLUS_OBS_CAT_THRESH',
'METPLUS_CLIMO_CDF_DICT',
'METPLUS_MASK_DICT',
'METPLUS_GRADIENT_DICT',
]

# deprecated env vars that are no longer supported in the wrapped MET conf
Expand Down Expand Up @@ -96,6 +97,7 @@ class SeriesAnalysisWrapper(RuntimeFreqWrapper):
'pstd',
'pjc',
'prc',
'grad',
]

def __init__(self, config, instance=None):
Expand Down Expand Up @@ -148,6 +150,11 @@ def create_c_dict(self):

self.handle_mask(single_value=True)

self.add_met_config_dict('gradient', {
'dx': ('list', 'remove_quotes'),
'dy': ('list', 'remove_quotes'),
})

c_dict['PAIRED'] = self.config.getbool('config',
'SERIES_ANALYSIS_IS_PAIRED',
False)
Expand Down
6 changes: 2 additions & 4 deletions parm/met_config/GridStatConfig_wrapped
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,8 @@ ${METPLUS_FOURIER_DICT}
// Gradient statistics
// May be set separately in each "obs.field" entry
//
gradient = {
dx = [ 1 ];
dy = [ 1 ];
}
//gradient = {
${METPLUS_GRADIENT_DICT}

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

Expand Down
9 changes: 9 additions & 0 deletions parm/met_config/SeriesAnalysisConfig_wrapped
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ boot = {
//mask = {
${METPLUS_MASK_DICT}

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

//
// Gradient statistics
// May be set separately in each "obs.field" entry
//
//gradient = {
${METPLUS_GRADIENT_DICT}

//
// Number of grid points to be processed concurrently. Set smaller to use
// less memory but increase the number of passes through the data.
Expand Down
3 changes: 3 additions & 0 deletions parm/use_cases/met_tool_wrapper/GridStat/GridStat.conf
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ GRID_STAT_NC_PAIRS_FLAG_APPLY_MASK = FALSE
#GRID_STAT_FOURIER_WAVE_1D_BEG =
#GRID_STAT_FOURIER_WAVE_1D_END =

#GRID_STAT_GRADIENT_DX =
#GRID_STAT_GRADIENT_DY =

#GRID_STAT_CENSOR_THRESH =
#GRID_STAT_CENSOR_VAL =
#GRID_STAT_CAT_THRESH =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,14 @@ SERIES_ANALYSIS_OUTPUT_STATS_CNT = TOTAL, RMSE, FBAR, OBAR
#SERIES_ANALYSIS_OUTPUT_STATS_PSTD =
#SERIES_ANALYSIS_OUTPUT_STATS_PJC =
#SERIES_ANALYSIS_OUTPUT_STATS_PRC =
#SERIES_ANALYSIS_OUTPUT_STATS_GRAD =

#SERIES_ANALYSIS_MASK_GRID =
#SERIES_ANALYSIS_MASK_POLY =

#SERIES_ANALYSIS_GRADIENT_DX =
#SERIES_ANALYSIS_GRADIENT_DY =


###
# SeriesAnalysis Plotting
Expand Down

0 comments on commit b01e334

Please sign in to comment.