METplus Practical Session Guide (Version 5.0) | Session 9: Python Embedding > Use Your Python Embedding Script with METplus Wrappers

Using Your Python Embedding Script With METplus Wrappers

This section will largely follow the instructions in section titled "Python Embedding for Gridded Data", except you will be using your own Python Embedding script.

In this section, you will use METplus Wrappers to run plot_data_plane with your Python Embedding script. The script you wrote in the "Writing A Python Script For Python Embedding" section supports both PYTHON_NUMPY and PYTHON_XARRAY, so sample METplus wrappers configuration files are shown for both approaches below.

First, verify you are in the Python Embedding practice directory:

cd ${METPLUS_TUTORIAL_DIR}/python_embed

PYTHON_NUMPY

Open a new file named practice_gridded_pyembed_NUMPY.conf with a text editor.

vi practice_gridded_pyembed_NUMPY.conf

Copy the following METplus Wrappers configuration items into the file and save it when complete. Recall there are some basic required elements that METplus wrappers needs to run including some time looping information that is not used for this example, as well as the top-level output directory:

[config]
LOOP_BY=VALID
VALID_BEG=20230101
VALID_END=20230101
VALID_TIME_FMT=%Y%m%d
OUTPUT_BASE={ENV[METPLUS_TUTORIAL_DIR]}/python_embed/practice_pyembed_wrappers_output
MET_INSTALL_DIR={ENV[MET_BUILD_BASE]}
PROCESS_LIST=PlotDataPlane
PLOT_DATA_PLANE_INPUT_TEMPLATE=PYTHON_NUMPY
PLOT_DATA_PLANE_OUTPUT_TEMPLATE={OUTPUT_BASE}/practice_pyembed_wrappers_numpy_plot.ps
PLOT_DATA_PLANE_FIELD_NAME={ENV[METPLUS_TUTORIAL_DIR]}/python_embed/practice_gridded_pyembed.py numpy
Now save the file, and run METplus wrappers:
run_metplus.py -c practice_gridded_pyembed_NUMPY.conf

PYTHON_XARRAY

Open a new file named practice_gridded_pyembed_XARRAY.conf with a text editor.

vi practice_gridded_pyembed_XARRAY.conf

Copy the following METplus Wrappers configuration items into the file and save it when complete. Recall there are some basic required elements that METplus wrappers needs to run including some time looping information that is not used for this example, as well as the top-level output directory:

[config]
LOOP_BY=VALID
VALID_BEG=20230101
VALID_END=20230101
VALID_TIME_FMT=%Y%m%d
OUTPUT_BASE={ENV[METPLUS_TUTORIAL_DIR]}/python_embed/practice_pyembed_wrappers_output
MET_INSTALL_DIR={ENV[MET_BUILD_BASE]}
PROCESS_LIST=PlotDataPlane
PLOT_DATA_PLANE_INPUT_TEMPLATE=PYTHON_XARRAY
PLOT_DATA_PLANE_OUTPUT_TEMPLATE={OUTPUT_BASE}/practice_pyembed_wrappers_xarray_plot.ps
PLOT_DATA_PLANE_FIELD_NAME={ENV[METPLUS_TUTORIAL_DIR]}/python_embed/practice_gridded_pyembed.py xarray
Now save the file, and run METplus wrappers:
run_metplus.py -c practice_gridded_pyembed_XARRAY.conf

If you completed the previous section using your Python Embedding script directly with plot_data_plane, then the image you generated from either of the approaches above should identically match that and look like this:

Well done! You successfully used your Python Embedding script with METplus Wrappers!