4. Python Wrappers

This chapter provides a description of each supported Python wrapper in METplus Wrappers. A wrapper is generally a Python script that encapsulates the behavior of a corresponding MET tool. Each of these sections can be added to the PROCESS_LIST configuration list variable. The Configuration section of each wrapper section below lists the METplus Wrappers configuration variables that are specific to that wrapper organized by config file section. You can find more information about each item in the METplus Configuration Glossary.

4.2. CyclonePlotter

4.2.1. Description

This wrapper does not have a corresponding MET tool but instead wraps the logic necessary to create plots of cyclone tracks. Currently only the output from the MET tc-pairs tool can be plotted.

4.3. EnsembleStat

4.3.1. Description

Used to configure the MET tool ensemble_stat.

4.4. Example

4.4.1. Description

Used to demonstrate how the METplus wrappers handle looping and building commands.

4.4.2. Configuration

[dir]

[filename_templates]

[config] | EXAMPLE_CUSTOM_LOOP_LIST

4.5. ExtractTiles

4.5.1. 3.5.1 Description

The ExtractTiles wrapper is used to regrid and extract subregions from paired tropical cyclone tracks that are created by the tc_pairs_wrapper. Unlike the other wrappers, the extract_tiles_wrapper does not correspond to a specific MET tool. It invokes the tc_stat_wrapper, which in turn calls the MET tc_stat tool to determine the lat/lon positions of the paired track data. This information is then used to create tiles of subregions. The ExtractTiles wrapper creates a 2n degree x 2m degree grid/tile with each storm located at the center.

4.6. GempakToCF

4.6.1. Description

Used to configure the utility GempakToCF.

4.8. GridDiag

4.8.1. Description

Used to configure the MET tool grid_diag.

4.8.3. MET Configuration

This is the MET configuration file used for this wrapper. Below the file contents are descriptions of each environment variable referenced in this file and how the METplus configuration variables relate to them.

////////////////////////////////////////////////////////////////////////////////
//
// Grid-Diag configuration file.
//
// For additional information, see the MET_BASE/config/README file.
//
////////////////////////////////////////////////////////////////////////////////

//
// Description
//
${DESC}

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

//
// Output grid
//
${REGRID_DICT}

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

//
// May be set separately in each "field" entry
//
censor_thresh = [];
censor_val    = [];

//
// Data fields
//
data = {
   field = [ ${DATA_FIELD} ];
}

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

mask = {
   grid = "";
   ${VERIF_MASK}
}

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

version = "V9.1";

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

The following environment variables are referenced in the MET configuration file. The values are generated based on values in the METplus configuration files.

${MODEL} - Corresponds to MODEL in the METplus configuration file. If unset in METplus, value set in the default MET TCRMW configuration file will be used.

METplus Configuration:

[config]
MODEL = GFS

Resulting value:

model = "GFS";

${DATA_FIELD} - Formatted input field information. Generated from [FCST/BOTH]_VAR<n>_[NAME/LEVEL/THRESH/OPTIONS] in the METplus configuration file.

METplus Configuration:

[config]
BOTH_VAR1_NAME = APCP
BOTH_VAR1_LEVELS = L0
BOTH_VAR1_OPTIONS = n_bins = 55; range  = [0, 55];

BOTH_VAR2_NAME = PWAT
BOTH_VAR2_LEVELS =  L0
BOTH_VAR2_OPTIONS = n_bins = 35; range  = [35, 70];

Resulting value:

{ name="APCP"; level="L0"; n_bins = 55; range  = [0, 55]; },{ name="PWAT"; level="L0"; n_bins = 35; range  = [35, 70];}

${DATA_FILE_TYPE} - Type of input data set only if necessary to allow MET to read the data. Generated from GRID_DIAG_INPUT_DATATYPE in the METplus configuration file.

METplus Configuration:

[config]
GRID_DIAG_INPUT_DATATYPE = GRIB2

Resulting value:

file_type = GRIB2;

