5.1.11.1. PB2NC: Basic Use Case

met_tool_wrapper/PB2NC/PB2NC.conf

Scientific Objective

Simply converting file formats so point observations can be read by the MET tools.

Datasets

Observations: Various fields in prepBUFR file
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/dtcenter/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.
Data Source: Unknown

METplus Components

This use case utilizes the METplus PB2NC wrapper to generate a command to run the MET tool PB2NC if all required files are found.

METplus Workflow

PB2NC is the only tool called in this example. It processes the following run time:

Valid: 2007-03-31_12Z

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/PB2NC/PB2NC.conf

# PrepBufr to NetCDF Configurations

# 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 PB2NC for this case
PROCESS_LIST = PB2NC

# 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 = VALID

# Format of VALID_BEG and VALID_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
VALID_TIME_FMT = %Y%m%d%H

# Start time for METplus run - must match VALID_TIME_FMT
VALID_BEG = 2007033112

# End time for METplus run - must match VALID_TIME_FMT
VALID_END = 2007033112

# Increment between METplus runs (in seconds if no units are specified)
#  Must be >= 60 seconds
VALID_INCREMENT = 1M

# 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 = 0

# list of offsets in the prepBUFR input filenames to allow. List is in order of preference
# i.e. if 12, 6 is listed, it will try to use a 12 offset file and then try to use a 6 offset
# if the 12 does not exist
PB2NC_OFFSETS = 12

# 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

# Location of MET config file to pass to PB2NC
# References CONFIG_DIR from the [dir] section
PB2NC_CONFIG_FILE = {CONFIG_DIR}/PB2NCConfig_wrapped

# If set to True, skip run if the output file determined by the output directory and
# filename template already exists
PB2NC_SKIP_IF_OUTPUT_EXISTS = True

# Time relative to each input file's valid time (in seconds if no units are specified) for data within the file to be
# considered valid. Values are set in the 'obs_window' dictionary in the PB2NC config file
PB2NC_WINDOW_BEGIN = -1800
PB2NC_WINDOW_END = 1800

# controls the window of time around the current run time to be considered to be valid for all
# input files, not just relative to each input files valid time
# if set, these values are substituted with the times from the current run time and passed to
# PB2NC on the command line with -valid_beg and -valid_end arguments.
# Not used if unset or set to an empty string
PB2NC_VALID_BEGIN = {valid?fmt=%Y%m%d_%H}
PB2NC_VALID_END = {valid?fmt=%Y%m%d_%H?shift=1d}

# Values to pass to pb2nc config file using environment variables of the same name.
# See MET User's Guide for more information
PB2NC_GRID = G212
PB2NC_POLY =
PB2NC_STATION_ID =
PB2NC_MESSAGE_TYPE =

# Leave empty to process all
PB2NC_OBS_BUFR_VAR_LIST = QOB, TOB, ZOB, UOB, VOB, D_DPT, D_WIND, D_RH, D_MIXR

# For defining the time periods for summarization
# False for no time summary, True otherwise
# The rest of the PB2NC_TIME_SUMMARY variables are ignored if set to False
PB2NC_TIME_SUMMARY_FLAG = False

# start time of time summary in HHMMSS format
# not used for this example
PB2NC_TIME_SUMMARY_BEG = 000000

# end time of time summary in HHMMSS format
# not used for this example
PB2NC_TIME_SUMMARY_END = 235959

# list of time summary variable names to set in the PB2NC config file
# not used for this example
PB2NC_TIME_SUMMARY_VAR_NAMES =

# list of time summary types to set in the PB2NC config file
# not used for this example
PB2NC_TIME_SUMMARY_TYPES = min, max, range, mean, stdev, median, p80  ;; a list of the statistics to summarize


# 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 input to PB2NC
PB2NC_INPUT_DIR = {INPUT_BASE}/met_test/data/sample_obs/prepbufr

# directory to write output from PB2NC
PB2NC_OUTPUT_DIR = {OUTPUT_BASE}/pb2nc


# End of [dir] section and start of [filename_templates] section
[filename_templates]
# Template to look for forecast input to PB2NC relative to PB2NC_INPUT_DIR
PB2NC_INPUT_TEMPLATE = ndas.t{da_init?fmt=%2H}z.prepbufr.tm{offset?fmt=%2H}.{da_init?fmt=%Y%m%d}.nr

# Template to use to write output from PB2NC
PB2NC_OUTPUT_TEMPLATE = sample_pb.nc

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.

////////////////////////////////////////////////////////////////////////////////
//
// PB2NC configuration file.
//
// For additional information, see the MET_BASE/config/README file.
//
////////////////////////////////////////////////////////////////////////////////

//
// PrepBufr message type
//
message_type =  ${PB2NC_MESSAGE_TYPE} ;

//
// Mapping of message type group name to comma-separated list of values
// Derive PRMSL only for SURFACE message types
//
message_type_group_map = [
   { key = "SURFACE"; val = "ADPSFC,SFCSHP,MSONET";               },
   { key = "ANYAIR";  val = "AIRCAR,AIRCFT";                      },
   { key = "ANYSFC";  val = "ADPSFC,SFCSHP,ADPUPA,PROFLR,MSONET"; },
   { key = "ONLYSF";  val = "ADPSFC,SFCSHP";                      }
];

