MetPy Mondays #11 - Plotting GOES-16 Data with Widgets

Everyone has been really excited about exploring the incredibly high resolution GOES-16 imagery that is now available in an experimental capacity. We host some of this data on out THREDDS test server and it can be ingested with siphon and plotted in Python! In this week’s MetPy Monday we’ll go over how to use interactive widgets to select the region and channel to plot and produce images from the data.

In a past MetPy Monday we’ve used the notebook interactive widgets to create a simple calculator utility. Everything I’m doing is available in a notebook from our Unidata Python Workshop and can be downloaded here. There’s a lot going on here, but I want to focus on the interactivity this week.

To start out with, we need to import a slew of tools. We’re going to use datetime for generating datetime objects to request data and make nice timestamps, cartopy for mapping, the interactive widgets for UI, matplotlib for the image rendering, netCDF4 to read the data, and siphon to request data.

It’s nice to break the problem up into smaller chunks that become functions. Our first function takes the datetime object, channel, dataset index, and region. It then generates a request to the THREDDS data server and returns a dataset.

The next function is what we’ll actually call. It calls open_dataset to request the data, pulls out the important variables and does the map creation. Here you can see we use the projection variable from the satellite data to specify the globe that cartopy will use for its mapping. We also use that projection information to setup a Lambert Conformal projection. Finally, we get state boundaries much like we did in the mapping with cartopy tutorial.

Next, the function sets up a figure and axis object to plot on and removes any old images plotted there. It also adds the state boundaries and country borders to the map. We use matplotlib’s imshow function to plot the data and let cartopy take care of all the projection issues. We clip the map to the extents of the data by finding the maximum and minimum values of the x and y coordinates.

Finally, we dress up the plot a bit by adding annotations of the image time, channel number, and the notation that these data are still experimental. We use the string parse function (strptime) to create a datetime object from the dataset’s timestamp and then the string format function (strftime) to write it back out as a string in a more readable format. Matplotlib’s text function takes care of plotting the text, but we apply some path effects to outline the white text in black lettering, to help increase the readability on different backgrounds. Finally, we show the figure.

With all the heavy lifting done, all that’s left is creating the interactive parts of the notebook. First, we create a dictionary with the name of the channels on the satellite as the key and the channel number as the value.

We then populate a channel dropdown selector with that dictionary and create a region selector. The GOES satellite transmits images for full disk, CONUS, and two mesoscale regions at different time resolutions. With the widgets made, we just need to hook them up to the plotting function!

We get the current time, then wrap the plotGOES16channel function with interact, just like in the dew point example.

The output we get is a map with two drop down menus allowing us to select and view our data in real-time! With a relatively small amount of code, we were able to create a tool that could be used in the classroom or weather discussions. Try using widgets in your classroom and let us know what you’re doing with notebooks and Unidata technologies!

Comments:

Hi -
I am a newcomer to metPy, It is installed under Windows 10 64-bit without using conda. I have successfully run some example scripts up to those using the cartopy module. I have tried to install it to no avail, Can you please give me precise indications on how to do it
many thanks, HP

Posted by Roesli HansPeter on December 15, 2017 at 03:40 AM MST #

Hi Roesli - Do recommend conda as the installation method, especially for libraries with compiled dependencies such as Cartopy. If you're still having trouble please email support-python@unidata.ucar.edu

Posted by John Leeman on December 17, 2017 at 11:48 PM MST #

Many thanks, John. In the meantime I have convinced myself to use conda. No further problems fo far!
HP

Posted by Roesli HansPeter on December 18, 2017 at 12:03 AM MST #

Great news! Thanks for using MetPy!

Posted by John Leeman on December 18, 2017 at 12:04 AM MST #

Post a Comment:
Comments are closed for this entry.
Unidata Developer's Blog
A weblog about software development by Unidata developers*
Unidata Developer's Blog
A weblog about software development by Unidata developers*

Welcome

FAQs

News@Unidata blog

Take a poll!

What if we had an ongoing user poll in here?

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