Skip to content

Commit

Permalink
changes made to api and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
tpt5cu committed Aug 19, 2020
1 parent 3f58b6a commit 10e70d1
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 63 deletions.
12 changes: 9 additions & 3 deletions NDFD_Api.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#python3
"""API for fetching NDFD data via their rest service. Written in python 3. In development.
Right now subGrid and getDataZipcode work well.
API Reference: https://graphical.weather.gov/xml/rest.php#degrib
API Reference: https://graphical.weather.gov/xml/rest.php#what
Author: Tuomas Talvitie
github: tpt5cu
email: tpt5cu@virginia.edu
Year: 2020
"""
import sys
Expand Down Expand Up @@ -185,7 +187,7 @@ def getDataZipcode(zipcodes, product, begin, end, optional_params=['wspd', 'wdir
"""

def subGrid(centerPointLat, centerPointLon, distanceLat, distanceLon, resolutionSquare, product, begin, end, Unit, optional_params):
def subGrid(centerPointLat, centerPointLon, distanceLat, distanceLon, resolutionSquare, product='time-series', begin=str(datetime.now().isoformat()), end=str((datetime.now()+timedelta(days=+1)).isoformat()), Unit='m', optional_params=['wspd', 'wdir']):
#Split into 3 dictionaries, each are encoded in a different manner
params = {
'centerPointLat':centerPointLat,
Expand Down Expand Up @@ -343,6 +345,10 @@ def run_request(q):
raise ApiError(resp.text, resp.status_code)
return resp





#test each API call
def run_tests(_tests):
for key, val in _tests.items():
Expand Down Expand Up @@ -377,7 +383,7 @@ def getSubGridData(centerLat, centerLon, distanceLat, distanceLon, resolutionSqu


if __name__ == '__main__':
run_tests(_tests)
# run_tests(_tests)



Expand Down
150 changes: 90 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,68 +1,98 @@
# pyNDFD-fetcher

This repository contains a repo with APIs for the National Digital Forecast Database Service. More info on the NDFD [HERE](https://www.weather.gov/mdl/ndfd_home)



## API calls

API Reference [HERE](https://graphical.weather.gov/xml/rest.php#use_it)

NDFD_Api.py contains many API calls for different NDFD data stores.

For example

- Single Point Unsummarized Data: Returns DWML-encoded NDFD data for a point
- Multiple Point Unsummarized Data: Returns DWML-encoded NDFD data for a list of points
- A List of NDFD Points for a Subgrid
- Data for subgrid defined by center point
- NDFD data for a line
- NDFD data for a specific zip code


More information on specific NDFD services can be found at https://graphical.weather.gov/xml/rest.php#use_it




Most API calls require a location in the form of a latitude and longitude, a start and end time, and which weather parameters you want predictions for.

The returned data format is in an xml. The NDFD_Api.py contains several xml parsers, but the `_generalParseXml` is a general parser for the xml format.



## Weather parameters

The API can return data for specific weather parameters. Below is a list of them.

List of possible elements


https://graphical.weather.gov/xml/docs/elementInputNames.php

Maximum Temperature maxt
Minimum Temperature mint
3 Hourly Temperature temp
Dewpoint Temperature dew
Apparent Temperature appt
12 Hour Probability of Precipitation pop12
Liquid Precipitation Amount qpf
Snowfall Amount snow
Cloud Cover Amount sky
Relative Humidity rh
Wind Speed wspd
Wind Direction wdir
Weather wx
Weather Icons icons
Wave Height waveh
Probabilistic Tropical Cyclone Wind Speed >34 Knots (Incremental) incw34
Probabilistic Tropical Cyclone Wind Speed >50 Knots (Incremental) incw50
Probabilistic Tropical Cyclone Wind Speed >64 Knots (Incremental) incw64
Probabilistic Tropical Cyclone Wind Speed >34 Knots (Cumulative) cumw34
Probabilistic Tropical Cyclone Wind Speed >50 Knots (Cumulative) cumw50
Probabilistic Tropical Cyclone Wind Speed >64 Knots (Cumulative) cumw64
Wind Gust wgust
Fire Weather from Wind and Relative Humidity critfireo
Fire Weather from Dry Thunderstorms dryfireo
Convective Hazard Outlook conhazo
Probability of Tornadoes ptornado
Probability of Hail phail
Probability of Damaging Thunderstorm Winds ptstmwinds
Probability of Extreme Tornadoes pxtornado
Probability of Extreme Hail pxhail
Probability of Extreme Thunderstorm Winds pxtstmwinds
Probability of Severe Thunderstorms ptotsvrtstm
Probability of Extreme Severe Thunderstorms pxtotsvrtstm
Probability of 8- To 14-Day Average Temperature Above Normal tmpabv14d
Probability of 8- To 14-Day Average Temperature Below Normal tmpblw14d
Probability of One-Month Average Temperature Above Normal tmpabv30d
Probability of One-Month Average Temperature Below Normal tmpblw30d
Probability of Three-Month Average Temperature Above Normal tmpabv90d
Probability of Three-Month Average Temperature Below Normal tmpblw90d
Probability of 8- To 14-Day Total Precipitation Above Median prcpabv14d
Probability of 8- To 14-Day Total Precipitation Below Median prcpblw14d
Probability of One-Month Total Precipitation Above Median prcpabv30d
Probability of One-Month Total Precipitation Below Median prcpblw30d
Probability of Three-Month Total Precipitation Above Median prcpabv90d
Probability of Three-Month Total Precipitation Below Median prcpblw90d
Real-time Mesoscale Analysis Precipitation precipa_r
Real-time Mesoscale Analysis GOES Effective Cloud Amount sky_r
Real-time Mesoscale Analysis Dewpoint Temperature td_r
Real-time Mesoscale Analysis Temperature temp_r
Real-time Mesoscale Analysis Wind Direction wdir_r
Real-time Mesoscale Analysis Wind Speed wspd_r
Watches, Warnings, and Advisories wwa
Ice Accumulation iceaccum
Maximum Relative Humidity maxrh
Minimum Relative Humidity minrh




**Work in progress**
- Maximum Temperature: maxt
- Minimum Temperature: mint
- 3 Hourly Temperature: temp
- Dewpoint Temperature: dew
- Apparent Temperature: appt
- 12 Hour Probability of Precipitation: pop12
- Liquid Precipitation Amount: qpf
- Snowfall Amount: snow
- Cloud Cover Amount: sky
- Relative Humidity: rh
- Wind Speed: wspd
- Wind Direction: wdir
- Weather: wx
- Weather Icons: icons
- Wave Height: waveh
- Probabilistic Tropical Cyclone Wind Speed >34 Knots (Incremental): incw34
- Probabilistic Tropical Cyclone Wind Speed >50 Knots (Incremental): incw50
- Probabilistic Tropical Cyclone Wind Speed >64 Knots (Incremental): incw64
- Probabilistic Tropical Cyclone Wind Speed >34 Knots (Cumulative): cumw34
- Probabilistic Tropical Cyclone Wind Speed >50 Knots (Cumulative): cumw50
- Probabilistic Tropical Cyclone Wind Speed >64 Knots (Cumulative): cumw64
- Wind Gust: wgust
- Fire Weather from Wind and Relative Humidity: critfireo
- Fire Weather from Dry Thunderstorms: dryfireo
- Convective Hazard Outlook: conhazo
- Probability of Tornadoes: ptornado
- Probability of Hail: phail
- Probability of Damaging Thunderstorm Winds: ptstmwinds
- Probability of Extreme Tornadoes: pxtornado
- Probability of Extreme Hail: pxhail
- Probability of Extreme Thunderstorm Winds: pxtstmwinds
- Probability of Severe Thunderstorms: ptotsvrtstm
- Probability of Extreme Severe Thunderstorms: pxtotsvrtstm
- Probability of 8- To 14-Day Average Temperature Above Normal: tmpabv14d
- Probability of 8- To 14-Day Average Temperature Below Normal: tmpblw14d
- Probability of One-Month Average Temperature Above Normal: tmpabv30d
- Probability of One-Month Average Temperature Below Normal: tmpblw30d
- Probability of Three-Month Average Temperature Above Normal: tmpabv90d
- Probability of Three-Month Average Temperature Below Normal: tmpblw90d
- Probability of 8- To 14-Day Total Precipitation Above Median: prcpabv14d
- Probability of 8- To 14-Day Total Precipitation Below Median: prcpblw14d
- Probability of One-Month Total Precipitation Above Median: prcpabv30d
- Probability of One-Month Total Precipitation Below Median: prcpblw30d
- Probability of Three-Month Total Precipitation Above Median: prcpabv90d
- Probability of Three-Month Total Precipitation Below Median: prcpblw90d
- Real-time Mesoscale Analysis Precipitation: precipa_r
- Real-time Mesoscale Analysis GOES Effective Cloud Amount: sky_r
- Real-time Mesoscale Analysis Dewpoint Temperature: td_r
- Real-time Mesoscale Analysis Temperature: temp_r
- Real-time Mesoscale Analysis Wind Direction: wdir_r
- Real-time Mesoscale Analysis Wind Speed: wspd_r
- Watches, Warnings, and Advisories: wwa
- Ice Accumulation: iceaccum
- Maximum Relative Humidity: maxrh
- Minimum Relative Humidity: minrh

20 changes: 20 additions & 0 deletions pyNDFD_test_platform.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,26 @@
"print(data['dwml'])"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2020-08-18T17:50:16.277146 2020-08-19T17:50:16.277205\n"
]
}
],
"source": [
"from datetime import datetime, timedelta\n",
"start = str(datetime.now().isoformat())\n",
"end = str((datetime.now()+timedelta(days=1)).isoformat())\n",
"print(start, end)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down

0 comments on commit 10e70d1

Please sign in to comment.