\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": [
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Imports\n",
"\n",
"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": [
"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": 2,
"metadata": {},
"outputs": [],
"source": [
"# Unidata's cloud EDEX instance is used in this example\n",
"edex_url = \"edex-beta.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": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['acars',\n",
" 'airep',\n",
" 'binlightning',\n",
" 'bufrmosAVN',\n",
" 'bufrmosETA',\n",
" 'bufrmosGFS',\n",
" 'bufrmosHPC',\n",
" 'bufrmosLAMP',\n",
" 'bufrmosMRF',\n",
" 'bufrua',\n",
" 'climate',\n",
" 'common_obs_spatial',\n",
" 'gfe',\n",
" 'gfeEditArea',\n",
" 'grid',\n",
" 'maps',\n",
" 'modelsounding',\n",
" 'obs',\n",
" 'pirep',\n",
" 'practicewarning',\n",
" 'profiler',\n",
" 'radar',\n",
" 'radar_spatial',\n",
" 'satellite',\n",
" 'sfcobs',\n",
" 'topo',\n",
" 'warning']"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dataTypes = DataAccessLayer.getSupportedDatatypes()\n",
"dataTypes.sort()\n",
"list(dataTypes)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Top\n",
"\n",
"---"
]
},
{
"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": 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": [
{
"data": {
"text/plain": [
"['AUTOSPE',\n",
" 'CMC',\n",
" 'ESTOFS',\n",
" 'ETSS',\n",
" 'FFG-ALR',\n",
" 'FFG-FWR',\n",
" 'FFG-KRF',\n",
" 'FFG-MSR',\n",
" 'FFG-ORN',\n",
" 'FFG-PTR',\n",
" 'FFG-RHA',\n",
" 'FFG-RSA',\n",
" 'FFG-STR',\n",
" 'FFG-TAR',\n",
" 'FFG-TIR',\n",
" 'FFG-TUA',\n",
" 'FNMOC-NCODA',\n",
" 'FNMOC-WW3',\n",
" 'GFS1p0',\n",
" 'GFS20',\n",
" 'HFR-EAST_6KM',\n",
" 'HFR-EAST_PR_6KM',\n",
" 'HFR-US_EAST_DELAWARE_1KM',\n",
" 'HFR-US_EAST_FLORIDA_2KM',\n",
" 'HFR-US_EAST_NORTH_2KM',\n",
" 'HFR-US_EAST_SOUTH_2KM',\n",
" 'HFR-US_EAST_VIRGINIA_1KM',\n",
" 'HFR-US_HAWAII_1KM',\n",
" 'HFR-US_HAWAII_2KM',\n",
" 'HFR-US_HAWAII_6KM',\n",
" 'HFR-US_WEST_500M',\n",
" 'HFR-US_WEST_CENCAL_2KM',\n",
" 'HFR-US_WEST_LOSANGELES_1KM',\n",
" 'HFR-US_WEST_LOSOSOS_1KM',\n",
" 'HFR-US_WEST_NORTH_2KM',\n",
" 'HFR-US_WEST_SANFRAN_1KM',\n",
" 'HFR-US_WEST_SOCAL_2KM',\n",
" 'HFR-US_WEST_WASHINGTON_1KM',\n",
" 'HFR-WEST_6KM',\n",
" 'HPCGuide',\n",
" 'HPCqpfNDFD',\n",
" 'HRRR',\n",
" 'LAMP2p5',\n",
" 'MRMS_0500',\n",
" 'MRMS_1000',\n",
" 'NAM12',\n",
" 'NAM40',\n",
" 'NOHRSC-SNOW',\n",
" 'RAP13',\n",
" 'RTMA',\n",
" 'RTOFS-Now-WestAtl',\n",
" 'RTOFS-Now-WestConus',\n",
" 'RTOFS-WestAtl',\n",
" 'RTOFS-WestConus',\n",
" 'SPCGuide',\n",
" 'SeaIce',\n",
" 'TPCWindProb',\n",
" 'URMA25',\n",
" 'navgem0p5']"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Grid Locations\n",
"grid_locations = DataAccessLayer.getAvailableLocationNames(grid_request)\n",
"grid_locations.sort()\n",
"list(grid_locations)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Top\n",
"\n",
"---"
]
},
{
"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": 6,
"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",
" 'CFRZR3hr',\n",
" 'CFRZR6hr',\n",
" 'CICEP',\n",
" 'CICEP3hr',\n",
" 'CICEP6hr',\n",
" 'CIn',\n",
" 'CP',\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",
" '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",
" 'EMSP',\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",
" 'FnVecs',\n",
" 'FsVecs',\n",
" 'Fzra1',\n",
" 'Fzra2',\n",
" 'GH',\n",
" 'GHxSM',\n",
" 'GHxSM2',\n",
" 'GVV',\n",
" 'HI',\n",
" 'HI1',\n",
" 'HI3',\n",
" 'HI4',\n",
" 'HIdx',\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",
" 'MSFDi',\n",
" 'MSFi',\n",
" 'MSFmi',\n",
" 'MSG',\n",
" 'MTV',\n",
" 'Mix1',\n",
" 'Mix2',\n",
" 'Mmag',\n",
" 'MnT3hr',\n",
" 'MnT6hr',\n",
" 'MpV',\n",
" 'MxT3hr',\n",
" 'MxT6hr',\n",
" 'NBE',\n",
" 'NST',\n",
" 'NST1',\n",
" 'NST2',\n",
" 'P',\n",
" 'P3hr',\n",
" 'P6hr',\n",
" 'PAdv',\n",
" 'PBE',\n",
" 'PEC',\n",
" 'PFrnt',\n",
" 'PGrd',\n",
" 'PGrd1',\n",
" 'PGrdM',\n",
" 'PIVA',\n",
" 'PTvA',\n",
" 'PTyp',\n",
" 'PW',\n",
" 'PW2',\n",
" 'PoT',\n",
" 'PoTA',\n",
" 'QPV1',\n",
" 'QPV2',\n",
" 'QPV3',\n",
" 'QPV4',\n",
" 'RH',\n",
" 'RH_001_bin',\n",
" 'RH_002_bin',\n",
" 'RM5',\n",
" 'RM6',\n",
" 'RMprop',\n",
" 'RMprop2',\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",
" '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",
" 'TP-GFS',\n",
" 'TP3hr',\n",
" 'TP6hr',\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",
" 'VAdv',\n",
" 'VAdvAdvection',\n",
" 'VGP',\n",
" 'VSS',\n",
" 'WCD',\n",
" 'WD',\n",
" 'WEASD',\n",
" 'Wind',\n",
" 'WndChl',\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",
" 'wDiv',\n",
" 'wSp',\n",
" 'wSp_001_bin',\n",
" 'wSp_002_bin',\n",
" 'wSp_003_bin',\n",
" 'wSp_004_bin',\n",
" 'zAGL']"
]
},
"execution_count": 6,
"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",
"