AWIPS Tips: Creating METAR Station Plots

AWIPS Tips

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
request.setParameters(*(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',...
request.setLocationNames(*(selected))

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()
 print(avail_params)


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

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
 else:
  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:

Advisories

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 support-awips@unidata.ucar.edu

Comments:

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

Welcome

FAQs

Developers’ blog

Take a poll!

What if we had an ongoing user poll in here?

Browse By Topic
Browse by Topic
« October 2024
SunMonTueWedThuFriSat
  
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today