Skip to content

Commit

Permalink
Feature #1626 TCDiag updates to wrapper and basic use case (#2248)
Browse files Browse the repository at this point in the history
Co-authored-by: Jonathan Vigh <jvigh@ucar.edu>
  • Loading branch information
georgemccabe and jvigh authored Jul 18, 2023
1 parent 618103f commit 050a833
Show file tree
Hide file tree
Showing 27 changed files with 234 additions and 85 deletions.
5 changes: 5 additions & 0 deletions .github/parm/use_case_groups.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
"index_list": "30-58",
"run": false
},
{
"category": "met_tool_wrapper",
"index_list": "62",
"run": false
},
{
"category": "air_quality_and_comp",
"index_list": "0",
Expand Down
6 changes: 6 additions & 0 deletions docs/Contributors_Guide/add_use_case.rst
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,12 @@ file.grib2, run the following command::

wgrib2 file.grib2 | grep TMP | wgrib2 -i file.grib2 -grib_out subset.grib2

The egrep command can be used for more complex subsetting of grib2 data.
Example: To create a file called subset.grib2 from file.grib2 that contains
PRMSL data and TMP data on 1000, 900, 800, 700, 500, and 100 mb levels::

wgrib2 file.grib2 -s | egrep '(:TMP:1000 mb:|:TMP:900 mb:|:TMP:800 mb:|:TMP:700 mb:|:TMP:500 mb:|:TMP:100 mb:|:PRMSL)' | wgrib2 -i file.grib2 -grib subset.grib2

If the input data is in NetCDF format, the
`ncks <http://nco.sourceforge.net/nco.html>`_ tool can be used to subset
the file(s).
Expand Down
3 changes: 3 additions & 0 deletions docs/Users_Guide/quicksearch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ METplus Quick Search for Use Cases


Use Cases by MET Tool:
======================

.. only:: html

Expand Down Expand Up @@ -163,6 +164,7 @@ Use Cases by METplus Feature:
| `Runtime Frequency <../search.html?q=RuntimeFreqUseCase&check_keywords=yes&area=default>`_
| `Series by Initialization <../search.html?q=SeriesByInitUseCase&check_keywords=yes&area=default>`_
| `Series by Forecast Lead <../search.html?q=SeriesByLeadUseCase&check_keywords=yes&area=default>`_
| `Tropical Cyclone <../search.html?q=TropicalCycloneUseCase&check_keywords=yes&area=default>`_
| `Validation of Models or Analyses <../search.html?q=ValidationUseCase&check_keywords=yes&area=default>`_
| `User Defined Script <../search.html?q=UserScriptUseCase&check_keywords=yes&area=default>`_
Expand Down Expand Up @@ -191,6 +193,7 @@ Use Cases by METplus Feature:
| **Runtime Frequency**: *RuntimeFreqUseCase*
| **Series by Initialization**: *SeriesByInitUseCase*
| **Series by Forecast Lead**: *SeriesByLeadUseCase*
| **Tropical Cyclone**: *TropicalCycloneUseCase*
| **Validation of Models or Analyses**: *ValidationUseCase*
| **User Defined Script**: *UserScriptUseCase*
Expand Down
2 changes: 1 addition & 1 deletion docs/Users_Guide/wrappers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7692,7 +7692,7 @@ TCDiag
Description
-----------

Used to configure the MET tool TC-Diag.
The TC-Diag wrapper encapsulates the behavior of the MET `tc_diag <https://met.readthedocs.io/en/develop/Users_Guide/tc-diag.html>`_ tool. It provides the infrastructure to compute diagnostics from model fields and tracks. It can be configured to run over a single intialization time, all of the initialization times for a given storm, or over many storms. Configuration also allows a user to select which domain(s) of the input model data to use in the diagnostics calculations, set which levels and variables will be used as well as details about the azimuth-range grid used for the calculations, and to control which output files are generated. Future functionality of the tc_diag tool, such as vortex removal, will also be configurable from this wrapper.

METplus Configuration
---------------------
Expand Down
52 changes: 45 additions & 7 deletions docs/use_cases/met_tool_wrapper/TCDiag/TCDiag.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,48 @@
met_tool_wrapper/TCDiag/TCDiag.conf
"""
##############################################################################
# Overview
# --------------------
#
# This use case illustrates the use of tc_diag tool, which is currently
# considered a beta-level release that lacks full functionality.
# The use case illustrates running the
# tc_diag tool for a tropical cyclone forecast case and generating
# intermediate NetCDF output files of the input model's data transformed
# onto an azimuth-range grid. When the full functionality of the
# tc_diag tool is released in MET v12.0.0, this use case will be also
# output environmental diagnostics computed from callable Python scripts.
#
# The diagnostics are computed on a range-azimuth grid that follows the
# projected storm track. For inputs, it uses 0.25 deg gridded GRIB files from the
# a retrospective reforecast of the Global Forecast System (GFS). For the track, it uses the
# GFS's predicted track to ensure that the model's simulated storm doesn't
# contaminate the diagnostics result as a result of the model's simulated
# storm being mistaken for environmental factors. (Note:
# a future version of the tc_diag tool will include removal of the model's vortex,
# allowing diagnostics to be computed along any arbitrarily defined track.)
#
# Novel aspects of this use case:
# * This is the first example use case to run the tc_diag tool.
# * Example of running for a single tropical cyclone forecast case from
# Tropical Storm Bret (2023) using GFS data.

##############################################################################
# Scientific Objective
# --------------------
#
# TODO: Add content here
# Generate intermediate data files, in which the input model's data have been
# transformed to a range-azimuth grid, in preparation for further diagnostic
# calculations using Python-based routines.

##############################################################################
# Datasets
# --------
#
# **Forecast:** GFS FV3
# **Track:** A Deck
# **Forecast:** GFS grib files
#
# **Track:** a-deck file (Automated Tropical Cyclone Forecast System format)
#
# **Location:** All of the input data required for this use case can be found
# in the met_test sample data tarball. Click here to the METplus releases page
Expand All @@ -26,6 +56,11 @@
# This tarball should be unpacked into the directory that you will set the
# value of INPUT_BASE. See `Running METplus`_ section for more information.
#
# **Data source:** Users may obtain real-time data from the deterministic GFS runs from
# NOAA's NOMADS server:
# https://nomads.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs.YYYYMMDD/ZZ/atmos/
# where YYYYMMDD is the date (4-digit year, 2-digit month, 2-digit day),
# ZZ is the initialization hour of the desired model cycle (00, 06, 12, 18).

##############################################################################
# METplus Components
Expand All @@ -42,8 +77,8 @@
# TCDiag is the only tool called in this example. It processes the following
# run times:
#
# **Init:** 2016-09-29- 00Z
# **Forecast lead:** 141, 143, and 147 hour
# **Init:** 2023-06-20 0000Z
# **Forecast lead:** 0, 6, and 12 hours
#

##############################################################################
Expand All @@ -67,7 +102,7 @@
# If there is a setting in the MET configuration file that is currently not supported by METplus you'd like to control, please refer to:
# :ref:`Overriding Unsupported MET config file settings<met-config-overrides>`
#
# .. note:: See the :ref:`TCDiag MET Configuration<tc-rmw-met-conf>` section of the User's Guide for more information on the environment variables used in the file below:
# .. note:: See the :ref:`TCDiag MET Configuration<tc-diag-met-conf>` section of the User's Guide for more information on the environment variables used in the file below:
#
# .. highlight:: bash
# .. literalinclude:: ../../../../parm/met_config/TCDiagConfig_wrapped
Expand Down Expand Up @@ -96,7 +131,8 @@
# Output for this use case will be found in met_tool_wrapper/TCDiag (relative to **OUTPUT_BASE**)
# and will contain the following files:
#
# * tc_diag_aal142016.nc
# * tc_diag_AL032023_GFSO_2023062012_cyl_grid_nest.nc
# * tc_diag_AL032023_GFSO_2023062012_cyl_grid_parent.nc
#

##############################################################################
Expand All @@ -105,8 +141,10 @@
#
# .. note::
#
# * DiagnosticsUseCase
# * TCDiagToolUseCase
# * GRIB2FileUseCase
# * TropicalCycloneUseCase
#
# Navigate to the :ref:`quick-search` page to discover other similar use cases.
#
Expand Down
1 change: 1 addition & 0 deletions docs/use_cases/met_tool_wrapper/TCGen/TCGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
#
# * TCGenToolUseCase
# * DTCOrgUseCase
# * TropicalCycloneUseCase
#
# Navigate to the :ref:`quick-search` page to discover other similar use cases.
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
# .. note::
#
# * TCMPRPlotterUseCase
# * TropicalCycloneUseCase
#
# Navigate to the :ref:`quick-search` page to discover other similar use cases.
#
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
#
# * TCPairsToolUseCase
# * SBUOrgUseCase
# * TropicalCycloneUseCase
#
# Navigate to the :ref:`quick-search` page to discover other similar use cases.
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
#
# * TCPairsToolUseCase
# * DTCOrgUseCase
# * TropicalCycloneUseCase
#
# Navigate to the :ref:`quick-search` page to discover other similar use cases.
#
Expand Down
1 change: 1 addition & 0 deletions docs/use_cases/met_tool_wrapper/TCRMW/TCRMW.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
#
# * TCRMWToolUseCase
# * GRIB2FileUseCase
# * TropicalCycloneUseCase
#
# Navigate to the :ref:`quick-search` page to discover other similar use cases.
#
Expand Down
1 change: 1 addition & 0 deletions docs/use_cases/met_tool_wrapper/TCStat/TCStat.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
# .. note::
#
# * TCStatToolUseCase
# * TropicalCycloneUseCase
#
# Navigate to the :ref:`quick-search` page to discover other similar use cases.
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@
# * SBUOrgUseCase
# * DiagnosticsUseCase
# * RuntimeFreqUseCase
# * TropicalCycloneUseCase
#
# Navigate to the :ref:`quick-search` page to discover other similar use cases.
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@
# * SBUOrgUseCase
# * DiagnosticsUseCase
# * RuntimeFreqUseCase
# * TropicalCycloneUseCase
#
# Navigate to the :ref:`quick-search` page to discover other similar use cases.
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@
# * SBUOrgUseCase
# * DiagnosticsUseCase
# * RuntimeFreqUseCase
# * TropicalCycloneUseCase
#
# Navigate to the :ref:`quick-search` page to discover other similar use cases.
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
# * TCPairsToolUseCase
# * SBUOrgUseCase
# * CyclonePlotterUseCase
# * TropicalCycloneUseCase
#
# Navigate to the :ref:`quick-search` page to discover other similar use cases.
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
#
# * TCandExtraTCAppUseCase
# * GridStatToolUseCase
# * TropicalCycloneUseCase
#
# Navigate to the :ref:`quick-search` page to discover other similar use cases.
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
# * NOAAEMCOrgUseCase
# * SBUOrgUseCase
# * DTCOrgUseCase
# * TropicalCycloneUseCase
#
# Navigate to the :ref:`quick-search` page to discover other similar use cases.
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
# * MediumRangeAppUseCase
# * SBUOrgUseCase
# * DTCOrgUseCase
# * TropicalCycloneUseCase
#
# Navigate to the :ref:`quick-search` page to discover other similar use cases.
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
# .. note::
#
# * TCGenToolUseCase
# * TropicalCycloneUseCase
#
# Navigate to the :ref:`quick-search` page to discover other similar use cases.
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
#
# * TCPairsToolUseCase
# * TCStatToolUseCase
# * TropicalCycloneUseCase
#
# Navigate to the :ref:`quick-search` page to discover other similar use cases.
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
#
# * TCRMWToolUseCase
# * GRIB2FileUseCase
# * TropicalCycloneUseCase
#
# Navigate to the :ref:`quick-search` page to discover other similar use cases.
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
# * UserScriptUseCase
# * PointStatToolUseCase
# * ASCII2NCToolUseCase
# * TropicalCycloneUseCase
#
# Navigate to the :ref:`quick-search` page to discover other similar use cases.
#
Expand Down
23 changes: 13 additions & 10 deletions internal/tests/pytests/wrappers/tc_diag/test_tc_diag_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

deck_template = 'aal14{date?fmt=%Y}_short.dat'
input_template = 'gfs.subset.t00z.pgrb2.0p25.f*'
output_template = 'tc_diag_aal14{date?fmt=%Y}.nc'
output_template = '{date?fmt=%Y}'

time_fmt = '%Y%m%d%H'
run_times = ['2016092900']
Expand All @@ -24,6 +24,9 @@
'{ name="TMP"; level="P100"; }];'
)

input_domain = 'parent'
input_tech_id_list = 'GFSO'


def get_data_dir(config):
return os.path.join(config.getdir('METPLUS_BASE'),
Expand All @@ -46,9 +49,11 @@ def set_minimum_config_settings(config):
config.set('config', 'TC_DIAG_CONFIG_FILE',
'{PARM_BASE}/met_config/TCDiagConfig_wrapped')
config.set('config', 'TC_DIAG_DECK_TEMPLATE', deck_template)
config.set('config', 'TC_DIAG_INPUT_TEMPLATE', input_template)
config.set('config', 'TC_DIAG_INPUT1_TEMPLATE', input_template)
config.set('config', 'TC_DIAG_INPUT1_DOMAIN', input_domain)
config.set('config', 'TC_DIAG_INPUT1_TECH_ID_LIST', input_tech_id_list)
config.set('config', 'TC_DIAG_OUTPUT_DIR',
'{OUTPUT_BASE}/TCDiag/output')
'{OUTPUT_BASE}/tc_diag')
config.set('config', 'TC_DIAG_OUTPUT_TEMPLATE', output_template)

config.set('config', 'BOTH_VAR1_NAME', 'PRMSL')
Expand Down Expand Up @@ -231,13 +236,11 @@ def test_tc_diag_run(metplus_config, config_overrides,
config_file = wrapper.c_dict.get('CONFIG_FILE')
out_dir = wrapper.c_dict.get('OUTPUT_DIR')

expected_cmds = [(f"{app_path} "
f"-deck {deck_dir}/aal142016_short.dat "
f"-data {file_list_file} "
f"-config {config_file} "
f"-out {out_dir}/tc_diag_aal142016.nc "
f"{verbosity}"),
]
expected_cmds = [
(f"{app_path} -deck {deck_dir}/aal142016_short.dat "
f"-data {input_domain} {input_tech_id_list} {file_list_file} "
f"-config {config_file} -outdir {out_dir}/2016/ {verbosity}"),
]

all_cmds = wrapper.run_all_times()
print(f"ALL COMMANDS: {all_cmds}")
Expand Down
2 changes: 1 addition & 1 deletion internal/tests/use_cases/all_use_cases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Category: met_tool_wrapper
59::IODA2NC::met_tool_wrapper/IODA2NC/IODA2NC.conf
60::PointStat_python_embedding_obs:: met_tool_wrapper/PointStat/PointStat_python_embedding_obs.conf
61::PlotPointObs:: met_tool_wrapper/PlotPointObs/PlotPointObs.conf
#62::TCDiag:: met_tool_wrapper/TCDiag/TCDiag.conf
62::TCDiag:: met_tool_wrapper/TCDiag/TCDiag.conf

Category: air_quality_and_comp
0::EnsembleStat_fcstICAP_obsMODIS_aod::model_applications/air_quality_and_comp/EnsembleStat_fcstICAP_obsMODIS_aod.conf
Expand Down
Loading

0 comments on commit 050a833

Please sign in to comment.