<jupyter_start><jupyter_text>NOAA GFS on AWS * [OpenData Registry](https://registry.opendata.aws/noaa-gfs-pds/) * [Browse datafiles](http://awsopendata.s3-website-us-west-2.amazonaws.com/noaa-gfs/)<jupyter_code># imports and setup

from matplotlib import pyplot
from podpac.coordinates import Coordinates, clinspace, crange
from podpac.datalib.gfs import GFSSource, GFS, GFSLatest

import datetime
now = datetime.datetime.now()
yesterday = now - datetime.timedelta(1)
tomorrow = now + datetime.timedelta(1)

# The data files are removed after a few weeks. Normally that won't matter
# because you would probably use GFSLatest. In order to demo GFSSource and GFS,
# let's use yesterday 12:00 as the base date.
date = yesterday.strftime('%Y%m%d')
hour = '1200'<jupyter_output><empty_output><jupyter_text>GFSSourceLoad and plot a forecast for a particular parameter and level. This node loads data from one S3 file given a parameter, level, base date, and forecast time.<jupyter_code># SOIM forecast from 2018-12-06 12:00 for +3 hours (2018-12-06 15:00)
gfs_soim = GFSSource(parameter='SOIM', level='0-10 m DPTH', date=date, hour=hour, forecast='003')
o = gfs_soim.eval(gfs_soim.coordinates)
pyplot.figure(); pyplot.suptitle('Soil Moisture 0-10m, +3 hours')
o.plot()

# SOIM forecast from 2018-12-06 12:00 for +3 hours (2018-12-06 15:00)
gfs_soim = GFSSource(parameter='SOIM', level='10-40 m DPTH', date=date, hour=hour, forecast='384')
o = gfs_soim.eval(gfs_soim.coordinates)
pyplot.figure(); pyplot.suptitle('Soil Moisture 10-40m, +3 hours')
o.plot()
pass
print(gfs_soim.json_pretty)
# TOZO forecast from 2018-12-06 12:00 for +3 hours (2018-12-22 15:00)
gfs_tozo = GFSSource(parameter='TOZO', level='0 - NONE', date=date, hour=hour, forecast='003')
o = gfs_tozo.eval(gfs_tozo.coordinates)
pyplot.figure(); pyplot.suptitle('Total Ozone, +3 hours')
o.plot()

# TOZO forecast from 2018-12-06 12:00 for +384 hours (2018-12-22 12:00)
gfs_tozo= GFSSource(parameter='TOZO', level='0 - NONE', date=date, hour=hour, forecast='384')
o = gfs_tozo.eval(gfs_tozo.coordinates)
pyplot.figure(); pyplot.suptitle('Total Ozone, +16 days')
o.plot()
pass<jupyter_output>INFO:podpac.core.data.file_source:Loading AWS resource: s3://noaa-gfs-pds/TOZO/0 - NONE/20200712/1200/003
INFO:podpac.core.data.file_source:Loading AWS resource: s3://noaa-gfs-pds/TOZO/0 - NONE/20200712/1200/384<jupyter_text>GFSThe `GFS` node aggregates the `GFSSource` forecast nodes given a parameter, level, and base date. It interpolates forecast time, so you can get data for any time in the forecast range.*Not yet complete*<jupyter_code># we'll re-use the same node with different coordinates in the following examples
gfs_soim = GFS(parameter='SOIM', level='0-10 m DPTH', date=date, hour=hour)

# get the global forecast for this time tomorrow at full resolution
c = Coordinates(
    [gfs_soim.coordinates['lat'], gfs_soim.coordinates['lon'], tomorrow],
    dims=['lat', 'lon', 'time'])

o = gfs_soim.eval(c)
pyplot.figure(); pyplot.suptitle('Soil Moisture 0-10m, tomorrow')
o.plot()

# get the regional forecast for this time tomorrow over at downsampled resolution
c = Coordinates([
    clinspace(-90,  90, 100), clinspace(0, 360, 200), tomorrow],
    dims=['lat', 'lon', 'time'])

o = gfs_soim.eval(c)
pyplot.figure(); pyplot.suptitle('Soil Moisture 0-10m, tomorrow (downsampled)')
o.plot()
pass<jupyter_output>INFO:podpac.core.data.file_source:Loading AWS resource: s3://noaa-gfs-pds/SOIM/0-10 m DPTH/20200712/1200/003
INFO:podpac.core.data.file_source:Loading AWS resource: s3://noaa-gfs-pds/SOIM/0-10 m DPTH/20200712/1200/042
INFO:podpac.core.data.file_source:Loading AWS resource: s3://noaa-gfs-pds/SOIM/0-10 m DPTH/20200712/1200/054
INFO:numexpr.utils:NumExpr defaulting to 8 threads.<jupyter_text>Time-seriesThe `GFS` node can also be used to plot the forecast for a particular location over time.<jupyter_code># this is the same node as above
gfs_soim = GFS(parameter='SOIM', level='0-10 m DPTH', date=date, hour=hour)

# get the forecast at lat=42, lon=275 every hour for the next 6 hours
start = now
stop = now + datetime.timedelta(hours=6)
c = Coordinates([42, 282, crange(start, stop, '1,h')], dims=['lat', 'lon', 'time'])
o = gfs_soim.eval(c)
print(o)
o.plot()<jupyter_output><empty_output><jupyter_text>GFSLatestConvenience wrapper to get the most recently available `GFS` node. Just supply the parameter and level, and evaluate at any time up to 16 days from now.*Not yet complete*<jupyter_code># get the latest forecast at lat=42, lon=275 at 1 hour resolution

gfs_soim = GFSLatest(parameter='SOIM', level='0-10 m DPTH')
start = now + datetime.timedelta(hours=3)
stop = now + datetime.timedelta(hours=9)
c = Coordinates([42, 282, crange(start, stop, '1,h')], dims=['lat', 'lon', 'time'])

o = gfs_soim.eval(c)
print(o)
o.plot()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13803807947019867, 'fraction_numerical': 0.06167218543046358, 'mean_word_length': 5.6570247933884295, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '87747', 'license': 'Apache-2.0', 'n_tokens_mistral': 1993, 'n_tokens_neox': 1779, 'n_words': 476, 'path': 'notebooks/5-datalib/gfs.ipynb', 'repo_name': 'creare-com/podpac_examples', 'size': '4832'}