${REGRID_DICT} - Corresponds to GRID_DIAG_REGRID_METHOD, GRID_DIAG_REGRID_WIDTH, GRID_DIAG_REGRID_VLD_THRESH, GRID_DIAG_REGRID_SHAPE, and GRID_DIAG_REGRID_TO_GRID in the METplus configuration file. If any of these variables are unset in METplus, value set in the default MET GridDiag configuration file will be used.

METplus Configuration 1:

[config]
GRID_DIAG_REGRID_SHAPE = SQUARE

Resulting value 1:

regrid = {shape = SQUARE;}

METplus Configuration 2:

[config]
GRID_DIAG_REGRID_WIDTH = 2
GRID_DIAG_REGRID_SHAPE = SQUARE

Resulting value 2:

regrid = {width = 2; shape = SQUARE;}

METplus Configuration 3:

[config]
GRID_DIAG_REGRID_WIDTH = 2
GRID_DIAG_REGRID_SHAPE = SQUARE
GRID_DIAG_REGRID_TO_GRID = NONE

Resulting value 2:

regrid = {to_grid = NONE; width = 2; shape = SQUARE;}

${VERIF_MASK} - Path to verification mask file. Generated from GRID_DIAG_VERIFICATION_MASK_TEMPLATE in the METplus configuration file. Filename template syntax can be used in here to find a file based on run time, i.e. file.{valid?fmt=%Y%m%d%H}.ext

METplus Configuration:

[filename_templates]
GRID_DIAG_VERIFICATION_MASK_TEMPLATE = MET_BASE/poly/SAO.poly

Resulting value:

poly = "MET_BASE/poly/SAO.poly";

4.9. GridStat

4.9.1. Description

Used to configure the MET tool grid_stat.

4.12. MTD

4.12.1. Description

Used to configure the MET MODE Time Domain tool mtd. This tools follows objects through time and can also be used to track objects.

4.14. PCPCombine

4.14.1. Description

The PCPCombine wrapper is a Python script that encapsulates the MET PCPCombine tool. It provides the infrastructure to combine or extract from files to build desired accumulations.

4.14.2. Configuration

[dir]

[filename_templates]

[config]

4.15. Point2Grid

4.15.1. Description

The Point2Grid wrapper is a Python script that encapsulates the MET point2grid tool. It provides the infrastructure to read in point observations and place them on a grid

4.16. PointStat

4.16.1. Description

The PointStat wrapper is a Python script that encapsulates the MET point_stat tool. It provides the infrastructure to read in gridded model data and netCDF point observation data to perform grid-to-point (grid-to-obs) verification.

4.16.2. Configuration

[dir]

[filename_templates]

[config]

4.17. PyEmbedIngest

4.17.1. Description

Used to configure the PyEmbedIngest wrapper that runs RegridDataPlane to convert data using python embedding scripts into NetCDF so it can be read by the MET tools.

4.20. SeriesByInit

4.20.1. Description

The SeriesByInit wrapper provides the infrastructure needed to demonstrates the use of the series analysis tool using tropical cyclone data, based on initialization times. The SeriesByInit_wrapper creates numerous plots that represent the field, level, and statistic for each initialization time.

4.21. SeriesByLead

4.21.1. Description

The SeriesByLead wrapper provides the infrastructure needed to perform a series analysis on tropical cyclone data, based on lead (forecast hour) times. The SeriesByLead wrapper creates numerous plots that represent the field, level, and statistic for each lead (forecast) time. The SeriesByLead can be done in one of two ways: by all forecast hours or by forecast hour groupings. Performing a series analysis by valid time with forecast hour groupings can be useful when analyzing storm tracks based on time ‘bins’ such as by days (eg. day 1, day 2, day 3, etc.).

4.21.2. Configuration

The input track and model data files are defined in any one of the user’s METplus Wrappers configuration files. If creating a final configuration file that overrides all other config files, it is customary to define the MODEL_DATA_DIR, pointing to the directory where all model data resides. The full file path to the INIT_INCLUDE and INIT_EXCLUDE are used to list the times in YYYYMMDD_HH format to include or exclude from your time window. If these values are undefined (i.e. no value is set for the variable), then all available times in your time window will be considered. For example, if your data is available every 6 hours and you are interested in creating a series analysis from init time 20180601 to 20180615 for all available times, from 00z to 23z, you would set the following:

