AWIPS Tips: View WWA Polygons with Python-AWIPS

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. In this edition we are looking at the Watch Warning and Advisory Plotting Jupyter notebook available in the python-awips Data Plotting Examples collection.

The phensig dictionary

There are a couple features in this blog that we want to highlight. The first is the use of a dictionary that is built into python-awips. The dictionary is part of the tables section of the python-awips package and is imported with the following statement:

from awips.tables import vtec

The imported vtec is actually a dictionary of dictionaries. We will be using the phensig dictionary, which is accessed with the following:

vtec[phensig]['<parameter>']

Where phensig is a specific variable from our data response that stands for Phenomena (phen) and Significance (sig). A little more information about phensigs can be found in this NWS pamphlet. The second argument, <parameter>, is a specific key we want to use. You can see this dictionary used in both the get_color() and get_title() functions.

Filter polygons by time

This notebook also makes use of filtering the watch, warning, advisory, and statement (WWA) polygons in our response by time. Some of our other notebooks just grab the most recent records, but this notebook actually specifies the time in hours of the most recent data we want. Here we can see what it looks like if we adjust the time interval and finish plotting our responses:

NOTE: The bigger timestep you pass into the data call, the longer the notebook will take to run.

12 Hours (1488 records, 20 Unique Phensigs)
12 Hours (1488 records, 20 Unique Phensigs)
24 Hours (3141 records, 22 Unique Phensigs)
24 Hours (3141 records, 22 Unique Phensigs)
48 Hours (6276 records, 22 Unique Phensigs)
48 Hours (6276 records, 22 Unique Phensigs)

Click to enlarge

​​As you can see, when we request data for bigger time intervals, we end up with more watches, warnings, advisories or statements.

Draw polygons by type

Another part of the notebook we can alter and compare the outputs is in the code cell that does the plotting. There are three boolean variables at the very beginning of the cell, that by default look like this:

# Set these variables for which records to draw
DRAW_ADVISORY = True
DRAW_WATCH = True
DRAW_WARNING = True
DRAW_STATEMENT = True

We can change any of these values to False which will hide their respective significance (watch, warning, advisory, or statement) polygons.

We’re going to continue working with the last data we requested which was from the 48 hour request. Let’s see what each of the watches, warnings, and advisories looks like on their own:

Watches
Watches
Warnings
Warnings
Advisories
Advisories

Click to enlarge

Filter polygons by action

Currently, the notebook draws every watch, warning, advisory or statement (if you have their boolean ‘turned on’), regardless of what kind of action is issued with the statement. The actions can be the following:

Action Description
NEW New event
CON Event continued
EXT Event extended (time)
EXA Event extended (area)
EXB Event extended (both time and area)
UPG Event upgraded
CAN Event canceled
EXP Event expired
COR Correction
ROU Routine

Based on these actions, particularly CAN (event canceled), a watch, warning, advisory, or statement can end before it originally was sent out. Therefore, you may not actually want to plot it.

Looking at the components from “P-VTEC String” of the watch, warning, advisory, or statement we can see which pieces are necessary to filter by canceled actions. These components are defined nicely in the VTEC explanation pamphlet.

We use the “Action” (aaa), “Office ID” (cccc), and “Event Tracking Number” (####) to match on existing notices and see if they have been canceled early. If so, we can omit that phensig and geometry from our lists of shape features.

We can investigate what parameters are available for warning data requests with the following:

request = DataAccessLayer.newDataRequest()
request.setDatatype("warning")
params = DataAccessLayer.getAvailableParameters(request)
params.sort()
list(params)

In the output, we can see there are parameters for the three things we are looking for: action (act), office id (wmoid), and event tracking number (etn). We can modify the params array in the EDEX Connection subsection of the notebook to also include these three additional parameters.

params = ["phensig", "sig", "act", "wmoid", "etn"]
request.setParameters(*(params))

Then, when we actually collect the data in the Extract Phensigs, Geometries, and Times notebook subsection, we can store the data using Pandas and the following lines of code:

NOTE: The following lines of code assume that Pandas has been imported as pd.

wwa_pandas = pd.DataFrame()

Inside the for loop, add:

wwa_this = pd.DataFrame()
wwa_this['geometries'] = geometries
wwa_this['wfo'] = site
wwa_this['phensig'] = phensigString
wwa_this['etn'] = etnString
wwa_this['act'] = actString
wwa_this['sig'] = sig

wwa_pandas = pd.concat([wwa_pandas,wwa_this])

Next, we can create a list of shape features that are filtered by the canceled action. We first group the panda data by wfo and etn, so that all of our corresponding WWAs are grouped together, and then we can filter on the ones that have a canceled action.

​​wwa_grouped = wwa_pandas.groupby(['wfo','etn'])

for key, item in wwa_grouped:
 wwa_this = wwa_grouped.get_group(key)
 if wwa_this['act'] != "CAN"
  # get the corresponding color using the dictionary
  color = get_color(wwa_this['phensig'])
  # create a new shape feature for the object
  shape_feature = ShapelyFeature(wwa_this['geometries',ccrs.PlateCarree(),
      facecolor=color, edgecolor=color)

Finally, we store the shape_feature in its corresponding significance array. This will provide the proper display of only active WWAs.

These lines of code were extracted from python scripts written by Unidata user Dr. Russ Schumacher from Colorado State University. You can view his live implementation of python-awips and the WWA functionality on his real-time weather site.

Now that we’ve walked through a few ways to alter and use the Watch Warning and Advisory Plotting notebook, we hope you’ve learned a few new things and can try them out for yourself. Thank you for joining and please check back in two weeks for the next blog post, about Objective Analysis Plots in CAVE.

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

Recent Entries:
Take a poll!

What if we had an ongoing user poll in here?

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