From da7b9caafb8afd002511c14fd3cee6a05cc5c6bf Mon Sep 17 00:00:00 2001 From: Shay Carter Date: Tue, 1 Jun 2021 11:03:31 -0600 Subject: [PATCH] Convert Grid Levels and Params to use new template --- .../Grid_Levels_and_Parameters.ipynb | 1123 ++++++----------- 1 file changed, 418 insertions(+), 705 deletions(-) diff --git a/examples/notebooks/Grid_Levels_and_Parameters.ipynb b/examples/notebooks/Grid_Levels_and_Parameters.ipynb index 004aa78..8b2c74a 100644 --- a/examples/notebooks/Grid_Levels_and_Parameters.ipynb +++ b/examples/notebooks/Grid_Levels_and_Parameters.ipynb @@ -4,21 +4,109 @@ "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." + "\n", + "
\n", + "\n", + "
\n", + "\"Unidata\n", + "
\n", + "\n", + "# Grid Levels and Parameters\n", + "**Python-AWIPS Tutorial Notebook**\n", + "\n", + "
\n", + "
\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": [ + "

Table of Contents

\n", + "
" ] }, { "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, + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "from awips.dataaccess import DataAccessLayer" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Top\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", + "edex_url = \"edex-cloud.unidata.ucar.edu\"\n", + "DataAccessLayer.changeEDEXHost(edex_url)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Top\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": 4, "metadata": {}, "outputs": [ { @@ -53,16 +141,12 @@ " 'warning']" ] }, - "execution_count": 1, + "execution_count": 4, "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", + "Top\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 the model data can be found, along with some other datasets (such as MRMS)." ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 5, + "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": 6, "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,674 +258,7 @@ " 'SeaIce',\n", " 'TPCWindProb',\n", " 'URMA25',\n", - " 'WaveWatch']" - ] - }, - "execution_count": 2, - "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)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## DataAccessLayer.getAvailableParameters()\n", - "\n", - "After datatype and model name (locationName) are set, you can query all available parameters with **getAvailableParameters()**" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "['36SHRMi',\n", - " '50dbzZ',\n", - " 'AV',\n", - " 'Along',\n", - " 'AppT',\n", - " 'BLI',\n", - " 'BRN',\n", - " 'BRNEHIi',\n", - " 'BRNSHR',\n", - " 'BRNmag',\n", - " 'BRNvec',\n", - " 'BdEPT06',\n", - " 'BlkMag',\n", - " 'BlkShr',\n", - " 'CAPE',\n", - " 'CFRZR',\n", - " 'CICEP',\n", - " 'CIn',\n", - " 'CP',\n", - " 'CP1hr',\n", - " 'CPr',\n", - " 'CPrD',\n", - " 'CRAIN',\n", - " 'CSNOW',\n", - " 'CURU',\n", - " 'CXR',\n", - " 'CapeStk',\n", - " 'Corf',\n", - " 'CorfF',\n", - " 'CorfFM',\n", - " 'CorfM',\n", - " 'CritT1',\n", - " 'CumNrm',\n", - " 'CumShr',\n", - " 'DivF',\n", - " 'DivFn',\n", - " 'DivFs',\n", - " 'DpD',\n", - " 'DpT',\n", - " 'EHI',\n", - " 'EHI01',\n", - " 'EHIi',\n", - " 'EPT',\n", - " 'EPTA',\n", - " 'EPTC',\n", - " 'EPTGrd',\n", - " 'EPTGrdM',\n", - " 'EPTs',\n", - " 'EPVg',\n", - " 'EPVs',\n", - " 'EPVt1',\n", - " 'EPVt2',\n", - " 'ESP',\n", - " 'ESP2',\n", - " 'FVecs',\n", - " 'FeatMot',\n", - " 'FnVecs',\n", - " 'FsVecs',\n", - " 'Fzra1',\n", - " 'Fzra2',\n", - " 'GH',\n", - " 'GHxSM',\n", - " 'GHxSM2',\n", - " 'Gust',\n", - " 'HI',\n", - " 'HI1',\n", - " 'HI3',\n", - " 'HI4',\n", - " 'HIdx',\n", - " 'HPBL',\n", - " 'Heli',\n", - " 'HeliC',\n", - " 'INV',\n", - " 'IPLayer',\n", - " 'Into',\n", - " 'KI',\n", - " 'L-I',\n", - " 'LIsfc2x',\n", - " 'LM5',\n", - " 'LM6',\n", - " 'MAdv',\n", - " 'MCon',\n", - " 'MCon2',\n", - " 'MLLCL',\n", - " 'MMP',\n", - " 'MMSP',\n", - " 'MSFDi',\n", - " 'MSFi',\n", - " 'MSFmi',\n", - " 'MSG',\n", - " 'MTV',\n", - " 'Mix1',\n", - " 'Mix2',\n", - " 'Mmag',\n", - " 'MpV',\n", - " 'NBE',\n", - " 'NST',\n", - " 'NST1',\n", - " 'NST2',\n", - " 'OmDiff',\n", - " 'P',\n", - " 'PAdv',\n", - " 'PBE',\n", - " 'PEC',\n", - " 'PFrnt',\n", - " 'PGrd',\n", - " 'PGrd1',\n", - " 'PGrdM',\n", - " 'PIVA',\n", - " 'PR',\n", - " 'PTvA',\n", - " 'PTyp',\n", - " 'PVV',\n", - " 'PW',\n", - " 'PW2',\n", - " 'PoT',\n", - " 'PoTA',\n", - " 'QPV1',\n", - " 'QPV2',\n", - " 'QPV3',\n", - " 'QPV4',\n", - " 'REFC',\n", - " 'RH',\n", - " 'RH_001_bin',\n", - " 'RH_002_bin',\n", - " 'RM5',\n", - " 'RM6',\n", - " 'RMprop',\n", - " 'RMprop2',\n", - " 'RRtype',\n", - " 'RV',\n", - " 'Rain1',\n", - " 'Rain2',\n", - " 'Rain3',\n", - " 'Ro',\n", - " 'SH',\n", - " 'SHx',\n", - " 'SLI',\n", - " 'SNSQ',\n", - " 'SNW',\n", - " 'SNWA',\n", - " 'SRMl',\n", - " 'SRMlM',\n", - " 'SRMm',\n", - " 'SRMmM',\n", - " 'SRMr',\n", - " 'SRMrM',\n", - " 'SSP',\n", - " 'SSi',\n", - " 'STP',\n", - " 'STP1',\n", - " 'Shear',\n", - " 'ShrMag',\n", - " 'SnD',\n", - " 'Snow1',\n", - " 'Snow2',\n", - " 'Snow3',\n", - " 'SnowT',\n", - " 'St-Pr',\n", - " 'StrTP',\n", - " 'StrmMot',\n", - " 'SuCP',\n", - " 'T',\n", - " 'TAdv',\n", - " 'TGrd',\n", - " 'TGrdM',\n", - " 'TORi',\n", - " 'TORi2',\n", - " 'TP',\n", - " 'TP1hr',\n", - " 'TQIND',\n", - " 'TShrMi',\n", - " 'TV',\n", - " 'TW',\n", - " 'T_001_bin',\n", - " 'Tdef',\n", - " 'Tdend',\n", - " 'ThGrd',\n", - " 'Thom5',\n", - " 'Thom5a',\n", - " 'Thom6',\n", - " 'TmDpD',\n", - " 'Tmax',\n", - " 'Tmin',\n", - " 'Topo',\n", - " 'TotQi',\n", - " 'Tstk',\n", - " 'TwMax',\n", - " 'TwMin',\n", - " 'Twstk',\n", - " 'TxSM',\n", - " 'USTM',\n", - " 'VAdv',\n", - " 'VAdvAdvection',\n", - " 'VGP',\n", - " 'VSTM',\n", - " 'Vis',\n", - " 'WCD',\n", - " 'WD',\n", - " 'WEASD',\n", - " 'WEASD1hr',\n", - " 'WGS',\n", - " 'Wind',\n", - " 'WndChl',\n", - " 'ageoVC',\n", - " 'ageoW',\n", - " 'ageoWM',\n", - " 'cCape',\n", - " 'cCin',\n", - " 'cTOT',\n", - " 'capeToLvl',\n", - " 'dCape',\n", - " 'dP',\n", - " 'dT',\n", - " 'dVAdv',\n", - " 'dZ',\n", - " 'defV',\n", - " 'del2gH',\n", - " 'df',\n", - " 'fGen',\n", - " 'fnD',\n", - " 'fsD',\n", - " 'gamma',\n", - " 'gammaE',\n", - " 'geoVort',\n", - " 'geoW',\n", - " 'geoWM',\n", - " 'loCape',\n", - " 'maxEPT',\n", - " 'minEPT',\n", - " 'mixRat',\n", - " 'msl-P',\n", - " 'muCape',\n", - " 'pV',\n", - " 'pVeq',\n", - " 'qDiv',\n", - " 'qVec',\n", - " 'qnVec',\n", - " 'qsVec',\n", - " 'shWlt',\n", - " 'snoRat',\n", - " 'snoRatCrocus',\n", - " 'snoRatEMCSREF',\n", - " 'snoRatOv2',\n", - " 'snoRatSPC',\n", - " 'snoRatSPCdeep',\n", - " 'snoRatSPCsurface',\n", - " 'staticCoriolis',\n", - " 'staticSpacing',\n", - " 'staticTopo',\n", - " 'swtIdx',\n", - " 'tTOT',\n", - " 'tWind',\n", - " 'tWindU',\n", - " 'tWindV',\n", - " 'uFX',\n", - " 'uW',\n", - " 'uWStk',\n", - " 'ulSnoRat',\n", - " 'vSmthW',\n", - " 'vTOT',\n", - " 'vW',\n", - " 'vWStk',\n", - " 'vertCirc',\n", - " 'wDiv',\n", - " 'wSp',\n", - " 'wSp_001_bin',\n", - " 'wSp_002_bin',\n", - " 'wSp_003_bin',\n", - " 'wSp_004_bin',\n", - " 'zAGL']" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "request.setLocationNames(\"RAP13\")\n", - "availableParms = DataAccessLayer.getAvailableParameters(request)\n", - "availableParms.sort()\n", - "list(availableParms)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## DataAccessLayer.getAvailableLevels()\n", - "\n", - "Selecting **\"T\"** for temperature." - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "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", - "1.5PV\n", - "700.0MB\n", - "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", - "925.0MB\n", - "2.0PV\n", - "0.5PV\n", - "0.0TROP\n", - "750.0MB\n", - "500.0MB\n", - "625.0MB\n", - "400.0MB\n", - "0.0FHAG\n", - "2.0FHAG\n", - "875.0MB\n", - "175.0MB\n", - "0.0_1000.0FHAG\n", - "850.0MB\n", - "600.0MB\n", - "725.0MB\n", - "0.0_6000.0FHAG\n", - "975.0MB\n", - "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", - "650.0MB\n", - "525.0MB\n", - "300.0MB\n", - "90.0_120.0BL\n", - "1000.0FHAG\n", - "775.0MB\n", - "340.0_350.0K\n", - "290.0_300.0K\n", - "700.0_600.0MB\n", - "700.0_300.0MB\n", - "320.0Ke\n", - "800.0_750.0MB\n", - "60.0TILT\n", - "5.3TILT\n", - "1000.0_900.0MB\n", - "340.0K\n", - "5500.0_6000.0FHAG\n", - "255.0K\n", - "255.0_265.0K\n", - "3000.0_6000.0FHAG\n", - "25.0TILT\n", - "2000.0FHAG\n", - "0.0_500.0FHAG\n", - "1000.0_850.0MB\n", - "850.0_250.0MB\n", - "280.0_290.0Ke\n", - "1524.0FHAG\n", - "320.0_330.0K\n", - "0.0TILT\n", - "310.0_320.0Ke\n", - "310.0Ke\n", - "330.0K\n", - "900.0_800.0MB\n", - "550.0_500.0MB\n", - "2.4TILT\n", - "50.0TILT\n", - "3500.0FHAG\n", - "35.0TILT\n", - "12.0TILT\n", - "300.0_310.0K\n", - "3000.0_12000.0FHAG\n", - "0.9TILT\n", - "320.0K\n", - "400.0_350.0MB\n", - "500.0FHAG\n", - "750.0_700.0MB\n", - "1000.0_400.0MB\n", - "345.0K\n", - "250.0_260.0K\n", - "300.0Ke\n", - "290.0Ke\n", - "950.0_900.0MB\n", - "4572.0FHAG\n", - "275.0_285.0Ke\n", - "335.0Ke\n", - "295.0_305.0Ke\n", - "275.0_285.0K\n", - "600.0_550.0MB\n", - "310.0K\n", - "9000.0FHAG\n", - "335.0K\n", - "1000.0_7000.0FHAG\n", - "700.0_500.0MB\n", - "9144.0FHAG\n", - "325.0_335.0K\n", - "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", - "0.0_4000.0FHAG\n", - "5000.0_5500.0FHAG\n", - "300.0_250.0MB\n", - "1.5TILT\n", - "335.0_345.0K\n", - "315.0K\n", - "3.4TILT\n", - "2500.0FHAG\n", - "10000.0FHAG\n", - "0.0_2000.0FHAG\n", - "7000.0FHAG\n", - "5000.0FHAG\n", - "330.0Ke\n", - "500.0_400.0MB\n", - "1000.0_1500.0FHAG\n", - "305.0K\n", - "285.0_295.0Ke\n", - "14.0TILT\n", - "3000.0_3500.0FHAG\n", - "325.0_335.0Ke\n", - "2000.0_5000.0FHAG\n", - "7620.0FHAG\n", - "850.0_800.0MB\n", - "6096.0FHAG\n", - "6000.0_7000.0FHAG\n", - "2000.0_7000.0FHAG\n", - "9000.0_10000.0FHAG\n", - "295.0Ke\n", - "305.0Ke\n", - "265.0_275.0K\n", - "7000.0_8000.0FHAG\n", - "3000.0_8000.0FHAG\n", - "700.0_650.0MB\n", - "1000.0_6000.0FHAG\n", - "0.5TILT\n", - "450.0_400.0MB\n", - "1.8TILT\n", - "330.0_340.0K\n", - "800.0_700.0MB\n", - "850.0_300.0MB\n", - "6.0TILT\n", - "900.0_850.0MB\n", - "3657.6FHAG\n", - "0.0_5000.0FHAG\n", - "320.0_330.0Ke\n", - "8.7TILT\n", - "650.0_600.0MB\n", - "600.0_400.0MB\n", - "55.0TILT\n", - "270.0_280.0Ke\n", - "30.0TILT\n", - "310.0_320.0K\n", - "1500.0FHAG\n", - "1000.0_950.0MB\n", - "5500.0FHAG\n", - "250.0_200.0MB\n", - "500.0_1000.0FHAG\n", - "400.0_300.0MB\n", - "500.0_100.0MB\n", - "1000.0_3000.0FHAG\n", - "8000.0FHAG\n", - "285.0Ke\n", - "290.0K\n", - "305.0_315.0K\n", - "285.0_295.0K\n", - "0.0_2500.0FHAG\n", - "925.0_850.0MB\n", - "275.0Ke\n", - "1500.0_2000.0FHAG\n", - "300.0_200.0MB\n", - "260.0_270.0K\n", - "2743.2FHAG\n", - "3000.0FHAG\n", - "315.0_325.0Ke\n", - "600.0_500.0MB\n", - "16.7TILT\n", - "280.0K\n", - "500.0_250.0MB\n", - "40.0TILT\n", - "3048.0FHAG\n", - "400.0_200.0MB\n", - "300.0_310.0Ke\n", - "270.0_280.0K\n", - "1000.0_700.0MB\n", - "45.0TILT\n", - "850.0_500.0MB\n", - "2500.0_3000.0FHAG\n", - "609.6FHAG\n", - "0.0_8000.0FHAG\n", - "295.0K\n", - "4.3TILT\n", - "295.0_305.0K\n", - "330.0_340.0Ke\n", - "270.0K\n", - "4000.0_4500.0FHAG\n", - "280.0_290.0K\n", - "925.0_700.0MB\n", - "0.0_1500.0FHAG\n", - "260.0K\n", - "10.0TILT\n", - "3500.0_4000.0FHAG\n", - "325.0Ke\n", - "285.0K\n", - "290.0_300.0Ke\n", - "7.5TILT\n", - "1828.8FHAG\n", - "280.0Ke\n", - "500.0_450.0MB\n", - "305.0_315.0Ke\n", - "250.0K\n", - "4500.0FHAG\n", - "1250.0FHAG\n", - "0.0_10000.0FHAG\n", - "4500.0_5000.0FHAG\n", - "250.0_350.0K\n", - "270.0Ke\n", - "275.0K\n", - "315.0Ke\n", - "500.0_300.0MB\n", - "350.0_300.0MB\n", - "750.0FHAG\n", - "19.5TILT\n", - "2000.0_2500.0FHAG\n", - "850.0_700.0MB\n", - "350.0K\n", - "265.0K\n", - "6000.0FHAG\n", - "8000.0_9000.0FHAG\n", - "700.0_300.0LYRMB\n", - "850.0_700.0LYRMB\n" - ] - } - ], - "source": [ - "request.setParameters(\"T\")\n", - "availableLevels = DataAccessLayer.getAvailableLevels(request)\n", - "for lvl in availableLevels:\n", - " print(lvl)" - ] - }, - { - "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" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [], - "source": [ - "request.setLevels(\"2.0FHAG\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## DataAccessLayer.getAvailableTimes()\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", - "* **getForecastRun(cycle, times)** will return a DataTime array for a single forecast cycle." - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ]" + " 'navgem0p5']" ] }, "execution_count": 6, @@ -819,49 +267,314 @@ } ], "source": [ - "cycles = DataAccessLayer.getAvailableTimes(request, True)\n", - "times = DataAccessLayer.getAvailableTimes(request)\n", - "fcstRun = DataAccessLayer.getForecastRun(cycles[-1], times)\n", - "list(fcstRun)" + "# Grid Locations\n", + "grid_locations = DataAccessLayer.getAvailableLocationNames(grid_request)\n", + "grid_locations.sort()\n", + "list(grid_locations)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "## DataAccessLayer.getGridData()\n", + "Top\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": "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": 7, + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['T']" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# 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": [ + "Top\n", + "\n", + "---" + ] + }, + { + "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": [ + "
\n", + "Warning: 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", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": 21, "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" + "0.0SFC\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", + "# 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)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "Note: 0.0SFC is the Surface level\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [], + "source": [ + "# We'll set the level to surface level\n", + "grid_request.setLevels(\"0.0SFC\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Top\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", + "* **getForecastRun(cycle, times)** will return a DataTime array for a single forecast cycle." + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "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" + ] + } + ], + "source": [ + "# 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": [ + "Top\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": [ + "
\n", + "Note: We have more, detailed notebooks about how analyze and visualize the data once you have what you want.\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Time : 2021-06-01 12:00:00 - 820800 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", + "* [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)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Top\n", + "\n", + "---" ] } ], @@ -888,15 +601,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 }