[dir]

[regex_patterns]

[config]

4.22. StatAnalysis

4.22.1. Description

The StatAnalysis wrapper encapsulates the behavior of the MET stat_analysis tool. It provides the infrastructure to summarize and filter the MET .stat files. StatAnalysis wrapper can be run in two different methods. First is to look at the STAT lines for a single date, to use this method set LOOP_ORDER = times. Second is to look at the STAT lines over a span of dates, to use this method set LOOP_ORDER = processes. To run StatAnalysis wrapper, include StatAnalysis in PROCESS_LIST.

4.22.2. Configuration

The following values must be defined in the METplus Wrappers configuration file for running with LOOP_ORDER = times:

[dir]

[filename_templates]

[config]

The following values are optional in the METplus Wrappers configuration file for running with LOOP_ORDER = times:

[config]

The following values must be defined in the METplus Wrappers configuration file for running with LOOP_ORDER = processes:

[dir]

[config]

The following values are optional in the METplus Wrappers configuration file for running with LOOP_ORDER = processes:

4.24. TCMPRPlotter

4.24.1. Description

The TCMPRPlotter wrapper is a Python script that wraps the R script plot_tcmpr.R. This script is useful for plotting the calculated statistics for the output from the MET-TC tools. This script, and other R scripts are included in the MET installation. Please refer to section 21.2.3 of the MET User’s Guide for usage information.

4.25. TCPairs

4.25.1. Description

The TCPairs wrapper encapsulates the behavior of the MET tc_pairs tool. The wrapper accepts Adeck and Bdeck (Best track) cyclone track data in extra tropical cyclone format (such as the data used by sample data provided in the METplus tutorial), or ATCF formatted track data. If data is in an extra tropical cyclone (non-ATCF) format, the data is reformatted into an ATCF format that is recognized by MET.

4.26. TCRMW

4.26.1. Description

Used to configure the MET tool TC-RMW.

4.26.3. MET Configuration

This is the MET configuration file used for this wrapper. Below the file contents are descriptions of each environment variable referenced in this file and how the METplus configuration variables relate to them.

////////////////////////////////////////////////////////////////////////////////
//
// TC-RMW configuration file.
//
// For additional information, see the MET_BASE/config/README_TC file.
//
////////////////////////////////////////////////////////////////////////////////

// The following environment variables set the text if the corresponding
// variables at defined in the METplus config. If not, they are set to
// and empty string, which will cause MET to use the value defined in the
// default configuration file.
// ${MODEL} sets "model = <user setting>;"
// ${STORM_ID} sets "storm_id = <user setting>;"
// ${BASIN} sets "basin = <user setting>;"
// ${CYCLONE} sets "cyclone = <user setting>;"
// ${STORM_NAME} sets " = <user setting>;"
// ${INIT_INCLUDE} sets "init_inc = <user setting>;"
// ${VALID_BEG} sets "valid_beg = <user setting>;"
// ${VALID_END} sets "valid_end = <user setting>;"
// ${VALID_INCLUDE_LIST} sets "valid_inc = [<user setting>];"
// ${VALID_EXCLUDE_LIST} sets "valid_exc = [<user setting>];"
// ${VALID_HOUR_LIST} sets "valid_hour = [<user setting>];"
// ${LEAD_LIST} sets "lead = [<user setting>];"

${MODEL}

${STORM_ID}
${BASIN}
${CYCLONE}
${INIT_INCLUDE}

${VALID_BEG}
${VALID_END}
${VALID_INCLUDE_LIST}
${VALID_EXCLUDE_LIST}

${VALID_HOUR_LIST}
${LEAD_LIST}

//
// May be set separately in each "field" entry
//
censor_thresh = [];
censor_val    = [];

//
// Data fields
//
data = {
   ${DATA_FILE_TYPE}

   field = [ ${DATA_FIELD} ];
}

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

