#!/usr/bin/env python # coding: utf-8 # # Read NWM Forecast "Best Time Series" # Here we use Fsspec ReferenceFileSystem to read data from 300 NWM Forecast netcdf files on AWS Public Dataset as a single virtual dataset. We used tau=0 for each forecast in the past + the latest forecast to construct the best time series virtual dataset. The only new file we created was the JSON file that points to the original NetCDF files. We read that JSON with the Zarr library. # In[1]: import fsspec import xarray as xr import json import intake import hvplot.xarray # In[2]: from dask.distributed import Client # In[3]: client = Client() # In[4]: client # #### Load the consolidated JSON for the last 300 time steps using an Intake Catalog # In[5]: get_ipython().run_cell_magic('time', '', 'cat = intake.open_catalog(\'s3://esip-qhub/usgs/nwm_intake.yml\', \n storage_options={"requester_pays": True})\n') # In[6]: list(cat) # In[7]: ds = cat['nwm-forecast'].to_dask() ds.streamflow # #### Find the site with the largest streamflow: # In[8]: get_ipython().run_cell_magic('time', '', "imax = ds['streamflow'].sel(time='2021-07-22 00:00:00', method='nearest').argmax().values\n") # #### Plot the "best time series" from that location: # In[9]: get_ipython().run_cell_magic('time', '', "ds.streamflow[:,imax].hvplot(x='time', grid=True)\n") # #### What does this magical intake catalog look like? # In[10]: print(cat.text) # In[11]: cat['nwm-forecast'] # In[ ]: