Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

By: Kevin Goebbert

This example uses the declarative syntax available through the MetPy package to allow a more convenient method for creating simple maps of atmospheric data. The key thing the declarative language does is to reduce the number of packages that users will need to know in detail and instead allow them to set key parameters to get the map they desire. One key element is the use of xarray as the data object, which allows coordinate information to be associated with atmospheric variables.

Open dataset using xarray module and subset global GFS to be over the CONUS.

Calculate Variable and Add to Dataset

Here it is demonstrated how you can calculate a new variable and add it to the xarray dataset (ds) so that it can be plotted with the declarative syntax. The key to adding a variable to an xarray dataset for use in the declarative syntax is the need to add a grid_mapping and units attribute.

Declarative Plot

The following settings create a single panel map plot of 300 hPa geopotential heights, wind speed, and wind barbs.

Could not find variable corresponding to the value of grid_mapping: LatLon_Projection
Could not find variable corresponding to the value of grid_mapping: LatLon_Projection
Could not find variable corresponding to the value of grid_mapping: LatLon_Projection
<Figure size 1500x900 with 2 Axes>