Skip to content
Open
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
35 changes: 35 additions & 0 deletions docs/Users_Guide/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15093,6 +15093,41 @@ METplus Configuration Glossary

| *Used by:* EnsembleStat

TC_RMW_COMPUTE_TANGENTIAL_AND_RADIAL_WINDS
Specify the value for 'compute_tangential_and_radial_winds' in the MET configuration file for TCRMW.

| *Used by:* TCRMW

TC_RMW_U_WIND_FIELD_NAME
Specify the value for 'u_wind_field_name' in the MET configuration file for TCRMW.

| *Used by:* TCRMW

TC_RMW_V_WIND_FIELD_NAME
Specify the value for 'v_wind_field_name' in the MET configuration file for TCRMW.

| *Used by:* TCRMW

TC_RMW_TANGENTIAL_VELOCITY_FIELD_NAME
Specify the value for 'tangential_velocity_field_name' in the MET configuration file for TCRMW.

| *Used by:* TCRMW

TC_RMW_TANGENTIAL_VELOCITY_LONG_FIELD_NAME
Specify the value for 'tangential_velocity_long_field_name' in the MET configuration file for TCRMW.

| *Used by:* TCRMW

TC_RMW_RADIAL_VELOCITY_FIELD_NAME
Specify the value for 'radial_velocity_field_name' in the MET configuration file for TCRMW.

| *Used by:* TCRMW

TC_RMW_RADIAL_VELOCITY_LONG_FIELD_NAME
Specify the value for 'radial_velocity_long_field_name' in the MET configuration file for TCRMW.

| *Used by:* TCRMW

GEN_ENS_PROD_EAS_PROB_WIDTH
Specify the value for 'eas_prob.width' in the MET configuration file for GenEnsProd.

Expand Down
91 changes: 91 additions & 0 deletions docs/Users_Guide/wrappers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13041,6 +13041,13 @@ METplus Configuration
| :term:`TC_RMW_VALID_INCLUDE_LIST`
| :term:`TC_RMW_VALID_EXCLUDE_LIST`
| :term:`TC_RMW_VALID_HOUR_LIST`
| :term:`TC_RMW_COMPUTE_TANGENTIAL_AND_RADIAL_WINDS`
| :term:`TC_RMW_U_WIND_FIELD_NAME`
| :term:`TC_RMW_V_WIND_FIELD_NAME`
| :term:`TC_RMW_TANGENTIAL_VELOCITY_FIELD_NAME`
| :term:`TC_RMW_TANGENTIAL_VELOCITY_LONG_FIELD_NAME`
| :term:`TC_RMW_RADIAL_VELOCITY_FIELD_NAME`
| :term:`TC_RMW_RADIAL_VELOCITY_LONG_FIELD_NAME`
| :term:`TC_RMW_SKIP_IF_OUTPUT_EXISTS`
| :term:`TC_RMW_DESC`
| :term:`MODEL`
Expand Down Expand Up @@ -13311,6 +13318,90 @@ ${METPLUS_RMW_SCALE}
* - :term:`TC_RMW_SCALE`
- rmw_scale

${METPLUS_COMPUTE_TANGENTIAL_AND_RADIAL_WINDS}
""""""""""""""""""""""""""""""""""""""""""""""

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

* - METplus Config(s)
- MET Config File
* - :term:`TC_RMW_COMPUTE_TANGENTIAL_AND_RADIAL_WINDS`
- compute_tangential_and_radial_winds

${METPLUS_U_WIND_FIELD_NAME}
""""""""""""""""""""""""""""

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

* - METplus Config(s)
- MET Config File
* - :term:`TC_RMW_U_WIND_FIELD_NAME`
- u_wind_field_name

${METPLUS_V_WIND_FIELD_NAME}
""""""""""""""""""""""""""""

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

* - METplus Config(s)
- MET Config File
* - :term:`TC_RMW_V_WIND_FIELD_NAME`
- v_wind_field_name

${METPLUS_TANGENTIAL_VELOCITY_FIELD_NAME}
"""""""""""""""""""""""""""""""""""""""""

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

* - METplus Config(s)
- MET Config File
* - :term:`TC_RMW_TANGENTIAL_VELOCITY_FIELD_NAME`
- tangential_velocity_field_name

