Preliminary work: METplus setup
Preliminary work: METplus setupWelcome to the online METplus tutorial!
In this preliminary session, you'll be guided through the necessary steps that need to happen before executing the tutorial's METplus commands. Additionally, we'll go over some of the common METplus wrapper configuration settings, timing control, and the directory structure of the METplus wrappers.
If you have already started working on the tutorial and are rejoining with the same METplus terminal session active (i.e. you have not changed any of the environmental configuration settings), you do not need to redo this section and can jump directly to the session of interest.
If you are just starting out, or you are returning with a new terminal session, you will need to revisit this session to get your environment correctly set. So select the next page of "METplus setup" to get started!
METplus Setup
METplus SetupMETplus Overview
METplus is a set of Python modules that have been developed with the flexibility to run the MET applications for various use cases or scenarios. The goal is to simplify the running of MET for scientists. Currently, the primary means of achieving this is through the use of METplus configuration files, aka "conf files." It is designed to provide a framework in which additional use cases can be added. The conf file implementation utilizes a Python package called produtil that was developed by NOAA/NCEP/EMC for the HWRF system.
Please be sure to follow the instructions in order.
METplus Useful Links
The following links are just for reference, and not required for this practical session. METplus releases are available on GitHub along with sample data and instructions.
The source code for the METplus components are publicly available in the following GitHub repositories:
- https://github.com/dtcenter/METplus - Python wrappers and use cases
- https://github.com/dtcenter/MET - Core MET codebase
- https://github.com/dtcenter/METdataio - Database system for MET output
- https://github.com/dtcenter/METplotpy - Python plotting scripts
- https://github.com/dtcenter/METcalcpy - Python calculation functions
- https://github.com/dtcenter/METviewer - Display system for MET output
- https://github.com/dtcenter/METexpress - Streamlined display system
New features are developed and bugs are tracked using GitHub issues in each repository.
METplus: Initial setup
METplus: Initial setupPrerequisites: Software
The Requirements section in the Software Installation chapter of the METplus User's Guide lists the software and Python packages that are required to run the METplus wrappers. Note that there is a core set of requirements needed to run the METplus wrappers and additional requirements needed to utilize some of the more advanced features.
Prerequisites: Environment
The following instructions are required so the commands in this tutorial can be copied and run without modification. The steps involve creating a working directory to store files used/generated by the tutorial and configuring a simple script that can be run to set up the shell environment. Once configured correctly, the script can be run upon returning to the tutorial content to easily resume progress.
Pre-Configured Environments
Setting up the Tutorial Environment on Hera (NOAA)
Setting up the Tutorial Environment on Jet (NOAA)
Setting up the Tutorial Environment on Cheyenne (NCAR)
Setting up the Tutorial Environment on Seneca (NCAR)
User Configured Environments
Setting up the Tutorial Environment (bash)
Setting up the Tutorial Environment (csh)
Setting up the Tutorial Environment on Cheyenne (NCAR)
Setting up the Tutorial Environment on Cheyenne (NCAR)Setting up the Tutorial Environment on Cheyenne (NCAR)
The following instructions should be run if configuring the shell environment to run the METplus Tutorial on Cheyenne (NCAR). If you are running on your own computer or a NOAA machine that has been set up to run the tutorial, please go back and click the appropriate link for those instructions.
Create a Working Directory
Create a directory called 'METplus-5.0.0_Tutorial' to hold all of the files you will create during the tutorial. This can be any directory that you have write permission.
Create Directories for Configuration Files and Output Data
mkdir output
Obtain the Tutorial Setup Script
DO NOT RUN BOTH SETS OF COMMANDS.
If you are unsure which shell you are using, run the command "echo $SHELL" to check.
Setting up the Tutorial Environment on Jet (NOAA)
Setting up the Tutorial Environment on Jet (NOAA)Setting up the Tutorial Environment on Jet (NOAA)
The following instructions should be run if configuring the shell environment to run the METplus Tutorial on Jet (NOAA). If you are running on your own computer or an NCAR machine that has been set up to run the tutorial, please go back and click the appropriate link for those instructions.
Create a Working Directory
Create a directory called 'METplus-5.0.0_Tutorial' to hold all of the files you will create during the tutorial. This can be any directory that you have write permission.
Create Directories for Configuration Files and Output Data
mkdir output
Obtain the Tutorial Setup Script
cp /lfs1/HFIP/dtc-hurr/METplus/METplus-5.0.0_Tutorial_Files/tutorial-5.0.0.conf ./tutorial.conf
Setting up the Tutorial Environment on Seneca (NCAR)
Setting up the Tutorial Environment on Seneca (NCAR)Setting up the Tutorial Environment on Seneca (NCAR)
The following instructions should be run if configuring the shell environment to run the METplus Tutorial on Seneca (NCAR). If you are running on your own computer or a NOAA machine that has been set up to run the tutorial, please go back and click the appropriate link for those instructions.
Create a Working Directory
Create a directory called 'METplus-5.0.0_Tutorial' to hold all of the files you will create during the tutorial. This can be any directory that you have write permission.
Create Directories for Configuration Files and Output Data
mkdir output
Obtain the Tutorial Setup Script
(OPTIONAL) Set up conda Environment for METplus Analysis and s2s Tutorial Sections
Due to the need for external package dependencies for the METplus Analysis and s2s sections, the following instructions are also necessary. If you do not plan on executing the commands of those sections, you can skip these steps.
First, ensure that you are running the bash environment:
Now, verify that you have a .condarc file in your /home/user directory. If the file does not exist, create one. In that file, you will need the following entries, in the exact same format (dashes and colons):
- defaults
- conda-forge
- anaconda
Verify that you are using the most recent version of anaconda3 in your .bashrc file. Verify that your conda_setup in your .bashrc file is using /usr/local/anaconda3/bin/conda. You should see a code block similar to following:
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/usr/local/anaconda3/bin/conda' 'shell.bash' 'hook'2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/usr/local/anaconda3/etc/profile.d/conda.sh" ]; then
. "/usr/local/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/usr/local/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
If you do have to make any changes to your .bashrc file, it would be best at this point to sign out, then sign back into your Seneca connection from the terminal. Errors have been found to happen even after sourcing your .bashrc file for the updated content.
From the command line, enter the following:
mamba -y
If this was successful, you will see the following at the end of the output streamed to the screen:
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
# $ conda activate metplus_analysis_tutorial_env
#
# To deactivate an active environment, use
#
# $ conda deactivate
This creates a basic Python 3.8 conda environment named ‘metplus_analysis_tutorial_env’ that contains mamba (to accelerate installing the remaining Python packages).
Activate this environment by running the following from the command line:
Install the following packages to the conda environment by running the following from the command line (using mamba to speed up the installation):
You will see many lines of information streaming to your screen. You will see following output to your screen if everything was successful:
Verifying transaction: done
Executing transaction: /
Installed package of scikit-learn can be accelerated using scikit-learn-intelex.
More details are available here: https://intel.github.io/scikit-learn-intelex
For example:
$ conda install scikit-learn-intelex
$ python -m sklearnex my_application.py
done
Now you are ready to run the METplus Analysis tutorials.
Setting up the Tutorial Environment on Hera (NOAA)
Setting up the Tutorial Environment on Hera (NOAA)Setting up the Tutorial Environment on Hera (NOAA)
The following instructions should be run if configuring the shell environment to run the METplus Tutorial on Hera (NOAA). If you are running on your own computer or an NCAR machine that has been set up to run the tutorial, please go back and click the appropriate link for those instructions.
Create a Working Directory
Create a directory called 'METplus-5.0.0_Tutorial' to hold all of the files you will create during the tutorial. This can be any directory that you have write permission.
Create Directories for Configuration Files and Output Data
mkdir output
Obtain the Tutorial Setup Script
cp /scratch1/BMC/dtc/METplus/METplus-5.0.0_Tutorial_Files/tutorial-5.0.0.conf ./tutorial.conf
Setting up the Tutorial Environment (bash)
Setting up the Tutorial Environment (bash)Setting up the Tutorial Environment (bash)
Create a Working Directory
Create a directory called 'METplus-5.0.0_Tutorial' to hold all of the files you will create during the tutorial. This can be any directory that you have write permission.
Create Directories for Configuration Files and Output Data
mkdir output
Obtain the Tutorial Setup Script
wget https://dtcenter.org/sites/default/files/community-code/metplus/tutorial-data/tutorial-5.0.0.conf -O ./tutorial.conf
Configure the Tutorial Setup Script
MET_BUILD_BASE is the full path to the MET installation (/path/to/met-X.Y)
METPLUS_DATA is the location of the sample test data directory
Setting up the Tutorial Environment (csh)
Setting up the Tutorial Environment (csh)Setting up the Tutorial Environment (csh)
Create a Working Directory
Create a directory called 'METplus-5.0.0_Tutorial' to hold all of the files you will create during the tutorial. This can be any directory that you have write permission.
Create Directories for Configuration Files and Output Data
mkdir output
Obtain the Tutorial Setup Script
wget https://dtcenter.org/sites/default/files/community-code/metplus/tutorial-data/tutorial-5.0.0.conf -O ./tutorial.conf
Configure the Tutorial Setup Script
MET_BUILD_BASE is the full path to the MET installation (/path/to/met-X.Y)
METPLUS_DATA is the location of the sample test data directory
Verify Environment is Set Correctly
Verify Environment is Set CorrectlyVerify Environment is Set Correctly
Run the Tutorial Setup Script
source METplus-5.0.0_TutorialSetup.sh
The tutorial setup script sets the paths for METPLUS_TUTORIAL_DIR, METPLUS_BUILD_BASE, MET_BUILD_BASE, and METPLUS_DATA. It also appends the $PATH environment variable to include the directory where the METplus scripts are located. If necessary, it may also load modules needed for the METplus software to run correctly.
Check Path
Make sure that all of the environment variables are set to the appropriate values and that the path is set up to locate the METplus components.
You should see the usage statement for Point-Stat. The version number listed should correspond to the version listed in MET_BUILD_BASE. If it does not, you will need to either reload the met module, or add ${MET_BUILD_BASE}/bin to your PATH.
$METPLUS_TUTORIAL_DIR
The directory you created to store all of your tutorial files
Example value:
Example contents:
output/
tutorial.conf
user_config/
$MET_BUILD_BASE
The directory where MET is installed
Example value:
Example contents
share
Check contents of MET bin directory
Example contents:
ensemble_stat
gen_ens_prod
gen_vx_mask
gis_dump_dbf
gis_dump_shp
gis_dump_shx
grid_diag
grid_stat
gsid2mpr
gsidens2orank
ioda2nc
lidar2nc
madis2nc
mode
mode_analysis
modis_regrid
mtd
pb2nc
pcp_combine
plot_data_plane
plot_mode_field
plot_point_obs
point2grid
point_stat
regrid_data_plane
rmw_analysis
series_analysis
shift_data_plane
stat_analysis
tc_dland
tc_gen
tc_pairs
tc_rmw
tc_stat
wavelet_stat
wwmca_plot
wwmca_regrid
$METPLUS_BUILD_BASE
The directory where METplus is installed
Example value:
Example contents:
docs
environment.yml
internal
manage_externals
metplus
parm
produtil
pyproject.toml
README.md
requirements.txt
setup.py
ush
$METPLUS_DATA
The directory containing sample input data to use for the tutorial
Example value:
Example contents:
met_test
model_applications
METplus Overview
METplus OverviewMETplus Overview
The following content will discuss and demonstrate some of the basic concepts of the METplus wrappers. This will include discussion of the repository structure and configuration files, as well as how to run a simple example and some associated settings that users will change the most frequently as they continue to work with the METplus system.
As you progress through later tutorial sessions, additional examples of the METplus wrappers will be provided that focus more on their specific MET tool configurable settings and use case based examples.
Proceed to the next page to start with a overview of the METplus directory layout.
METplus: Directories and Configuration Files - Overview
METplus: Directories and Configuration Files - OverviewMETplus directory structure
A brief description and overview of the METplus/ directory structure can be found in the METplus User's Guide section called METplus Wrappers Directory Structure. The files/directories in ${METPLUS_BUILD_BASE} should match this list.
METplus default configuration file
Look inside the directory ${METPLUS_BUILD_BASE}/parm
Look at the METplus default configuration file:
The METplus default configuration file (defaults.conf) is always read first. Any additional configuration files passed in on the command line are then processed in the order in which they are specified. This allows for each successive conf file the ability to override variables defined in any previously processed conf files. It also allows for defining and setting up conf files from a general (settings used by all use cases, ie. MET install dir) to more specific (Plot type when running track and intensity plotter) structure. The idea is to created a hiearchy of conf files that is easier to maintain, read, and manage. It is important to note, running METplus creates a single configuration file, which can be viewed to understand the result of all the conf file processing.
When METplus is run, the final metplus conf file is generated here:
metplus_runtime.conf:METPLUS_CONF={OUTPUT_BASE}/metplus_final.conf.YYYYMMDDHHmmss
This is a unique final config file for each METplus run. Use this file to see the result of all the conf file processing; this can be very helpful when troubleshooting.
NOTE: The syntax for METplus configuration files MUST include a "[config]" section header with the variable names and values on subsequent lines.
More information about the default configuration variables can be found in the METplus User's Guide section called Default Configuration File.
The met_config directory (in ${METPLUS_BUILD_BASE}/parm) contains "wrapped" MET configuration files that are used by calls to the MET applications via the METplus wrappers. The wrappers set environment variables that control settings in the wrapped MET configuration files through these environment variables. See the METplus User's Guide section called How METplus controls MET configuration variables for more information.
METplus Use Cases
The use_cases directory - this is where the use cases you will be running exist. Under the use_cases directory are two directories: met_tool_wrapper and model_applications. The met_tool_wrapper directory contains use cases that run a single METplus wrapper. They are a good starting point to see how the wrapper scripts generate commands that run the MET tools. The model_applications directory contains more complex use cases that often run multiple wrappers and demonstrate real evaluations from users.
MET Tool Wrapper Use Cases
Look at the MET Tool Wrapper Use Cases
The met_tool_wrapper use case files are organized into subdirectories by wrapper, e.g. Example or GridStat. They contain METplus configuration files (ending with .conf). If a MET tool that is called by a use case uses a MET configuration file, the file used for the met_tool_wrapper use cases is found in parm/met_config.
- met_tool_wrapper/Example - directory
- met_tool_wrapper/Example/Example.conf - use case configuration file
- met_tool_wrapper/GridStat - directory
- met_tool_wrapper/GridStat/GridStat.conf - use case configuration file
- parm/met_config/GridStatConfig_wrapped - MET configuration file used in the GridStat.conf use case
Model Application Use Cases
Look at the Model Application use cases
The model_applications use case files are organized in directories by category, e.g. precipitation or data_assimilation. They contain METplus configuration files (ending with .conf). If additional files such as Python Embedding scripts are included with a use case, these files are found in a directory named after the METplus configuration file without the .conf extension.
- model_applications/data_assimilation - directory
- model_applications/data_assimilation/StatAnalysis_fcstHAFS_obsPrepBufr_JEDI_IODA_interface.conf - use case configuration file
- model_applications/data_assimilation/StatAnalysis_fcstHAFS_obsPrepBufr_JEDI_IODA_interface - directory containing supplemental files for the use case
- model_applications/data_assimilation/StatAnalysis_fcstHAFS_obsPrepBufr_JEDI_IODA_interface/read_ioda_mpr.py - script called by the use case
Example Use Case (aka "Hello World" Example - METplus style)
Let's look at the Example use case, Example.conf, under met_tool_wrapper/Example
In this file are variables, denoted in ALL_CAPS. These can be modified as needed. In the METplus system, unmodified config files remain in the directories under ${MET_BUILD_BASE}, while user-modified files are stored in ${METPLUS_TUTORIAL_DIR}/user_config.
No changes are needed in Example.conf. Close it and continue to the next page.
Unless otherwise indicated, all directories are relative to your ${METPLUS_TUTORIAL_DIR} directory.
METplus: User Configuration Settings
METplus: User Configuration SettingsModify your Tutorial/User conf files
In this section you will modify the configuration files that will be read for each call to METplus.
The paths in this practical session guide assume:
- You have created a user_config directory in your ${METPLUS_TUTORIAL_DIR} directory
- You have added the shared METplus ush directory to your PATH (done in the Tutorial Setup script)
- You are using the shared installation of MET.
If not, then you need to adjust accordingly.
-
Change to the ${METPLUS_TUTORIAL_DIR} directory. Try running run_metplus.py. You should see the usage statement output to the screen.
run_metplus.py
-
Now try to pass in the example.conf configuration file found in your parm directory under use_cases/met_tool_wrapper/Examples tutorial.conf
${METPLUS_BUILD_BASE}/parm/use_cases/met_tool_wrapper/Example/Example.conf
You should see output like this:
Running METplus 5.0.1
Starting METplus v5.0.1
12/15 19:53:06.223 metplus (config_metplus.py:102) INFO: Starting METplus configuration setup.
12/15 19:53:06.225 metplus (config_metplus.py:230) INFO: Parsing config file: /var/autofs/mnt/linux-amd64/debian/buster/local/METplus-5.0.1/parm/metplus_config/defaults.conf
12/15 19:53:06.226 metplus (config_metplus.py:230) INFO: Parsing config file: /var/autofs/mnt/linux-amd64/debian/buster/local/METplus-5.0.1/parm/use_cases/met_tool_wrapper/Example/Example.conf
Traceback (most recent call last):
File "/usr/local/METplus-5.0.1/ush/run_metplus.py", line 128, in <module>
main()
File "/usr/local/METplus-5.0.1/ush/run_metplus.py", line 44, in main
config = pre_run_setup(config_inputs)
File "/usr/local/METplus-5.0.1/metplus/util/run_util.py", line 23, in pre_run_setup
config = setup(config_inputs)
File "/usr/local/METplus-5.0.1/metplus/util/config_metplus.py", line 108, in setup
config = launch(override_list)
File "/usr/local/METplus-5.0.1/metplus/util/config_metplus.py", line 256, in launch
mkdir_p(config.getdir('OUTPUT_BASE'))
File "/usr/local/METplus-5.0.1/metplus/util/config_metplus.py", line 693, in getdir
raise ValueError(f"{dir_name} cannot be set to "
ValueError: OUTPUT_BASE cannot be set to or contain '/path/to'
ERROR: run_metplus failed: OUTPUT_BASE cannot be set to or contain '/path/to'
Note it ends with an error message stating that OUTPUT_BASE was not set correctly. You will need to configure the METplus wrappers to be able to run a use case.
Some variables in the system conf are set to '/path/to' and must be overridden to run METplus, such as OUTPUT_BASE in defaults.conf.
-
View the defaults.conf file and notice how OUTPUT_BASE = /path/to . This implies it is REQUIRED to be overridden to a valid path.
-
View the tutorial configuration files in your ${METPLUS_TUTORIAL_DIR} directory.
The INPUT_BASE, OUTPUT_BASE, and MET_INSTALL_DIR variables must all be set to run METplus. Since MET_INSTALL_DIR (and possibly INPUT_BASE) should already be set in the default METplus configuration file (completed on install of METplus), only OUTPUT_BASE is required to run. If INPUT_BASE is not set in the tutorial configuration file, it should be set correctly in the defaults configuration file.
We will test out using these configurations on the next page.
METplus: How to Run with Example.conf
METplus: How to Run with Example.confRunning METplus
Running METplus involves invoking the python script run_metplus.py followed by a list of configuration files.
Reminder: The default configuration file (defaults.conf) is always read in and processed first before the configuration files passed in on the command line.
If you have configured METplus correctly and call run_metplus.py without passing in any configuration files, it will generate a usage statement to indicate that other config files are required to perform a useful task. It will generate an error statement if something is amiss.
- Review the Example.conf configuration file - which is METplus' version of a "Hello World" example
- Call the run_metplus.py script again, this time passing in the Example.conf configuration file and the tutorial.conf configuration file. You should see logs output to the screen.
${METPLUS_BUILD_BASE}/parm/use_cases/met_tool_wrapper/Example/Example.conf \
${METPLUS_TUTORIAL_DIR}/tutorial.conf
Note: The environment variable METPLUS_BUILD_BASE determines where to look for paths to use_case files. The METPLUS_TUTORIAL_DIR environment variable determines where to look for user-modified config files.
- Check the directory specified by the OUTPUT_BASE configuration variable. You should see that files and sub-directories have been created
- Review the METplus log file to see what was run. Compare the log output to the Example.conf configuration file to see how they correspond to each other. The log file will have today's date in the filename. Since METplus was configured to list today's timestamp in YYYYMMDDHHMMSS format, each run of METplus will generate a separate log file. This is the same behavior as the METplus final configuration file. List all of the log files and view the latest METplus log file:
You will notice that METplus ran for 5 valid times, processing 4 forecast hours for each valid time. For each run time, it ran twice using two different input templates to find files.
metplus INFO: * Running METplus
metplus INFO: * at valid time: 201702010000
metplus INFO: ****************************************
metplus.Example INFO: Running ExampleWrapper at valid time 20170201000000
metplus.Example INFO: Input directory is /dir/containing/example/data
metplus.Example INFO: Input template is {init?fmt=%Y%m%d}/file_{init?fmt=%Y%m%d}_{init?fmt=%2H}_F{lead?fmt=%3H}.{custom?fmt=%s}
metplus.Example INFO: Processing custom string: ext
metplus.Example INFO: Processing forecast lead 3 hours initialized at 2017-01-31 21Z and valid at 2017-02-01 00Z
metplus.Example INFO: Looking in input directory for file: 20170131/file_20170131_21_F003.ext
metplus.Example INFO: Processing custom string: nc
metplus.Example INFO: Processing forecast lead 3 hours initialized at 2017-01-31 21Z and valid at 2017-02-01 00Z
metplus.Example INFO: Looking in input directory for file: 20170131/file_20170131_21_F003.nc
metplus.Example INFO: Processing custom string: ext
metplus.Example INFO: Processing forecast lead 6 hours initialized at 2017-01-31 18Z and valid at 2017-02-01 00Z
metplus.Example INFO: Looking in input directory for file: 20170131/file_20170131_18_F006.ext
metplus.Example INFO: Processing custom string: nc
metplus.Example INFO: Processing forecast lead 6 hours initialized at 2017-01-31 18Z and valid at 2017-02-01 00Z
metplus.Example INFO: Looking in input directory for file: 20170131/file_20170131_18_F006.nc
metplus.Example INFO: Processing custom string: ext
metplus.Example INFO: Processing forecast lead 9 hours initialized at 2017-01-31 15Z and valid at 2017-02-01 00Z
metplus.Example INFO: Looking in input directory for file: 20170131/file_20170131_15_F009.ext
metplus.Example INFO: Processing custom string: nc
metplus.Example INFO: Processing forecast lead 9 hours initialized at 2017-01-31 15Z and valid at 2017-02-01 00Z
metplus.Example INFO: Looking in input directory for file: 20170131/file_20170131_15_F009.nc
metplus.Example INFO: Processing custom string: ext
metplus.Example INFO: Processing forecast lead 12 hours initialized at 2017-01-31 12Z and valid at 2017-02-01 00Z
metplus.Example INFO: Looking in input directory for file: 20170131/file_20170131_12_F012.ext
metplus.Example INFO: Processing custom string: nc
metplus.Example INFO: Processing forecast lead 12 hours initialized at 2017-01-31 12Z and valid at 2017-02-01 00Z
metplus.Example INFO: Looking in input directory for file: 20170131/file_20170131_12_F012.nc
metplus INFO: ****************************************
metplus INFO: * Running METplus
metplus INFO: * at valid time: 201702010600
metplus INFO: ****************************************
...
- Now run METplus passing in the Example.conf and tutorial.conf files from the previous run AND an explicit override of the OUTPUT_BASE variable.
${METPLUS_BUILD_BASE}/parm/use_cases/met_tool_wrapper/Example/Example.conf \
${METPLUS_TUTORIAL_DIR}/tutorial.conf \
config.OUTPUT_BASE=${METPLUS_TUTORIAL_DIR}/output/changed
- Check the directory that corresponds to the config.OUTPUT_BASE value that you set in the command line override. You should see that files and sub-directories have been created in the new location. Note that you can reference an environment variable when setting values on the command line.
Remember: Additional conf files and config variable overrides are processed after the default METplus config file (defaults.conf). OUTPUT_BASE was set in tutorial.conf and then overridden with config.OUTPUT_BASE.
Order matters, since each successive conf file and/or explicit variable override will take precedence over any value set for variables defined previously.
Note: The processing order allows for structuring your conf files to contain system/user configurations (settings used for every run) and use case specific configurations (settings only used for a given use case).
Modifying Timing Control in Example.conf
Modifying Timing Control in Example.confTiming Control in METplus
METplus configuration variables that control timing information are described in the Timing Control section of the System Configuration chapter in the METplus User's Guide. The Example wrapper is a good tool to help understand how these settings control what is run by the METplus wrappers.
- Copy the Example.conf configuration file in your user_config directory, renaming it Example_timing.conf
${METPLUS_TUTORIAL_DIR}/user_config/Example_timing.conf
- Open the new Example_timing.conf file with an editor.
- Make the following changes:
3a. Change VALID_BEG and VALID_END:
VALID_END = 2017020200
to:
VALID_END = 2022011809
3b. Change LEAD_SEQ:
to:
3c. Change EXAMPLE_CUSTOM_LOOP_LIST:
to:
Also note that "ext" stands for extension and "nc" is the typical extension for a netCDF file. The initial example demonstrates how you can have METplus loop over two types of files but the removal of "nc" results in METplus only looking for files that end with "ext".
- Call the run_metplus.py script again, this time passing in the Example_timing.conf configuration file and the tutorial.conf configuration file. You should see logs output to the screen.
${METPLUS_TUTORIAL_DIR}/user_config/Example_timing.conf \
${METPLUS_TUTORIAL_DIR}/tutorial.conf
- Review the screen output and/or log file output.
- Open Example_timing.conf again to increase the frequency of output by making the following changes:
6a. Change VALID_END:
to:
- Call the run_metplus.py script again and see how the output has changed.
${METPLUS_TUTORIAL_DIR}/user_config/Example_timing.conf \
${METPLUS_TUTORIAL_DIR}/tutorial.conf
INFO: Processing forecast lead 3 hours initialized at 2022-01-18 12Z and valid at 2022-01-18 15Z
- Change the timing settings to loop by initialization (or retrospective) time. Open Example_timing.conf again and make the following changes:
8a. Change LOOP_BY:
to:
8b. Change VALID_TIME_FMT to INIT_TIME_FMT:
to:
8c. Change VALID_BEG to INIT_BEG:
to:
8d. Change VALID_END to INIT_END:
to:
8e. Change VALID_INCREMENT to INIT_INCREMENT:
to:
- Call the run_metplus.py script once again and see how the output has changed.
${METPLUS_TUTORIAL_DIR}/user_config/Example_timing.conf \
${METPLUS_TUTORIAL_DIR}/tutorial.conf
INFO: Processing forecast lead 3 hours initialized at 2022-01-18 15Z and valid at 2022-01-18 18Z
- Change the value for LOOP_BY from INIT to its nickname RETRO. Open Example_timing.conf again and make the following changes:
10a. Change LOOP_BY:
to:
- Call the run_metplus.py script another time.
${METPLUS_TUTORIAL_DIR}/user_config/Example_timing.conf \
${METPLUS_TUTORIAL_DIR}/tutorial.conf
Modifying Filename Template in Example.conf
Modifying Filename Template in Example.confFilename Template Settings in METplus
METplus configuration variables that control filename templates are described in the Directory and Filename Template Info section of the System Configuration chapter in the METplus User's Guide. The Example wrapper is a good tool to help understand how these settings control what is run by the METplus wrappers.
- List the sample available in the ${METPLUS_DATA} directory
The output should list:
nam.t00z.awip1236.tm00.20070330.grb
This translates into nam.t{init?fmt=%2H}z.awip1236.tm00.{init?fmt=%Y%m%d}.grib, We will use this in this next exercise.
- Copy the Example_timing.conf configuration file in your user_config directory, renaming it Example_filename.conf
${METPLUS_TUTORIAL_DIR}/user_config/Example_filename.conf
- Open the new Example_filename.conf file with an editor.
- Make the following changes:
4a. Change EXAMPLE_INPUT_DIR:
to:
4b. Change EXAMPLE_INPUT_TEMPLATE:
to:
- Call the run_metplus.py script again, this time passing in the Example_timing.conf configuration file and the tutorial.conf configuration file. You should see logs output to the screen.
${METPLUS_TUTORIAL_DIR}/user_config/Example_filename.conf \
${METPLUS_TUTORIAL_DIR}/tutorial.conf
- Review the screen output and/or log file output.
...
INFO: Looking in input directory for file: nam.t15z.awip1236.tm00.20220118.grib
- Open the new Example_filename.conf file with an editor.
- Make the following changes:
8a. Change INIT_BEG and INIT_END:
INIT_END = 2022011815
to:
INIT_END = 2007033000
- Call the run_metplus.py script again, passing in the modified Example_timing.conf configuration file and the tutorial.conf configuration file. You should see logs output to the screen.
${METPLUS_TUTORIAL_DIR}/user_config/Example_filename.conf \
${METPLUS_TUTORIAL_DIR}/tutorial.conf
- Review the screen output and/or log file output. It appears it is now looking for the right file.
Modifying Log Timestamp using Example.conf
Modifying Log Timestamp using Example.confThe METplus configuration variable named LOG_TIMESTAMP_TEMPLATE controls to timestamp that is included in the log file names. The default value of LOG_TIMESTAMP_TEMPLATE is %Y%m%d%H%M%S, which will include the year, month, day, hour, minute, and second when the run_metplus.py command was executed. This will create a new log file each time run_metplus.py is called from the command line.
Starting in METplus v5.0.0, the log timestamp is also included by default in the final configuration file that is generated by the METplus wrappers. This helps with debugging because the final config file and its corresponding log file(s) are more easily identified. The path to the final config file is set by METPLUS_CONF.
The values of these settings can be changed by including them in a METplus configuration file that is passed into run_metplus.py. They can also be set directly in the run_metplus.py command using the syntax config.VARIABLE_NAME=VALUE. The following examples will use the latter.
Changing the Log Timestamp Template
In this example we will change the log timestamp template to only include the year, month, and day of the run. This will create a single log file each day. Each call to run_metplus.py will add its log output to the daily file.
- Run the Example_timing use case from the previous exercise and override the log timestamp template to only include year, month, and day.
${METPLUS_TUTORIAL_DIR}/user_config/Example_timing.conf \
${METPLUS_TUTORIAL_DIR}/tutorial.conf \
config.LOG_TIMESTAMP_TEMPLATE=%Y%m%d
- List the contents of the log directory and notice that there is now a log file that matches the format metplus.log.YYYYMMDD
- Run the Example_filename use case from the previous exercise and again override the log timestamp template to only include YYYYMMDD.
${METPLUS_TUTORIAL_DIR}/user_config/Example_filename.conf \
${METPLUS_TUTORIAL_DIR}/tutorial.conf \
config.LOG_TIMESTAMP_TEMPLATE=%Y%m%d
- Review the log file and notice that it contains the log output from both runs.
- Search for the word "Running" to see each command.
Adding Run ID in Log Timestamp Template
The METplus configuration variable RUN_ID was added in METplus v5.0.0. This variable contains an 8 character string that is automatically generated by and is unique to each call to run_metplus.py. This variable can be referenced in other METplus configuration variables. This can be useful in a variety of ways. For example, it can be used to distinguish log files for METplus runs that may have started within the same second.
- Run the Example_timing use case and override the log timestamp template to include the RUN_ID.
${METPLUS_TUTORIAL_DIR}/user_config/Example_timing.conf \
${METPLUS_TUTORIAL_DIR}/tutorial.conf \
config.LOG_TIMESTAMP_TEMPLATE=%Y%m%d%H%M%S.{RUN_ID}
- List the contents of the log directory and notice that there is now a log file that matches the format metplus.log.YYYYMMDDHHMMSS.XXXXXXXX where XXXXXXXX is a random set of characters.