//
// Mapping of input PrepBufr message types to output message types
//
message_type_map = [];

//
// PrepBufr station ID
//
station_id = ${PB2NC_STATION_ID};


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

//
// Observation time window
//
obs_window = {
  beg = ${OBS_WINDOW_BEGIN};
  end = ${OBS_WINDOW_END};
}

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

//
// Observation retention regions
//
mask = {
   grid = "${PB2NC_GRID}" ;
   poly = "${PB2NC_POLY}" ;
}

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

//
// Observing location elevation
//
elevation_range = {
   beg =  -1000;
   end = 100000;
}

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

//
// Observation types
//
pb_report_type = [120, 220, 221, 122, 222, 223, 224, 131, 133, 233, 153, 156, 157, 180, 280, 181, 182, 281, 282, 183, 284, 187, 287];

in_report_type  = [];

instrument_type = [];

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

//
// Vertical levels to retain
//
level_range = {
   beg = 1;
   end = 511;
}

level_category = [0, 1, 4, 5, 6];

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

//
// BUFR variable names to retain or derive.
// If emtpy, process all available variables.
//
obs_bufr_var =  ${OBS_BUFR_VAR_LIST};

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

//
// Mapping of BUFR variable name to GRIB name. The default map is defined at
// obs_prepbufr_map. This replaces/expends the default map.
//
obs_bufr_map = [];

// This map is for PREPBUFR. It will be added into obs_bufr_map.
// Please do not override this map.
obs_prefbufr_map = [
   { key = "POB";     val = "PRES";  },
   { key = "QOB";     val = "SPFH";  },
   { key = "TOB";     val = "TMP";   },
   { key = "ZOB";     val = "HGT";   },
   { key = "UOB";     val = "UGRD";  },
   { key = "VOB";     val = "VGRD";  },
   { key = "D_DPT";   val = "DPT";   },
   { key = "D_WDIR";  val = "WDIR";  },
   { key = "D_WIND";  val = "WIND";  },
   { key = "D_RH";    val = "RH";    },
   { key = "D_MIXR";  val = "MIXR";  },
   { key = "D_PRMSL"; val = "PRMSL"; },
   { key = "D_PBL";   val = "PBL";   },
   { key = "D_CAPE";  val = "CAPE";  }
];


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

quality_mark_thresh = 3;
event_stack_flag    = TOP;

////////////////////////////////////////////////////////////////////////////////
//
// Time periods for the summarization
//
time_summary = {
  flag = ${TIME_SUMMARY_FLAG};
  beg = ${TIME_SUMMARY_BEG};
  end = ${TIME_SUMMARY_END};
  step = 3600;
  width = 3600;
  grib_code = [];
  obs_var   = ${TIME_SUMMARY_VAR_NAMES};
  type = ${TIME_SUMMARY_TYPES};
  vld_freq = 0;
  vld_thresh = 0.0;
}

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

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

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

Note the following variables are referenced in the MET configuration file. Please see the MET User’s Guide section regarding PB2NC options for more information.

  • ${PB2NC_MESSAGE_TYPE} - Corresponds to PB2NC_MESSAGE_TYPE in the METplus configuration file.

  • ${PB2NC_STATION_ID} - Corresponds to PB2NC_STATION_ID in the METplus configuration file.

  • ${PB2NC_GRID} - Corresponds to PB2NC_GRID in the METplus configuration file.

  • ${PB2NC_POLY} - Corresponds to PB2NC_POLY in the METplus configuration file.

  • ${OBS_WINDOW_BEGIN} - Corresponds to OBS_WINDOW_BEGIN or PB2NC_WINDOW_BEGIN in the METplus configuration file.

  • ${OBS_WINDOW_END} - Corresponds to OBS_WINDOW_END or PB2NC_WINDOW_END in the METplus configuration file.

  • ${OBS_BUFR_VAR_LIST} - Corresponds to PB2NC_OBS_BUFR_VAR_LIST in the METplus configuration file.

  • ${TIME_SUMMARY_FLAG} - True/False option to compute time summary statistics. Corresponds to PB2NC_TIME_SUMMARY_FLAG in the METplus configuration file.

  • ${TIME_SUMMARY_BEG} - Corresponds to PB2NC_TIME_SUMMARY_BEG in the METplus configuration file.

  • ${TIME_SUMMARY_END} - Corresponds to PB2NC_TIME_SUMMARY_END in the METplus configuration file.

  • ${TIME_SUMMARY_VAR_NAMES} - Corresponds to PB2NC_TIME_SUMMARY_VAR_NAMES in the METplus configuration file.

  • ${TIME_SUMMARY_TYPES} - Corresponds to PB2NC_TIME_SUMMARY_TYPES in the METplus configuration file.

Running METplus

This use case can be run two ways:

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

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

    master_metplus.py -c /path/to/METplus/parm/use_cases/met_tool_wrapper/PB2NC/PB2NC.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 pb2nc (relative to OUTPUT_BASE) and will contain the following file:

  • sample_pb.nc

Keywords

sphinx_gallery_thumbnail_path = ‘_static/met_tool_wrapper-PB2NC.png’

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

Gallery generated by Sphinx-Gallery