//
// Regridding options
//
${REGRID_DICT}

//
// Range-Azimuth grid parameters 
//
// The following environmnet variables set the text if the corresponding
// variables at defined in the METplus config. If not, they are set to
// and empty string, which will cause MET to use the value defined in the
// default configuration file.
// ${N_RANGE} sets "n_range = <user setting>;"
// ${N_AZIMUTH} sets "n_azimuth = <user setting>;"
// ${MAX_RANGE_KM} sets "max_range_km = <user setting>;"
// ${DELTA_RANGE_KM} sets "delta_range_km = <user setting>;"
// ${RMW_SCALE} sets "rmw_scale = <user setting>;"

${N_RANGE}
${N_AZIMUTH}
${MAX_RANGE_KM}
${DELTA_RANGE_KM}
${RMW_SCALE}

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

version = "V9.1";

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

The following environment variables are referenced in the MET configuration file. The values are generated based on values in the METplus configuration files.

${MODEL} - Corresponds to MODEL in the METplus configuration file. If unset in METplus, value set in the default MET TCRMW configuration file will be used.

METplus Configuration:

[config]
MODEL = GFS

Resulting value:

model = "GFS";

${STORM_ID} - Corresponds to TC_RMW_STORM_ID in the METplus configuration file. If unset in METplus, value set in the default MET TCRMW configuration file will be used.

METplus Configuration:

[config]
TC_RMW_STORM_ID = al062018

Resulting value:

storm_id = "al062018";

${BASIN} - Corresponds to TC_RMW_BASIN in the METplus configuration file. If unset in METplus, value set in the default MET TCRMW configuration file will be used.

METplus Configuration:

[config]
TC_RMW_BASIN = AL

Resulting value:

basin = "AL";

${CYCLONE} - Corresponds to TC_RMW_CYCLONE in the METplus configuration file. If unset in METplus, value set in the default MET TCRMW configuration file will be used.

METplus Configuration:

[config]
TC_RMW_CYCLONE = 06

Resulting value:

cyclone = "06";

${STORM_NAME} - Corresponds to TC_RMW_STORM_NAME in the METplus configuration file. If unset in METplus, value set in the default MET TCRMW configuration file will be used.

METplus Configuration:

[config]
TC_RMW_STORM_NAME = al062018

Resulting value:

storm_name = "al062018";

${INIT_INCLUDE} - Corresponds to TC_RMW_INIT_INCLUDE in the METplus configuration file. If unset in METplus, value set in the default MET TCRMW configuration file will be used.

METplus Configuration:

[config]
TC_RMW_INIT_INCLUDE = 20101231_06

Resulting value:

init_inc = "20101231_06";

Resulting value:

init_exc = "20101231_00";

${VALID_BEG} - Corresponds to TC_RMW_VALID_BEG in the METplus configuration file. If unset in METplus, value set in the default MET TCRMW configuration file will be used.

METplus Configuration:

[config]
TC_RMW_VALID_BEG = 20100101

Resulting value:

valid_beg = "20100101";

${VALID_END} - Corresponds to TC_RMW_VALID_END in the METplus configuration file. If unset in METplus, value set in the default MET TCRMW configuration file will be used.

METplus Configuration:

[config]
TC_RMW_VALID_END = 20101231_12

Resulting value:

valid_end = "20101231_12";

${VALID_INCLUDE_LIST} - Corresponds to TC_RMW_VALID_INCLUDE_LIST in the METplus configuration file. If unset in METplus, value set in the default MET TCRMW configuration file will be used.

METplus Configuration:

[config]
TC_RMW_VALID_INCLUDE_LIST = 20101231_06, 20101231_12

Resulting value:

valid_inc = [ "20101231_06", "20101231_12" ];

${VALID_EXCLUDE_LIST} - Corresponds to TC_RMW_VALID_EXCLUDE_LIST in the METplus configuration file. If unset in METplus, value set in the default MET TCRMW configuration file will be used.

METplus Configuration:

