<jupyter_start><jupyter_text>Explore the National Water Model Reanalysis v2.1 Explore the NWM Reanalysis (1979-2020) NetCDF files (all 367,439 of them) on AWS as a single xarray dataset! The only new file we created was a JSON file that points to data chunks in the original NetCDF files that is then read with the [fsspec](https://filesystem-spec.readthedocs.io/en/latest/) and [zarr](https://zarr.readthedocs.io/en/stable/) packages. See this [blog post](https://medium.com/pangeo/cloud-performant-netcdf4-hdf5-with-zarr-fsspec-and-intake-3d3a3e7cb935) for how this works. **Important note on performance**: The data in the original NetCDF files is chunked as the entire spatial domain and a single time step.  Thus reading a time series will be very slow -- to extract a time series at a single location for the entire time period will require reading and uncompressing 8TB of data!   But extraction of a few days or weeks of data will be relatively fast.<jupyter_code>import fsspec
import xarray as xr
import intake<jupyter_output><empty_output><jupyter_text>Use Intake to load the consolidated NWM datasetThe Intake catalog, the consolidated JSON file it accesses, and the NetCDF files the JSON file references are all on public S3 buckets that do not require an AWS account, so no credentials are required!<jupyter_code>cat = intake.open_catalog('./example_jsons/nwm_catalog.yml')
ds = cat['nwm-reanalysis'].to_dask()
ds.streamflow.nbytes/1e12 # How many terabytes is a single variable<jupyter_output><empty_output><jupyter_text>Read and plot streamflow for a specific time The local National Weather Service office in Houston observed all-time record daily rainfall accumulations on both August 26 and 27, measured at 14.4 in (370 mm) and 16.08 in (408 mm) respectively<jupyter_code>import hvplot.pandas
import geoviews as gv
from holoviews.operation.datashader import rasterize
import cartopy.crs as ccrs
import numpy as np
import pandas as pd
ds1 = ds.sel(time='2017-08-27 18:00:00', method='nearest')
var = 'streamflow'
df = ds1[var].to_pandas().to_frame()
date_title = pd.to_datetime(ds1.time.values).strftime('%Y-%m-%d %H:%M:%S')
date_title = f'{var}: {date_title}'
date_title
df = df.assign(latitude=ds.latitude)
df = df.assign(longitude=ds.longitude)
df.rename(columns={0: var}, inplace=True)
p = df.hvplot.points(x='longitude', y='latitude', geo=True,
                     c=var, colorbar=True, size=14, label=date_title)
g = rasterize(p, aggregator='mean', x_sampling=0.02, 
                y_sampling=0.02, width=500).opts(tools=['hover'], 
                aspect='equal', logz=True, cmap='viridis', clim=(1e-2, np.nan))
g * gv.tile_sources.OSM<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10070605722779635, 'fraction_numerical': 0.028985507246376812, 'mean_word_length': 5.063063063063063, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 3, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '323072', 'license': 'MIT', 'n_tokens_mistral': 928, 'n_tokens_neox': 861, 'n_words': 293, 'path': '03-nwm_hindcast_intake.ipynb', 'repo_name': 'lsterzinger/maptimedavis-pangeo', 'size': '2691'}