5.1.14.1. SeriesAnalysis: Basic Use Case

This use case will run the MET Seriesi-Analysis tool over a series of input files and computes the selected statistics. Several optional adjustments are presented but not used in this example, including the ability to loop over a list of strings that will run Series-Analysis multiple times for varying filename templates.

Scientific Objective

Compare forecasts for 3-hour precipitation accumulations to observed 3-hour accumulation. These comparisons are made through generating statistics of the results.

Datasets

Forecast: WRF 3 hour precipitation accumulation
Observation: MU 3 hour precipitation accumulation
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 and download sample data for the appropriate release: https://github.com/NCAR/METplus/releases
This tarball should be unpacked into the directory that you will set the value of INPUT_BASE. See ‘Running METplus’ section for more information.

METplus Components

This use case utilizes the METplus SeriesAnalysis wrapper to search for files that are valid at a given run time and generates a command to run the MET tool series_analysis if all required files are found.

METplus Workflow

SeriesAnalysis is the only tool called in this example. It processes the following run times:

Init: 2005-08-07_0Z
Forecast lead: 12 hour

METplus Configuration

METplus first loads all of the configuration files found in parm/metplus_config, then it loads any configuration files passed to METplus via the command line with the -c option, i.e. -c parm/use_cases/met_tool_wrapper/SeriesAnalysis/SeriesAnalysis.conf

# SeriesAnalysis METplus Configuration

# section heading for [config] variables - all items below this line and
# before the next section heading correspond to the [config] section
[config]

# List of applications to run - only SeriesAnalysis for this case
PROCESS_LIST = SeriesAnalysis

# time looping - options are INIT, VALID, RETRO, and REALTIME
# If set to INIT or RETRO:
#   INIT_TIME_FMT, INIT_BEG, INIT_END, and INIT_INCREMENT must also be set
# If set to VALID or REALTIME:
#   VALID_TIME_FMT, VALID_BEG, VALID_END, and VALID_INCREMENT must also be set
LOOP_BY = INIT

# Format of INIT_BEG and INT_END using % items
# %Y = 4 digit year, %m = 2 digit month, %d = 2 digit day, etc.
# see www.strftime.org for more information
# %Y%m%d%H expands to YYYYMMDDHH
INIT_TIME_FMT = %Y%m%d%H

# Start time for METplus run - must match INIT_TIME_FMT
INIT_BEG=2005080700

# End time for METplus run - must match INIT_TIME_FMT
INIT_END=2005080700

# Increment between METplus runs (in seconds if no units are specified)
#  Must be >= 60 seconds
INIT_INCREMENT = 12H

# List of forecast leads to process for each run time (init or valid)
# In hours if units are not specified
# If unset, defaults to 0 (don't loop through forecast leads)
LEAD_SEQ = 12

# list of strings to loop over to run SeriesAnalysis multiple times for a
# given run time. Each item can be referenced using the filename template
# syntax {custom?fmt=%s}
# Not used in this example
SERIES_ANALYSIS_CUSTOM_LOOP_LIST = 

# Order of loops to process data - Options are times, processes
# Not relevant if only one item is in the PROCESS_LIST
# times = run all wrappers in the PROCESS_LIST for a single run time, then
#   increment the run time and run all wrappers again until all times have
#   been evaluated.
# processes = run the first wrapper in the PROCESS_LIST for all times
#   specified, then repeat for the next item in the PROCESS_LIST until all
#   wrappers have been run
LOOP_ORDER = processes

# Verbosity of MET output - overrides LOG_VERBOSITY for SeriesAnalysis only
#LOG_SERIES_ANALYSIS_VERBOSITY = 2

# set to True to add the -paired flag to the SeriesAnalysis command
SERIES_ANALYSIS_IS_PAIRED = False

# Location of MET config file to pass to SeriesAnalysis
# References CONFIG_DIR from the [dir] section
SERIES_ANALYSIS_CONFIG_FILE = {CONFIG_DIR}/SeriesAnalysisConfig_wrapped

# list of statistics to generate with SeriesAnalysis
SERIES_ANALYSIS_STAT_LIST = TOTAL, RMSE, FBAR, OBAR

# grid to remap data. Value is set as the 'to_grid' variable in the 'regrid' dictionary
# See MET User's Guide for more information
SERIES_ANALYSIS_REGRID_TO_GRID = NONE

# Name to identify model (forecast) data in output
MODEL = WRF

# Name to identify observation data in output
OBTYPE = MC_PCP

# List of variables to compare in SeriesAnalysis - FCST_VAR1 variables correspond
#  to OBS_VAR1 variables
# Note [FCST/OBS/BOTH]_SERIES_ANALYSIS_VAR<n>_NAME can be used instead if different evaluations
# are needed for different tools

# Name of forecast variable 1
FCST_VAR1_NAME = APCP