[config]
TC_RMW_VALID_EXCLUDE_LIST = 20101231_00, 20101231_03

Resulting value:

valid_exc = [ "20101231_00", "20101231_03" ];

${VALID_HOUR_LIST} - Corresponds to TC_RMW_VALID_HOUR_LIST in the METplus configuration file. If unset in METplus, value set in the default MET TCRMW configuration file will be used.

METplus Configuration:

[config]
TC_RMW_VALID_HOUR_LIST = 12, 15

Resulting value:

valid_hour = [ "12", "15" ];

${LEAD_LIST} - Corresponds to LEAD_SEQ in the METplus configuration file. If unset in METplus, value set in the default MET TCRMW configuration file will be used.

METplus Configuration:

[config]
LEAD_SEQ = 6, 12, 18, 24

Resulting value:

lead = ["06", "12", "18", "24"];

${DATA_FIELD} - Formatted input field information. Generated from [FCST/BOTH]_VAR<n>_[NAME/LEVEL/THRESH/OPTIONS] in the METplus configuration file.

METplus Configuration:

[config]
BOTH_VAR1_NAME = PRMSL
BOTH_VAR1_LEVELS = L0
BOTH_VAR2_NAME = TMP
BOTH_VAR2_LEVELS = P1000, P750

Resulting value:

{ name="PRMSL"; level="L0"; },{ name="TMP"; level="P1000"; },{ name="TMP"; level="P750"; }

${DATA_FILE_TYPE} - Type of input data set only if necessary to allow MET to read the data. Generated from TC_RMW_INPUT_DATATYPE in the METplus configuration file.

METplus Configuration:

[config]
TC_RMW_INPUT_DATATYPE = GRIB2

Resulting value:

file_type = GRIB2;

${N_RANGE} - Corresponds to TC_RMW_N_RANGE in the METplus configuration file. If unset in METplus, value set in the default MET TCRMW configuration file will be used.

METplus Configuration:

[config]
TC_RMW_N_RANGE = 100

Resulting value:

n_range = 100;

${N_AZIMUTH} - Corresponds to TC_RMW_N_AZIMUTH in the METplus configuration file. If unset in METplus, value set in the default MET TCRMW configuration file will be used.

METplus Configuration:

[config]
TC_RMW_N_AZIMUTH = 180

Resulting value:

n_azimuth = 180;

${MAX_RANGE_KM} - Corresponds to TC_RMW_MAX_RANGE_KM in the METplus configuration file. If unset in METplus, value set in the default MET TCRMW configuration file will be used.

METplus Configuration:

[config]
TC_RMW_MAX_RANGE_KM = 1000.0

Resulting value:

max_range_km = 1000.0;

${DELTA_RANGE_KM} - Corresponds to TC_RMW_DELTA_RANGE_KM in the METplus configuration file. If unset in METplus, value set in the default MET TCRMW configuration file will be used.

METplus Configuration:

[config]
TC_RMW_DELTA_RANGE_KM = 10.0

Resulting value:

delta_range_km = 10.0;

${RMW_SCALE} - Corresponds to TC_RMW_SCALE in the METplus configuration file. If unset in METplus, value set in the default MET TCRMW configuration file will be used.

METplus Configuration:

[config]
TC_RMW_SCALE = 0.2

Resulting value:

rmw_scale = 0.2;

${REGRID_DICT} - Corresponds to TC_RMW_REGRID_METHOD, TC_RMW_REGRID_WIDTH, TC_RMW_REGRID_VLD_THRESH, and TC_RMW_REGRID_SHAPE in the METplus configuration file. If any of these variables are unset in METplus, value set in the default MET TCRMW configuration file will be used.

METplus Configuration 1:

[config]
TC_RMW_REGRID_SHAPE = SQUARE

Resulting value 1:

regrid = {shape = SQUARE;}

METplus Configuration 2:

[config]
TC_RMW_REGRID_WIDTH = 2
TC_RMW_REGRID_SHAPE = SQUARE

Resulting value 2:

regrid = {width = 2; shape = SQUARE;}