AWIPS Tips: Access Model Output with Python-AWIPS

AWIPS Tips

Welcome back to AWIPS Tips! Today we’re talking about data access with python-awips. If you use Python and need data from an EDEX server, python-awips is the package you need. While there are many utilities of python-awips, today we’re focusing on accessing model output. We will walk through a brief explanation of the methods needed in succession to create a final 2D array of temperature from the RAP13 model. Much more detail and explanation on how to access data can be found in this tutorial. Once you have installed python-awips, you can follow along with this blog in a Jupyter Notebook or IDE of your choosing.

The very first thing you’ll do anytime you access data from an EDEX using python-awips is import the DataAccessLayer and establish a connection to an EDEX server. If you use the Unidata EDEX, your first few lines of code will look like this:

from awips.dataaccess import DataAccessLayer
DataAccessLayer.changeEDEXHost("edex-cloud.unidata.ucar.edu")

With the DataAccessLayer initialized, the standard workflow needed to create a 2D array of model output looks like this:

Create a request, set properties, send request

In python-awips, the “location” can have different meanings. For accessing gridded model output like we will in this blog, “location” refers to a specific model. However, “location” may refer to a sector or site name for other data types.

Let’s create a request for 2 meter AGL temperature from the RAP13 model. Setting up the request will look like this:

request = DataAccessLayer.newDataRequest()
request.setDatatype("grid") # "grid" for model output
request.setLocationNames("RAP13") # RAP13 model
request.setParameters("T") # Temperature
request.setLevels("2.0FHAG") # 2 meter fixed height above ground

As we have it set up now, this request will pull all available valid times from all available forecast runs, which is more data than we need. For this example, we’ll only select the latest forecast run from the latest valid time:

cycles = DataAccessLayer.getAvailableTimes(request, True)
times = DataAccessLayer.getAvailableTimes(request)
fcstRun = DataAccessLayer.getForecastRun(cycles[-1], times)
reqtime = [fcstRun[-1]]

Now it’s time to get the data returned in a response:

response = DataAccessLayer.getGridData(request, reqtime)

The response variable is of type list. Since we requested only a single time, our resultant 2D array is stored in:

response[0].getRawData()

This can now be used for analysis or plotting. For more detail on the specific steps taken in this blog, check out the Grid Levels and Parameters tutorial notebook.

Stay tuned two weeks from today for the next blog post, where we will discuss how to explore datasets in CAVE with the Product Browser.

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