"* Cover the relevant methods for accessing EDEX and investigating what data is available. \n",
"* This example we look at the \"grid\" data type and investigate the Global Forcast System (GFS) model. \n",
"* We will talk quite a bit about the **DataAccessLayer** utility, and its [online documentation](http://unidata.github.io/python-awips/api/DataAccessLayer.html#) might be a helpful reference.\n",
"\n",
"---"
]
},
{
"cell_type": "markdown",
"metadata": {
"toc": true
},
"source": [
"<h1>Table of Contents<span class=\"tocSkip\"></span></h1>\n",
"<div class=\"toc\"><ul class=\"toc-item\"><li><span><a href=\"#Imports\" data-toc-modified-id=\"Imports-1\"><span class=\"toc-item-num\">1 </span>Imports</a></span></li><li><span><a href=\"#Connect-to-EDEX\" data-toc-modified-id=\"Connect-to-EDEX-2\"><span class=\"toc-item-num\">2 </span>Connect to EDEX</a></span></li><li><span><a href=\"#Get-a-List-of-Supported-Data-Types\" data-toc-modified-id=\"Get-a-List-of-Supported-Data-Types-3\"><span class=\"toc-item-num\">3 </span>Get a List of Supported Data Types</a></span></li><li><span><a href=\"#Create-a-New-Data-Request-and-Set-the-Type\" data-toc-modified-id=\"Create-a-New-Data-Request-and-Set-the-Type-4\"><span class=\"toc-item-num\">4 </span>Create a New Data Request and Set the Type</a></span></li><li><span><a href=\"#Get-Available-Locations\" data-toc-modified-id=\"Get-Available-Locations-5\"><span class=\"toc-item-num\">5 </span>Get Available Locations</a></span></li><li><span><a href=\"#Get-Available-Parameters\" data-toc-modified-id=\"Get-Available-Parameters-6\"><span class=\"toc-item-num\">6 </span>Get Available Parameters</a></span></li><li><span><a href=\"#Get-Available-Levels\" data-toc-modified-id=\"Get-Available-Levels-7\"><span class=\"toc-item-num\">7 </span>Get Available Levels</a></span></li><li><span><a href=\"#Get-Available-Times\" data-toc-modified-id=\"Get-Available-Times-8\"><span class=\"toc-item-num\">8 </span>Get Available Times</a></span></li><li><span><a href=\"#Get-the-Data!\" data-toc-modified-id=\"Get-the-Data!-9\"><span class=\"toc-item-num\">9 </span>Get the Data!</a></span></li><li><span><a href=\"#See-Also\" data-toc-modified-id=\"See-Also-10\"><span class=\"toc-item-num\">10 </span>See Also</a></span><ul class=\"toc-item\"><li><span><a href=\"#Related-Notebooks\" data-toc-modified-id=\"Related-Notebooks-10.1\"><span class=\"toc-item-num\">10.1 </span>Related Notebooks</a></span></li></ul></li></ul></div>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Imports\n",
"\n",
"Start by importing the DataAccessLayer package from python-awips:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"from awips.dataaccess import DataAccessLayer"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<a href=\"#top\">Top</a>\n",
"\n",
"---"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Connect to EDEX\n",
"\n",
"Define a url for your EDEX connection, and then point python-awips at that EDEX"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"# Unidata's cloud EDEX instance is used in this example\n",
"[***DataAccessLayer.getSupportedDatatypes()***](http://unidata.github.io/python-awips/api/DataAccessLayer.html#awips.dataaccess.DataAccessLayer.getSupportedDatatypes) returns a list of supported data types offered by the EDEX server defined above. The code below shows how to populate, sort, and print out that list."
"## Create a New Data Request and Set the Type\n",
"\n",
"Now create a new data request using [***DataAccessLayer.newDataRequest()***](http://unidata.github.io/python-awips/api/DataAccessLayer.html#awips.dataaccess.DataAccessLayer.newDataRequest), and set the data type using [***request.setDatatype()***](http://unidata.github.io/python-awips/api/IDataRequest.html#awips.dataaccess.IDataRequest.setDatatype). Below we create a few different requests with different data types to show some differences with other methods.\n",
"For this example we are going to look at the \"grid\" data type, which is the model data can be found, along with some other datasets (such as MRMS)."
"Use the [***DataAccessLayer.getAvailableLocationNames(request)***](http://unidata.github.io/python-awips/api/DataAccessLayer.html#awips.dataaccess.DataAccessLayer.getAvailableLocationNames) method to find out what locations are available for the given dataset. Typically these will be geographic locations or NWS sites, although in some instances it will be something else. Take a look at what's outputted for the grid_request, for example."
"Take a look at the available parameters for the data set by using [***DataAccessLayer.getAvailableParameters(request)***](http://unidata.github.io/python-awips/api/DataAccessLayer.html#awips.dataaccess.DataAccessLayer.getAvailableParameters)"
"Setting the parameters is just an option, you do not need to filter the data if you do not wish to. Also, although we are only setting one parameter in this example, you can set multiple parameters by using an array:\n",
"Set a parameter, from the output above and take a look at what \"levels\" are available for the data set you're looking at using [***DataAccessLayer.getAvailableLevels(request)***](http://unidata.github.io/python-awips/api/DataAccessLayer.html#awips.dataaccess.DataAccessLayer.getAvailableLevels)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<div class=\"alert-warning\">\n",
"<b>Warning:</b> Not all datasets support levels. If you are trying this with another dataset and run into an exception (error), it's most likely because levels are not supported for that data type.\n",
"Take a look at what time options are available for the data you're looking at using the [***DataAccessLayer.getAvailableTimes()***](http://unidata.github.io/python-awips/api/DataAccessLayer.html#awips.dataaccess.DataAccessLayer.getAvailableTimes) method:\n",
"Now that we have our `request` and DataTime `fcstRun` arrays ready, it's time to request the data array from EDEX. Depending on what kind of data we're working with, we'll either use [***DataAccessLayer.getGridData()***](http://unidata.github.io/python-awips/api/DataAccessLayer.html#awips.dataaccess.DataAccessLayer.getGridData) or [***DataAccessLayer.getGeometryData()***](http://unidata.github.io/python-awips/api/DataAccessLayer.html#awips.dataaccess.DataAccessLayer.getGeometryData)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<div class=\"alert-info\">\n",
"<b>Note:</b> We have more, detailed notebooks about how analyze and visualize the data once you have what you want.\n",
"Several functions are used throughout this notebook from the DataAccessLayer class in python-awips, to see full documentation for these functions vist [**here**](http://unidata.github.io/python-awips/api/DataAccessLayer.html#).\n",
"\n",
"### Related Notebooks\n",
"\n",
"* [python-awips: Working with Surface Obs](https://nbviewer.jupyter.org/github/Unidata/pyaos-ams-2021/blob/master/notebooks/visualization/python-awips-WorkingWithSurfaceObs.ipynb)\n",
"* [python-awips: Working with Models](https://nbviewer.jupyter.org/github/Unidata/pyaos-ams-2021/blob/master/notebooks/visualization/python-awips-WorkingWithModels.ipynb)\n",
"* [python-awips: Working with Satellite Data](https://nbviewer.jupyter.org/github/Unidata/pyaos-ams-2021/blob/master/notebooks/visualization/python-awips-WorkingWithSatelliteData.ipynb)\n",
"* [python-awips: Working with Upper Air Obs](https://nbviewer.jupyter.org/github/Unidata/pyaos-ams-2021/blob/master/notebooks/visualization/python-awips-WorkingWithUpperAirObs.ipynb)\n",
"* [python-awips: Working with Maps and Topography Databases](https://nbviewer.jupyter.org/github/Unidata/pyaos-ams-2021/blob/master/notebooks/visualization/python-awips-WorkingWithMapsTopoDatabases.ipynb)"