Merge branch 'main' of github.com:Unidata/python-awips into notebook-updates

This commit is contained in:
Shay Carter 2021-06-22 12:06:03 -06:00
commit 2101794ed4
5 changed files with 791 additions and 290 deletions

View file

@ -1,7 +1,10 @@
name: Publish Sphinx Built Webpages to Github Pages
on:
workflow_dispatch:
push:
branches:
- website
paths:
- 'docs/**'
- 'examples/**'

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

File diff suppressed because one or more lines are too long

View file

@ -4,22 +4,110 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"This example covers the callable methods of python-awips when working with gridded data. We start with a connection to an EDEX server, then query data types, then grid names, parameters, levels, and other information. Finally the gridded data is plotted for its domain using Matplotlib and Cartopy."
"<a name=\"top\"></a>\n",
"<div style=\"width:1000 px\">\n",
"\n",
"<div style=\"float:right; width:98 px; height:98px;\">\n",
"<img src=\"https://docs.unidata.ucar.edu/images/logos/unidata_logo_vertical_150x150.png\" alt=\"Unidata Logo\" style=\"height: 98px;\">\n",
"</div>\n",
"\n",
"# Grid Levels and Parameters\n",
"**Python-AWIPS Tutorial Notebook**\n",
"\n",
"<div style=\"clear:both\"></div>\n",
"</div>\n",
"\n",
"---\n",
"\n",
"\n",
"# Objectives\n",
"\n",
"* 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&nbsp;&nbsp;</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&nbsp;&nbsp;</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&nbsp;&nbsp;</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&nbsp;&nbsp;</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&nbsp;&nbsp;</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&nbsp;&nbsp;</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&nbsp;&nbsp;</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&nbsp;&nbsp;</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&nbsp;&nbsp;</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&nbsp;&nbsp;</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&nbsp;&nbsp;</span>Related Notebooks</a></span></li></ul></li></ul></div>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## DataAccessLayer.getSupportedDatatypes()\n",
"## Imports\n",
"\n",
"getSupportedDatatypes() returns a list of available data types offered by the EDEX server defined above. "
"Start by importing the DataAccessLayer package from python-awips:"
]
},
{
"cell_type": "code",
"execution_count": 1,
"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": 2,
"metadata": {},
"outputs": [],
"source": [
"# Unidata's cloud EDEX instance is used in this example\n",
"edex_url = \"edex-cloud.unidata.ucar.edu\"\n",
"DataAccessLayer.changeEDEXHost(edex_url)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<a href=\"#top\">Top</a>\n",
"\n",
"---"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Get a List of Supported Data Types\n",
"\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."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
@ -53,16 +141,12 @@
" 'warning']"
]
},
"execution_count": 1,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from awips.dataaccess import DataAccessLayer\n",
"import unittest\n",
"\n",
"DataAccessLayer.changeEDEXHost(\"edex-cloud.unidata.ucar.edu\")\n",
"dataTypes = DataAccessLayer.getSupportedDatatypes()\n",
"dataTypes.sort()\n",
"list(dataTypes)"
@ -72,14 +156,45 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## DataAccessLayer.getAvailableLocationNames()\n",
"<a href=\"#top\">Top</a>\n",
"\n",
"Now create a new data request, and set the data type to **grid** to request all available grids with **getAvailableLocationNames()**"
"---"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 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",
"\n",
"For this example we are going to look at the ***grid*** data type, which is where the model data can be found, along with some other datasets (such as MRMS)."
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"# Create a request for data type grid\n",
"grid_request = DataAccessLayer.newDataRequest()\n",
"grid_request.setDatatype(\"grid\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Get Available Locations\n",
"\n",
"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."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
@ -101,8 +216,9 @@
" 'FFG-TAR',\n",
" 'FFG-TIR',\n",
" 'FFG-TUA',\n",
" 'GEFS',\n",
" 'GFS',\n",
" 'FNMOC-NCODA',\n",
" 'FNMOC-WW3',\n",
" 'GFS1p0',\n",
" 'GFS20',\n",
" 'HFR-EAST_6KM',\n",
" 'HFR-EAST_PR_6KM',\n",
@ -132,7 +248,6 @@
" 'NAM12',\n",
" 'NAM40',\n",
" 'NOHRSC-SNOW',\n",
" 'NationalBlend',\n",
" 'RAP13',\n",
" 'RTMA',\n",
" 'RTOFS-Now-WestAtl',\n",
@ -143,34 +258,44 @@
" 'SeaIce',\n",
" 'TPCWindProb',\n",
" 'URMA25',\n",
" 'WaveWatch']"
" 'navgem0p5']"
]
},
"execution_count": 2,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"request = DataAccessLayer.newDataRequest()\n",
"request.setDatatype(\"grid\")\n",
"available_grids = DataAccessLayer.getAvailableLocationNames(request)\n",
"available_grids.sort()\n",
"list(available_grids)"
"# Grid Locations\n",
"grid_locations = DataAccessLayer.getAvailableLocationNames(grid_request)\n",
"grid_locations.sort()\n",
"list(grid_locations)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## DataAccessLayer.getAvailableParameters()\n",
"<a href=\"#top\">Top</a>\n",
"\n",
"After datatype and model name (locationName) are set, you can query all available parameters with **getAvailableParameters()**"
"---"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Get Available Parameters\n",
"\n",
"We're setting the \"location\" (in this case, what model we are interested in) to specify our request before we look at the available parameters.\n",
"\n",
"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)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 6,
"metadata": {},
"outputs": [
{
@ -192,16 +317,25 @@
" 'BlkShr',\n",
" 'CAPE',\n",
" 'CFRZR',\n",
" 'CFRZR3hr',\n",
" 'CFRZR6hr',\n",
" 'CICEP',\n",
" 'CICEP3hr',\n",
" 'CICEP6hr',\n",
" 'CIn',\n",
" 'CP',\n",
" 'CP1hr',\n",
" 'CP-GFS',\n",
" 'CP3hr',\n",
" 'CP6hr',\n",
" 'CPr',\n",
" 'CPrD',\n",
" 'CRAIN',\n",
" 'CRAIN3hr',\n",
" 'CRAIN6hr',\n",
" 'CSNOW',\n",
" 'CSNOW3hr',\n",
" 'CSNOW6hr',\n",
" 'CURU',\n",
" 'CXR',\n",
" 'CapeStk',\n",
" 'Corf',\n",
" 'CorfF',\n",
@ -218,6 +352,7 @@
" 'EHI',\n",
" 'EHI01',\n",
" 'EHIi',\n",
" 'EMSP',\n",
" 'EPT',\n",
" 'EPTA',\n",
" 'EPTC',\n",
@ -231,7 +366,6 @@
" 'ESP',\n",
" 'ESP2',\n",
" 'FVecs',\n",
" 'FeatMot',\n",
" 'FnVecs',\n",
" 'FsVecs',\n",
" 'Fzra1',\n",
@ -239,13 +373,12 @@
" 'GH',\n",
" 'GHxSM',\n",
" 'GHxSM2',\n",
" 'Gust',\n",
" 'GVV',\n",
" 'HI',\n",
" 'HI1',\n",
" 'HI3',\n",
" 'HI4',\n",
" 'HIdx',\n",
" 'HPBL',\n",
" 'Heli',\n",
" 'HeliC',\n",
" 'INV',\n",
@ -261,7 +394,6 @@
" 'MCon2',\n",
" 'MLLCL',\n",
" 'MMP',\n",
" 'MMSP',\n",
" 'MSFDi',\n",
" 'MSFi',\n",
" 'MSFmi',\n",
@ -270,13 +402,18 @@
" 'Mix1',\n",
" 'Mix2',\n",
" 'Mmag',\n",
" 'MnT3hr',\n",
" 'MnT6hr',\n",
" 'MpV',\n",
" 'MxT3hr',\n",
" 'MxT6hr',\n",
" 'NBE',\n",
" 'NST',\n",
" 'NST1',\n",
" 'NST2',\n",
" 'OmDiff',\n",
" 'P',\n",
" 'P3hr',\n",
" 'P6hr',\n",
" 'PAdv',\n",
" 'PBE',\n",
" 'PEC',\n",
@ -285,10 +422,8 @@
" 'PGrd1',\n",
" 'PGrdM',\n",
" 'PIVA',\n",
" 'PR',\n",
" 'PTvA',\n",
" 'PTyp',\n",
" 'PVV',\n",
" 'PW',\n",
" 'PW2',\n",
" 'PoT',\n",
@ -297,7 +432,6 @@
" 'QPV2',\n",
" 'QPV3',\n",
" 'QPV4',\n",
" 'REFC',\n",
" 'RH',\n",
" 'RH_001_bin',\n",
" 'RH_002_bin',\n",
@ -305,7 +439,6 @@
" 'RM6',\n",
" 'RMprop',\n",
" 'RMprop2',\n",
" 'RRtype',\n",
" 'RV',\n",
" 'Rain1',\n",
" 'Rain2',\n",
@ -329,7 +462,6 @@
" 'STP1',\n",
" 'Shear',\n",
" 'ShrMag',\n",
" 'SnD',\n",
" 'Snow1',\n",
" 'Snow2',\n",
" 'Snow3',\n",
@ -345,7 +477,9 @@
" 'TORi',\n",
" 'TORi2',\n",
" 'TP',\n",
" 'TP1hr',\n",
" 'TP-GFS',\n",
" 'TP3hr',\n",
" 'TP6hr',\n",
" 'TQIND',\n",
" 'TShrMi',\n",
" 'TV',\n",
@ -367,20 +501,15 @@
" 'TwMin',\n",
" 'Twstk',\n",
" 'TxSM',\n",
" 'USTM',\n",
" 'VAdv',\n",
" 'VAdvAdvection',\n",
" 'VGP',\n",
" 'VSTM',\n",
" 'Vis',\n",
" 'VSS',\n",
" 'WCD',\n",
" 'WD',\n",
" 'WEASD',\n",
" 'WEASD1hr',\n",
" 'WGS',\n",
" 'Wind',\n",
" 'WndChl',\n",
" 'ageoVC',\n",
" 'ageoW',\n",
" 'ageoWM',\n",
" 'cCape',\n",
@ -439,7 +568,6 @@
" 'vTOT',\n",
" 'vW',\n",
" 'vWStk',\n",
" 'vertCirc',\n",
" 'wDiv',\n",
" 'wSp',\n",
" 'wSp_001_bin',\n",
@ -449,33 +577,57 @@
" 'zAGL']"
]
},
"execution_count": 3,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"request.setLocationNames(\"RAP13\")\n",
"availableParms = DataAccessLayer.getAvailableParameters(request)\n",
"availableParms.sort()\n",
"list(availableParms)"
"# Pick a model and set the location for the grid request -- we'll be using the Global Forecast System 20km (GFS20) \n",
"grid_request.setLocationNames(\"GFS20\")\n",
"grid_params = DataAccessLayer.getAvailableParameters(grid_request)\n",
"grid_params.sort()\n",
"list(grid_params)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## DataAccessLayer.getAvailableLevels()\n",
"<a href=\"#top\">Top</a>\n",
"\n",
"Selecting **\"T\"** for temperature."
"---"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Get Available Levels\n",
"\n",
"\n",
"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",
"```\n",
"params = (\"param1\", \"param2\", \"param3\"...)\n",
"request.setParameters(params)\n",
"```\n",
"\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",
"</div> "
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"scrolled": true
},
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
@ -483,20 +635,15 @@
"text": [
"0.0SFC\n",
"350.0MB\n",
"475.0MB\n",
"610.0_40000.0FHAG\n",
"225.0MB\n",
"120.0_150.0BL\n",
"900.0MB\n",
"125.0MB\n",
"0.0_610.0FHAG\n",
"450.0MB\n",
"575.0MB\n",
"325.0MB\n",
"100.0MB\n",
"1000.0MB\n",
"60.0_90.0BL\n",
"275.0MB\n",
"1.0PV\n",
"950.0MB\n",
"150.0MB\n",
@ -505,7 +652,6 @@
"825.0MB\n",
"150.0_180.0BL\n",
"250.0MB\n",
"375.0MB\n",
"1000.0_500.0MB\n",
"800.0MB\n",
"4000.0FHAG\n",
@ -520,7 +666,6 @@
"0.0FHAG\n",
"2.0FHAG\n",
"875.0MB\n",
"175.0MB\n",
"0.0_1000.0FHAG\n",
"850.0MB\n",
"600.0MB\n",
@ -530,7 +675,6 @@
"550.0MB\n",
"0.0_3000.0FHAG\n",
"675.0MB\n",
"425.0MB\n",
"200.0MB\n",
"0.0_30.0BL\n",
"30.0_60.0BL\n",
@ -602,7 +746,6 @@
"2000.0_8000.0FHAG\n",
"0.0_609.6FHAG\n",
"300.0K\n",
"0.0MAXOMEGA\n",
"315.0_325.0K\n",
"325.0K\n",
"340.0Ke\n",
@ -735,14 +878,16 @@
"6000.0FHAG\n",
"8000.0_9000.0FHAG\n",
"700.0_300.0LYRMB\n",
"850.0_700.0LYRMB\n"
"850.0_700.0LYRMB\n",
"1000.0_500.0LYRMB\n"
]
}
],
"source": [
"request.setParameters(\"T\")\n",
"availableLevels = DataAccessLayer.getAvailableLevels(request)\n",
"for lvl in availableLevels:\n",
"# For grid data we'll use the temperature parameter (\"T\")\n",
"grid_request.setParameters(\"T\")\n",
"grid_levels = DataAccessLayer.getAvailableLevels(grid_request)\n",
"for lvl in grid_levels:\n",
" print(lvl)"
]
},
@ -750,31 +895,42 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"* **0.0SFC** is the Surface level\n",
"* **FHAG** stands for Fixed Height Above Ground (in meters)\n",
"* **NTAT** stands for Nominal Top of the ATmosphere\n",
"* **BL** stands for Boundary Layer, where **0.0_30.0BL** reads as *0-30 mb above ground level* \n",
"* **TROP** is the Tropopause level\n",
"\n",
"**request.setLevels()**\n",
"\n",
"For this example we will use Surface Temperature"
"<div class=\"alert-info\">\n",
"<b>Note:</b> \n",
" <li><b>0.0SFC</b> is the Surface level</li>\n",
" <li><b>HAG</b> stands for Fixed Height Above Ground (in meters)</li>\n",
" <li><b>NTAT</b> stands for Nominal Top of the ATmosphere</li>\n",
" <li><b>BL</b> stands for Boundary Layer, where <b>0.0_30.0BL</b> reads as <i>0-30 mb above ground level</i></li> \n",
" <li><b>TROP</b> is the Tropopause level\n",
"</div>"
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"request.setLevels(\"2.0FHAG\")"
"# We'll set the level to surface level\n",
"grid_request.setLevels(\"0.0SFC\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## DataAccessLayer.getAvailableTimes()\n",
"<a href=\"#top\">Top</a>\n",
"\n",
"---"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Get Available Times\n",
"\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",
"\n",
"* **getAvailableTimes(request, True)** will return an object of *run times* - formatted as `YYYY-MM-DD HH:MM:SS`\n",
"* **getAvailableTimes(request)** will return an object of all times - formatted as `YYYY-MM-DD HH:MM:SS (F:ff)`\n",
@ -783,85 +939,168 @@
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[<DataTime instance: 2020-09-04 18:00:00 >,\n",
" <DataTime instance: 2020-09-04 18:00:00 >,\n",
" <DataTime instance: 2020-09-04 18:00:00 >,\n",
" <DataTime instance: 2020-09-04 18:00:00 >,\n",
" <DataTime instance: 2020-09-04 18:00:00 >,\n",
" <DataTime instance: 2020-09-04 18:00:00 >,\n",
" <DataTime instance: 2020-09-04 18:00:00 >,\n",
" <DataTime instance: 2020-09-04 18:00:00 >,\n",
" <DataTime instance: 2020-09-04 18:00:00 >,\n",
" <DataTime instance: 2020-09-04 18:00:00 >,\n",
" <DataTime instance: 2020-09-04 18:00:00 >,\n",
" <DataTime instance: 2020-09-04 18:00:00 >,\n",
" <DataTime instance: 2020-09-04 18:00:00 >,\n",
" <DataTime instance: 2020-09-04 18:00:00 >,\n",
" <DataTime instance: 2020-09-04 18:00:00 >,\n",
" <DataTime instance: 2020-09-04 18:00:00 >,\n",
" <DataTime instance: 2020-09-04 18:00:00 >,\n",
" <DataTime instance: 2020-09-04 18:00:00 >,\n",
" <DataTime instance: 2020-09-04 18:00:00 >,\n",
" <DataTime instance: 2020-09-04 18:00:00 >,\n",
" <DataTime instance: 2020-09-04 18:00:00 >,\n",
" <DataTime instance: 2020-09-04 18:00:00 >]"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cycles = DataAccessLayer.getAvailableTimes(request, True)\n",
"times = DataAccessLayer.getAvailableTimes(request)\n",
"fcstRun = DataAccessLayer.getForecastRun(cycles[-1], times)\n",
"list(fcstRun)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## DataAccessLayer.getGridData()\n",
"\n",
"Now that we have our `request` and DataTime `fcstRun` arrays ready, it's time to request the data array from EDEX."
]
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Time : 2020-09-04 18:00:00\n",
"Model: RAP13\n",
"Parm : T\n",
"Unit : K\n",
"(337, 451)\n"
"2021-06-01 12:00:00.000 : 0 seconds\n",
"2021-06-01 12:00:00.000 : 10800 seconds\n",
"2021-06-01 12:00:00.000 : 21600 seconds\n",
"2021-06-01 12:00:00.000 : 32400 seconds\n",
"2021-06-01 12:00:00.000 : 43200 seconds\n",
"2021-06-01 12:00:00.000 : 54000 seconds\n",
"2021-06-01 12:00:00.000 : 64800 seconds\n",
"2021-06-01 12:00:00.000 : 75600 seconds\n",
"2021-06-01 12:00:00.000 : 86400 seconds\n",
"2021-06-01 12:00:00.000 : 97200 seconds\n",
"2021-06-01 12:00:00.000 : 108000 seconds\n",
"2021-06-01 12:00:00.000 : 118800 seconds\n",
"2021-06-01 12:00:00.000 : 129600 seconds\n",
"2021-06-01 12:00:00.000 : 140400 seconds\n",
"2021-06-01 12:00:00.000 : 151200 seconds\n",
"2021-06-01 12:00:00.000 : 162000 seconds\n",
"2021-06-01 12:00:00.000 : 172800 seconds\n",
"2021-06-01 12:00:00.000 : 183600 seconds\n",
"2021-06-01 12:00:00.000 : 194400 seconds\n",
"2021-06-01 12:00:00.000 : 205200 seconds\n",
"2021-06-01 12:00:00.000 : 216000 seconds\n",
"2021-06-01 12:00:00.000 : 226800 seconds\n",
"2021-06-01 12:00:00.000 : 237600 seconds\n",
"2021-06-01 12:00:00.000 : 248400 seconds\n",
"2021-06-01 12:00:00.000 : 259200 seconds\n",
"2021-06-01 12:00:00.000 : 270000 seconds\n",
"2021-06-01 12:00:00.000 : 280800 seconds\n",
"2021-06-01 12:00:00.000 : 291600 seconds\n",
"2021-06-01 12:00:00.000 : 302400 seconds\n",
"2021-06-01 12:00:00.000 : 324000 seconds\n",
"2021-06-01 12:00:00.000 : 345600 seconds\n",
"2021-06-01 12:00:00.000 : 367200 seconds\n",
"2021-06-01 12:00:00.000 : 388800 seconds\n",
"2021-06-01 12:00:00.000 : 410400 seconds\n",
"2021-06-01 12:00:00.000 : 432000 seconds\n",
"2021-06-01 12:00:00.000 : 453600 seconds\n",
"2021-06-01 12:00:00.000 : 475200 seconds\n",
"2021-06-01 12:00:00.000 : 496800 seconds\n",
"2021-06-01 12:00:00.000 : 518400 seconds\n",
"2021-06-01 12:00:00.000 : 540000 seconds\n",
"2021-06-01 12:00:00.000 : 561600 seconds\n",
"2021-06-01 12:00:00.000 : 583200 seconds\n",
"2021-06-01 12:00:00.000 : 604800 seconds\n",
"2021-06-01 12:00:00.000 : 626400 seconds\n",
"2021-06-01 12:00:00.000 : 648000 seconds\n",
"2021-06-01 12:00:00.000 : 669600 seconds\n",
"2021-06-01 12:00:00.000 : 691200 seconds\n",
"2021-06-01 12:00:00.000 : 712800 seconds\n",
"2021-06-01 12:00:00.000 : 734400 seconds\n",
"2021-06-01 12:00:00.000 : 756000 seconds\n",
"2021-06-01 12:00:00.000 : 777600 seconds\n",
"2021-06-01 12:00:00.000 : 799200 seconds\n",
"2021-06-01 12:00:00.000 : 820800 seconds\n",
"2021-06-01 12:00:00.000 : 842400 seconds\n",
"2021-06-01 12:00:00.000 : 864000 seconds\n"
]
}
],
"source": [
"response = DataAccessLayer.getGridData(request, [fcstRun[-1]])\n",
"for grid in response:\n",
" data = grid.getRawData()\n",
" lons, lats = grid.getLatLonCoords()\n",
" print('Time :', str(grid.getDataTime()))\n",
"# Available grid times\n",
"grid_cycles = DataAccessLayer.getAvailableTimes(grid_request, True)\n",
"grid_times = DataAccessLayer.getAvailableTimes(grid_request)\n",
"## Using -1 in an array will access the last element of the array \n",
"## (using -2 will access the second last element, and so on)\n",
"grid_fcstRun = DataAccessLayer.getForecastRun(grid_cycles[-1], grid_times)\n",
"\n",
"## print out the time instances\n",
"times = []\n",
"for fcst in grid_fcstRun:\n",
" print(fcst.getRefTime(), ':', fcst.getFcstTime(), 'seconds')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<a href=\"#top\">Top</a>\n",
"\n",
"---"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Get the Data!\n",
"\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",
"</div>"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Time : 2021-06-01 12:00:00 - 864000 seconds\n",
"Model: GFS20\n",
"Parm : T\n",
"Unit : K\n",
"(257, 369)\n"
]
}
],
"source": [
"## Grid Data\n",
"grid_response = DataAccessLayer.getGridData(grid_request, [grid_fcstRun[-1]])\n",
"for grid in grid_response:\n",
" grid_data = grid.getRawData()\n",
" lons, lats = grid.getLatLonCoords()\n",
" print('Time :', grid.getDataTime(), \"-\", grid.getDataTime().getFcstTime(), 'seconds')\n",
"\n",
"## Take a look at some information in our data\n",
"print('Model:', str(grid.getLocationName()))\n",
"print('Parm :', str(grid.getParameter()))\n",
"print('Unit :', str(grid.getUnit()))\n",
"print(data.shape)"
"print(grid_data.shape)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## See Also\n",
"\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",
"* [Colored Surface Temperature Plot](https://unidata.github.io/python-awips/examples/generated/Colored_Surface_Temperature_Plot.html)\n",
"* [Grids and Cartopy](https://unidata.github.io/python-awips/examples/generated/Grids_and_Cartopy.html)\n",
"* [Satellite Imagery](https://unidata.github.io/python-awips/examples/generated/Satellite_Imagery.html)\n",
"* [Upper Air BUFR Soundings](https://unidata.github.io/python-awips/examples/generated/Upper_Air_BUFR_Soundings.html)\n",
"* [Maps Resources and Topography](https://unidata.github.io/python-awips/examples/generated/Map_Resources_and_Topography.html)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<a href=\"#top\">Top</a>\n",
"\n",
"---"
]
}
],
@ -888,15 +1127,15 @@
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"skip_h1_title": true,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_cell": true,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
"toc_window_display": true
}
},
"nbformat": 4,
"nbformat_minor": 1
"nbformat_minor": 4
}

File diff suppressed because one or more lines are too long