# List of levels to evaluate for forecast variable 1
# A03 = 3 hour accumulation in GRIB file
FCST_VAR1_LEVELS = A03

# Name of observation variable 1
OBS_VAR1_NAME = APCP_03


# List of levels to evaluate for observation variable 1
# (*,*) is NetCDF notation - must include quotes around these values!
# must be the same length as FCST_VAR1_LEVELS
OBS_VAR1_LEVELS = "(*,*)"

# List of thresholds to evaluate for each name/level combination for
#  both forecast and observation variable 1
BOTH_VAR1_THRESH = gt12.7, gt25.4, gt50.8, gt76.2


# End of [config] section and start of [dir] section
[dir]

# location of configuration files used by MET applications
CONFIG_DIR={PARM_BASE}/met_config

# directory containing forecast input to SeriesAnalysis
FCST_SERIES_ANALYSIS_INPUT_DIR = {INPUT_BASE}/met_test/data/sample_fcst

# directory containing observation input to SeriesAnalysis
OBS_SERIES_ANALYSIS_INPUT_DIR = {INPUT_BASE}/met_test/new

# directory containing climatology mean input to SeriesAnalysis
# Not used in this example
SERIES_ANALYSIS_CLIMO_MEAN_INPUT_DIR =

# directory containing climatology standard deviation input to SeriesAnalysis
# Not used in this example
SERIES_ANALYSIS_CLIMO_STDEV_INPUT_DIR =

# directory to write output from SeriesAnalysis
SERIES_ANALYSIS_OUTPUT_DIR = {OUTPUT_BASE}/met_tool_wrapper/SeriesAnalysis

# End of [dir] section and start of [filename_templates] section
[filename_templates]

# Template to look for forecast input to SeriesAnalysis relative to FCST_SERIES_ANALYSIS_INPUT_DIR
FCST_SERIES_ANALYSIS_INPUT_TEMPLATE = {init?fmt=%Y%m%d%H}/wrfprs_ruc13_{lead?fmt=%HH}.tm00_G212,
                                      {init?fmt=%Y%m%d%H}/wrfprs_ruc13_{lead?fmt=%HH?shift=-3H}.tm00_G212,
                                      {init?fmt=%Y%m%d%H}/wrfprs_ruc13_{lead?fmt=%HH?shift=-6H}.tm00_G212

# Template to look for observation input to SeriesAnalysis relative to OBS_SERIES_ANALYSIS_INPUT_DIR
OBS_SERIES_ANALYSIS_INPUT_TEMPLATE = ST2ml{valid?fmt=%Y%m%d%H}_A03h.nc,
                                     ST2ml{valid?fmt=%Y%m%d%H?shift=-3H}_A03h.nc,
                                     ST2ml{valid?fmt=%Y%m%d%H?shift=-6H}_A03h.nc

# Optional subdirectories relative to SERIES_ANALYSIS_OUTPUT_DIR to write output from SeriesAnalysis
SERIES_ANALYSIS_OUTPUT_TEMPLATE = {init?fmt=%Y%m%d%H}_sa.nc

# Template to look for climatology mean input to SeriesAnalysis relative to SERIES_ANALYSIS_CLIMO_MEAN_INPUT_DIR
# Not used in this example
SERIES_ANALYSIS_CLIMO_MEAN_INPUT_TEMPLATE =

# Template to look for climatology standard deviation input to SeriesAnalysis relative to SERIES_ANALYSIS_CLIMO_STDEV_INPUT_DIR
# Not used in this example
SERIES_ANALYSIS_CLIMO_STDEV_INPUT_TEMPLATE =

MET Configuration

METplus sets environment variables based on the values in the METplus configuration file. These variables are referenced in the MET configuration file. YOU SHOULD NOT SET ANY OF THESE ENVIRONMENT VARIABLES YOURSELF! THEY WILL BE OVERWRITTEN BY METPLUS WHEN IT CALLS THE MET TOOLS! If there is a setting in the MET configuration file that is not controlled by an environment variable, you can add additional environment variables to be set only within the METplus environment using the [user_env_vars] section of the METplus configuration files. See the ‘User Defined Config’ section on the ‘System Configuration’ page of the METplus User’s Guide for more information.

////////////////////////////////////////////////////////////////////////////////
//
// Series-Analysis configuration file.
//
// For additional information, see the MET_BASE/config/README file.
//
////////////////////////////////////////////////////////////////////////////////

//
// Output model name to be written
//
model = "${MODEL}";

//
// Output description to be written
//
desc = "NA";

//
// Output observation type to be written
//
obtype = "${OBTYPE}";

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

//
// Verification grid
// May be set separately in each "field" entry
//
regrid = {
   to_grid    = ${REGRID_TO_GRID};
   method     = NEAREST;
   width      = 1;
   vld_thresh = 0.5;
   shape      = SQUARE;
}

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

