MetPy is a collection of tools in Python that are specific to meteorological applications. I strongly encourage you to have a look at the Getting Started with MetPy guide to introduce you to the basic syntax and functionality of the MetPy library of functions. Unidata also provides a good collection of examples in the Unidata Python Gallery. You will also find that the MetPy Reference Guide is quite useful for finding specific functions, such as one that calculates vorticity given the wind components and the grid size. A few tutorials exist to date on the MetPy pages, but you will find many more excellent tutorials for drawing thermodynamic diagrams, visualizing satellite data, downloading model output, and performing many tasks related to meteorology in Unidata’s Python Workshop.
One of the great aspects of MetPy is that it can handle units attached to certain types of data structures. This functionality is based on Pint. Read all about how to manipulate units in the Pint tutorial or in the MetPy Units Tutorial. This description of Unit Support has some nice examples of dealing with units in MetPy and there are some excellent examples of units in this MetPy Monday tutorial. To manipulate units within an xarray DataArray, which is what you will likely get with model data, use this example.
As I first mentioned in the Vector Graphics tutorial, I have installed MetPy on Blizzard, but recall that these tools will only work with Python 3. Again, you will notice a few differences between Python 2.x and Python 3.x, the most consequential of which is the syntax of print statements.
Plotting Model Output
MetPy uses a delightful set of utilities called Siphon that can download data from remote data services, specifically from the THREDDS Data Server. You can browse the available data on the THREDDS Data Server here. These data include model output and surface, radar, and satellite observations. For this assignment, let’s focus on plotting model output from the High-Resolution Rapid Refresh model over the continental United States (CONUS). Start by downloading plotmodel.py into a suitable directory on Blizzard. This program is a modification of this Unidata tutorial on downloading model fields using the netCDF Subset Service (NCSS). Carefully read the comments to see what each line does. As you modify this program for the assignment outlined below, you may find some useful elements within this tutorial on plotting geopotential heights, temperature, and winds, as well as this one that shows how to extract and plot HRRR data. I have embedded some other helpful URLs within the program. For general plotting assistance and keywords, peruse the Matplotlib documentation, examples, and tutorials.
Here, you will plot the latest HRRR model analysis for several fields. Run plotmodel.py straight out of the box to see a basic plot of the latest 850-hPa geopotential heights and temperatures. Extend this program to create the following four maps:
In each case, add a descriptive title with units and include the appropriate date and time of the analysis. Be sure to plot your winds in knots, not meters per second. Save the figures within the program as raster images and post these, along with your code, to your password-protected website. You are welcome to zoom in on a region of interest in each plot if you wish. Your finished plots might look something like the following figures.