AWIPS Tips: Creating METAR Station Plots


Welcome back to AWIPS Tips! Today we’re going to talk about some more functionality with python-awips. If you aren’t familiar with python-awips, please check out some of our previous blog posts explaining some of the existing functionality. This blog entry will be focused on our notebook for creating METAR station plots.

The data request type used in this notebook is the obs data type. We have touched on this data type previously when creating a colorized surface observation plot. In this example, we are going to use more than just the temperature data associated with a surface observation. One of the immediate differences is the number of parameters that are defined for our data request:

single_value_params = ["timeObs", "stationName", "longitude", "latitude",
              "temperature", "dewpoint", "windDir", "windSpeed"]
multi_value_params = ["skyCover"]
params = single_value_params + multi_value_params

NOTE: You may set additional parameters on the request. To see an example of accessing a list of all parameters refer to the getAvailableParameters function demonstrated in one of our other notebooks.

In order to create a legible plot, we are also limiting our results based on station IDs that we think would make a reasonable figure. Again, these are values you can change to your liking if you would like to increase or decrease the density of station plots added to the figure.

selected = ['KPDX', 'KOKC', 'KICT', 'KGLD',...

Additionally, we filter our results on time, which is something that is done in many of our notebooks. In this example, the default time filter is for the previous hour.

We are finally ready to submit our request to EDEX and get a data response. From this response we can investigate the actual data we’re receiving. If we add a few print statements in our for loop that is processing our response we can see what we’re working with:

# cycle through all the data in the response, in reverse order to get the most recent data first

for ob in reversed(response):
 avail_params = ob.getParameters()

['temperature', 'stationName', 'dewpoint', 'windDir', 'windSpeed', 'timeObs', 'latitude', 'longitude']
['temperature', 'stationName', 'dewpoint', 'windDir', 'windSpeed', 'timeObs', 'latitude', 'longitude']

Notice that this output shows some objects in the data response only contain the skyCover parameter, while others have more parameters that we initially requested. This response, where not all objects have data for all parameters, is common with other dataset types returned from EDEX using python-awips. So, if you are having trouble with the responses, it might be worth taking a moment to print out what parameters are on each of the objects in the response.

For this notebook, we gather data from the most recent record for each stationID and the most recent 'skyCover' response for each stationID. We then display the corresponding cloud cover symbol on our plot. In order to translate the skyCover response from a text abbreviation to an integer value the get_cloud_cover function is used:

def get_cloud_cover(code):
 if 'OVC' in code:
  return 8
 elif 'BKN' in code:
  return 6
 elif 'SCT' in code:
  return 4
 elif 'FEW' in code:
  return 2
  return 0

Once we have the data reformatted into a useful dictionary named data, we can then use the dictionary keys to add the customized values to our METARs plot. The values defined in this example are wind barb, air temperature, dew point temperature, and cloud coverage. This customization takes advantage of the MetPy class StationPlotLayout. An example output from this customization is a plot like this:


Like we just highlighted, this plot is produced using only a few of the parameters available from the METARs data set. Please feel free to modify this example to display additional/alternative data, like air pressure for example (where the parameter name on EDEX is seaLevelPress).

Please let us know if you produce any alternate versions of the plot and maybe we’ll highlight your work in a future blog or add your contribution to our example notebooks. Thank you for joining this week and we hope you learned something new about python-awips. Please check back in two weeks for the next blog post, where we will share updates regarding the Geostationary Lightning Mapper (GLM) data feeds.

To view archived blogs, visit the AWIPS Tips blog tag, and get notified of the latest updates from the AWIPS team by signing up for the AWIPS mailing list. Questions or suggestions for the team on future topics? Let us know at


Post a Comment:
Comments are closed for this entry.
News and information from the Unidata Program Center
News and information from the Unidata Program Center



Developers’ blog

Recent Entries:
Take a poll!

What if we had an ongoing user poll in here?

Browse By Topic
Browse by Topic
« June 2024