censor_thresh = [];
censor_val    = [];
cat_thresh    = [ NA ];
cnt_thresh    = [ NA ];
cnt_logic     = UNION;

//
// Forecast and observation fields to be verified
//
fcst = {
   ${FCST_FILE_TYPE}

   field = [ ${FCST_FIELD} ];
}
obs = {
   ${OBS_FILE_TYPE}

   field = [ ${OBS_FIELD} ];
}

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

//
// Climatology data
//
climo_mean = {

   file_name = [ ${CLIMO_MEAN_FILE} ];
   field     = [];

   regrid = {
      method     = NEAREST;
      width      = 1;
      vld_thresh = 0.5;
      shape      = SQUARE;
   }

   time_interp_method = DW_MEAN;
   day_interval       = 31;
   hour_interval      = 6;
}

climo_stdev = climo_mean;
climo_stdev = {
   file_name = [ ${CLIMO_STDEV_FILE} ];
}

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

//
// Confidence interval settings
//
ci_alpha  = [ 0.05 ];

boot = {
   interval = PCTILE;
   rep_prop = 1.0;
   n_rep    = 0;
   rng      = "mt19937";
   seed     = "";
}

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

//
// Verification masking regions
//
mask = {
   grid = "";
   poly = "";
}

//
// Number of grid points to be processed concurrently.  Set smaller to use
// less memory but increase the number of passes through the data.
//
block_size = 1024;

//
// Ratio of valid matched pairs to compute statistics for a grid point
//
vld_thresh = 1.0;

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

//
// Statistical output types
//
output_stats = {
   fho    = [];
   ctc    = [];
   cts    = [];
   mctc   = [];
   mcts   = [];
   cnt    = ${STAT_LIST};
   sl1l2  = [];
   sal1l2 = [];
   pct    = [];
   pstd   = [];
   pjc    = [];
   prc    = [];
}

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

rank_corr_flag = FALSE;
tmp_dir        = "/tmp";
version        = "V9.0";

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

Note the following variables are referenced in the MET configuration file.

  • ${MODEL} - Name of forecast input. Corresponds to MODEL in the METplus configuration file.

  • ${OBTYPE} - Name of observation input. Corresponds to OBTYPE in the METplus configuration file.

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

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

  • ${REGRID_TO_GRID} - Grid to remap data. Corresponds to SERIES_ANALYSIS_REGRID_TO_GRID in the METplus configuration file.

  • ${CLIMO_MEAN_FILE} - Optional path to climatology mean file. Corresponds to SERIES_ANALYSIS_CLIMO_MEAN_INPUT_[DIR/TEMPLATE] in the METplus configuration file.

  • ${CLIMO_STDEV_FILE} - Optional path to climatology standard deviation file. Corresponds to SERIES_ANALYSIS_CLIMO_STDEV_INPUT_[DIR/TEMPLATE] in the METplus configuration file.

Running METplus

This use case can be run two ways:

  1. Passing in SeriesAnalysis.conf then a user-specific system configuration file:

    master_metplus.py -c /path/to/METplus/parm/use_cases/met_tool_wrapper/SeriesAnalysis/SeriesAnalysis.conf -c /path/to/user_system.conf
    
  2. Modifying the configurations in parm/metplus_config, then passing in SeriesAnalysis.conf:

    master_metplus.py -c /path/to/METplus/parm/use_cases/met_tool_wrapper/SeriesAnalysis/SeriesAnalysis.conf
    

The former method is recommended. Whether you add them to a user-specific configuration file or modify the metplus_config files, the following variables must be set correctly:

  • INPUT_BASE - Path to directory where sample data tarballs are unpacked (See Datasets section to obtain tarballs). This is not required to run METplus, but it is required to run the examples in parm/use_cases

  • OUTPUT_BASE - Path where METplus output will be written. This must be in a location where you have write permissions

  • MET_INSTALL_DIR - Path to location where MET is installed locally

Example User Configuration File:

[dir]
INPUT_BASE = /path/to/sample/input/data
OUTPUT_BASE = /path/to/output/dir
MET_INSTALL_DIR = /path/to/met-X.Y

NOTE: All of these items must be found under the [dir] section.

Expected Output

A successful run will output the following both to the screen and to the logfile:

INFO: METplus has successfully finished running.

Refer to the value set for OUTPUT_BASE to find where the output data was generated. Output for this use case will be found in met_tool_wrapper/SeriesAnalysis (relative to OUTPUT_BASE) and will contain the following file:

  • 2005080700_sa.nc

Keywords

sphinx_gallery_thumbnail_path = ‘_static/met_tool_wrapper-SeriesAnalysis.png’

Total running time of the script: ( 0 minutes 0.000 seconds)

Gallery generated by Sphinx-Gallery