${METPLUS_TANGENTIAL_VELOCITY_LONG_FIELD_NAME}
""""""""""""""""""""""""""""""""""""""""""""""

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

* - METplus Config(s)
- MET Config File
* - :term:`TC_RMW_TANGENTIAL_VELOCITY_LONG_FIELD_NAME`
- tangential_velocity_long_field_name

${METPLUS_RADIAL_VELOCITY_FIELD_NAME}
"""""""""""""""""""""""""""""""""""""

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

* - METplus Config(s)
- MET Config File
* - :term:`TC_RMW_RADIAL_VELOCITY_FIELD_NAME`
- radial_velocity_field_name

${METPLUS_RADIAL_VELOCITY_LONG_FIELD_NAME}
""""""""""""""""""""""""""""""""""""""""""

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

* - METplus Config(s)
- MET Config File
* - :term:`TC_RMW_RADIAL_VELOCITY_LONG_FIELD_NAME`
- radial_velocity_long_field_name

${METPLUS_MET_CONFIG_OVERRIDES}
"""""""""""""""""""""""""""""""

Expand Down
22 changes: 22 additions & 0 deletions internal/tests/pytests/wrappers/tcrmw/test_tcrmw_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def set_minimum_config_settings(config):
'censor_val = [12000, 5000];}'
)
}),

({'TC_RMW_N_RANGE': '10', },
{'METPLUS_N_RANGE': 'n_range = 10;'}),

Expand All @@ -122,6 +123,27 @@ def set_minimum_config_settings(config):
({'TC_RMW_RMW_SCALE': '15', },
{'METPLUS_RMW_SCALE': 'rmw_scale = 15.0;'}),

({'TC_RMW_COMPUTE_TANGENTIAL_AND_RADIAL_WINDS': 'true', },
{'METPLUS_COMPUTE_TANGENTIAL_AND_RADIAL_WINDS': 'compute_tangential_and_radial_winds = TRUE;'}),

({'TC_RMW_U_WIND_FIELD_NAME': 'UGRD', },
{'METPLUS_U_WIND_FIELD_NAME': 'u_wind_field_name = "UGRD";'}),

({'TC_RMW_V_WIND_FIELD_NAME': 'VGRD', },
{'METPLUS_V_WIND_FIELD_NAME': 'v_wind_field_name = "VGRD";'}),

({'TC_RMW_TANGENTIAL_VELOCITY_FIELD_NAME': 'VT', },
{'METPLUS_TANGENTIAL_VELOCITY_FIELD_NAME': 'tangential_velocity_field_name = "VT";'}),

({'TC_RMW_TANGENTIAL_VELOCITY_LONG_FIELD_NAME': 'Tangential Velocity', },
{'METPLUS_TANGENTIAL_VELOCITY_LONG_FIELD_NAME': 'tangential_velocity_long_field_name = "Tangential Velocity";'}),

({'TC_RMW_RADIAL_VELOCITY_FIELD_NAME': 'VR', },
{'METPLUS_RADIAL_VELOCITY_FIELD_NAME': 'radial_velocity_field_name = "VR";'}),

({'TC_RMW_RADIAL_VELOCITY_LONG_FIELD_NAME': 'Radial Velocity', },
{'METPLUS_RADIAL_VELOCITY_LONG_FIELD_NAME': 'radial_velocity_long_field_name = "Radial Velocity";'}),

]
)
@pytest.mark.wrapper
Expand Down
1 change: 1 addition & 0 deletions metplus/wrappers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from .reformat_gridded_wrapper import ReformatGriddedWrapper
from .reformat_point_wrapper import ReformatPointWrapper
from .compare_gridded_wrapper import CompareGriddedWrapper
from .tc_base_wrapper import TCBaseWrapper

# import RegridDataPlane wrapper because it is used by other wrappers
from .regrid_data_plane_wrapper import RegridDataPlaneWrapper
Expand Down
76 changes: 76 additions & 0 deletions metplus/wrappers/tc_base_wrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
"""
Program Name: tc_base_wrapper.py
Contact(s): George McCabe
"""

from . import RuntimeFreqWrapper

from ..util import get_lead_sequence, sub_var_list
from ..util.time_util import ti_get_hours_from_relativedelta

'''!@namespace TCBaseWrapper
@brief parent class for the tropical cyclone wrappers
@endcode
'''

class TCBaseWrapper(RuntimeFreqWrapper):

def __init__(self, config, instance=None):
super().__init__(config, instance=instance)

def add_met_config_tc_wind(self):
self.add_met_config(name='compute_tangential_and_radial_winds', data_type='bool')
self.add_met_config(name='u_wind_field_name', data_type='string')
self.add_met_config(name='v_wind_field_name', data_type='string')
self.add_met_config(name='tangential_velocity_field_name', data_type='string')
self.add_met_config(name='tangential_velocity_long_field_name', data_type='string')
self.add_met_config(name='radial_velocity_field_name', data_type='string')
self.add_met_config(name='radial_velocity_long_field_name', data_type='string')

def _set_lead_list(self, time_info, lead_seq=None):
self.env_var_dict['METPLUS_LEAD_LIST'] = ''

if lead_seq is None:
lead_seq = get_lead_sequence(self.config, time_info)

# set LEAD_LIST to list of forecast leads used
if lead_seq == [0]:
return

lead_list = []
for lead in lead_seq:
lead_hours = (
ti_get_hours_from_relativedelta(lead, valid_time=time_info['valid'])
)
lead_list.append(f'"{str(lead_hours).zfill(2)}"')

self.env_var_dict['METPLUS_LEAD_LIST'] = f"lead = [{', '.join(lead_list)}];"

def _set_data_field(self, time_info):
"""!Get list of fields from config to process. Build list of field info
that are formatted to be read by the MET config file. Set DATA_FIELD
item of c_dict with the formatted list of fields.
Args:
@param time_info time dictionary to use for string substitution
@returns True if field list could be built, False if not.
"""
field_list = sub_var_list(self.c_dict['VAR_LIST_TEMP'], time_info)
if not field_list:
self.log_error("Could not get field information from config.")
return False

all_fields = []
for field in field_list:
field_list = self.get_field_info(d_type='FCST',
v_name=field['fcst_name'],
v_level=field['fcst_level'],
)
if field_list is None:
self.log_error(f'Could not get field info from {field}')
return False

all_fields.extend(field_list)

data_field = ','.join(all_fields)
self.env_var_dict['METPLUS_DATA_FIELD'] = f'field = [{data_field}];'
return True
50 changes: 5 additions & 45 deletions metplus/wrappers/tc_diag_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import os

from ..util import time_util
from . import RuntimeFreqWrapper
from . import TCBaseWrapper
from ..util import do_string_sub, get_lead_sequence
from ..util import parse_var_list, sub_var_list, getlist
from ..util import find_indices_in_config_section
Expand All @@ -25,7 +25,7 @@
'''


class TCDiagWrapper(RuntimeFreqWrapper):
class TCDiagWrapper(TCBaseWrapper):
RUNTIME_FREQ_DEFAULT = 'RUN_ONCE_PER_INIT_OR_VALID'
RUNTIME_FREQ_SUPPORTED = ['RUN_ONCE_PER_INIT_OR_VALID']

Expand Down Expand Up @@ -190,18 +190,7 @@ def create_c_dict(self):

self.handle_regrid(c_dict, set_to_grid=False)

self.add_met_config(name='compute_tangential_and_radial_winds',
data_type='bool')
self.add_met_config(name='u_wind_field_name', data_type='string')
self.add_met_config(name='v_wind_field_name', data_type='string')
self.add_met_config(name='tangential_velocity_field_name',
data_type='string')
self.add_met_config(name='tangential_velocity_long_field_name',
data_type='string')
self.add_met_config(name='radial_velocity_field_name',
data_type='string')
self.add_met_config(name='radial_velocity_long_field_name',
data_type='string')
self.add_met_config_tc_wind()

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

Expand Down Expand Up @@ -314,11 +303,11 @@ def run_at_time_once(self, time_info):
return

# get field information to set in MET config
if not self.set_data_field(time_info):
if not self._set_data_field(time_info):
return

# set forecast lead list for MET config
self.set_lead_list(time_info)
self._set_lead_list(time_info)

# get other configurations for command
self.set_command_line_arguments(time_info)
Expand All @@ -328,35 +317,6 @@ def run_at_time_once(self, time_info):

self.build()

def set_data_field(self, time_info):
"""!Get list of fields from config to process. Build list of field info
that are formatted to be read by the MET config file. Set DATA_FIELD
item of c_dict with the formatted list of fields.
Args:
@param time_info time dictionary to use for string substitution
@returns True if field list could be built, False if not.
"""
field_list = sub_var_list(self.c_dict['VAR_LIST_TEMP'], time_info)
if not field_list:
self.log_error("Could not get field information from config.")
return False

all_fields = []
for field in field_list:
field_list = self.get_field_info(d_type='FCST',
v_name=field['fcst_name'],
v_level=field['fcst_level'],
)
if field_list is None:
return False

all_fields.extend(field_list)

data_field = ','.join(all_fields)
self.env_var_dict['METPLUS_DATA_FIELD'] = f'field = [{data_field}];'

return True

def find_input_files(self, time_info):
"""!Get DECK file and list of input data files and set c_dict items.
Args:
Expand Down
Loading
Loading