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
With the DataAccessLayer initialized, the standard workflow needed to create a 2D array of model output looks like this:
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:
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 firstname.lastname@example.org