These examples Python library to fetch and process the National Water Model (NWM) NetCDF datasets.
If you have any suggestion to improve the current function of the NWM python library, please create a github issue to connect with Tian here. If you have any suggestion to improve the Notebooks used to customize access to NWM data, please create a github issue to connect with Christina here.
The Story Map was developed for Hurricane Harvey to show usable National Water Model results and provides access to operational forecasts (learn more about this resource on HydroShare.
Here is a National Water Model User Story with narrative description of how and why to use the National Water Model, provided by ESRI Water.
The U.S. Climate Resilence Toolkit uses the National Water Model to assess vulnerability and risk and provides a helpful orientation to the model features.
National Water Model interactive Map is provided by the Office of Water Prediction (OWP) National Water Center provides water information products from version 2.0 of the National Water Model (NWM). Information about NWM products available through the OWP website can be found in this Product Description Document. Advisory: NWM products do not yet incorporate anthropogenic influence and should be used with some caution. The NWM is currently undergoing extensive validation and verification to identify where scientific updates to the model can make the most improvement. The next version of the NWM will be released in the late spring 2020 time frame. Click here for more information about the NWM.
WRF-Hydro HydroInspector is a state-of-the-art Web Mapping Service (WMS) that allows users to manipulate and interact with a host of hydrologic observation and hydrologic model output data. WRF-Hydro is the model used to generate National Water Model simulations.
Intelligent Earth Collective Notebooks are designed for developers and instructors of interactive curriculum for research and education using Python, Jupyter, and HydroShare.
Download subset maps and time series using the National Water Model Data Viewer on HydroShare App.
Go to HydroShare.org and login at www.hydroshare.org
Do one time: Go to Collaborate, Find the CUAHSI Compute Group, Ask to Join.
Next time: Go directly to https://jupyterhub.cuahsi.org
New users: Get familiar with JupyterHub platform with [Juptyer Notebook new user instructions] and JuptyerHub Documentation
-
Launch CUAHSI JupyterHub (or go to jupyterhub.cuahsi.org) and choose the WaterHackWeek 2020 environment profile. This environment will contain all the libraries that we need.
-
In the Jupyterlab view, Create a new folder called "Github"` (this creates a folder in /home/jovyan/data)
-
Open an new "Terminal" session and clone the github repository by running the command:
The terminal opens in /home/jovyan/
> cd data
Make a new directory specific to your Github repositories on this server.
> mkdir Github
Clone the github repository by running the command:
> git clone https://github.com/christinab/nwm.git
Notebook User Instructions for interactive compute on CSDMS JupyterHub
Work in Progress.
Notebook User Instructions for interactive compute on CyberGIS for Water
Work in Progress.
$ pip install nwm
You can launch binder to test and run the code below.
import matplotlib.pyplot as plt
from nwm import NwmHs
# get data from National water model HydroShare App
nwm_data = NwmHs()
dataset = nwm_data.get_data(archive='harvey', config='short_range', geom='channel_rt', variable='streamflow',
comid=[5781915], init_time=0, start_date='2017-08-23')
# show metadata
dataset.attrs
# plot data
plt.figure(figsize=(9,5))
dataset.plot()
plt.xlabel('Year 2017')
plt.ylabel('{} ({})'.format(dataset.variable_name,dataset.variable_unit))
plt.title('Short range streamflow forecast for Channel 5781915 during Harvey Hurricane Event')
import matplotlib.pyplot as plt
import numpy as np
import cftime
from nwm import BmiNwmHs
# initiate a data component
data_comp = BmiNwmHs()
data_comp.initialize('config_file.yaml')
# get variable info
var_name = data_comp.get_output_var_names()[0]
var_unit = data_comp.get_var_units(var_name)
print(' variable_name: {}\n var_unit: {}\n'.format(var_name, var_unit))
# get time info
start_time = data_comp.get_start_time()
end_time = data_comp.get_end_time()
time_step = data_comp.get_time_step()
time_unit = data_comp.get_time_units()
time_steps = int((end_time - start_time)/time_step) + 1
print(' start_time:{}\n end_time:{}\n time_step:{}\n time_unit:{}\n time_steps:{}\n'.format(start_time, end_time, time_step, time_unit, time_steps))
# initiate numpy arrays to store data
stream_value = np.empty(1)
stream_array = np.empty(time_steps)
cftime_array = np.empty(time_steps)
for i in range(0, time_steps):
data_comp.get_value(var_name, stream_value)
stream_array[i] = stream_value
cftime_array[i] = data_comp.get_current_time()
data_comp.update()
time_array = cftime.num2date(cftime_array, time_unit, only_use_cftime_datetimes=False, only_use_python_datetimes=True)
# plot data
plt.figure(figsize=(9,5))
plt.plot(time_array, stream_array)
plt.xlabel('Year 2017')
plt.ylabel('{} ({})'.format(var_name, var_unit))
plt.title('Short range streamflow forecast for Channel 5781915 during Harvey Hurricane Event')
We agree that the resulting products from work would be issued under a Creative Commons License Attribution-NonCommercial 4.0 International.
We agreed to add language to any contract (below) that provides for me a non-exclusive, irrevocable, global, royalty-free license to the work produced, and that all publicly distributed copies of work prepared under this contract shall indicate the names of the author(s) [based on these community instructions].
The CONTRACTOR shall have a non-exclusive, irrevocable, global, royalty-free license to translate, reproduce and publicly distribute articles, reports, books, Powerpoint slides, Jupyter notebooks, videos, webcasts and any such material arising under this Contract for non-commercial purposes.
The CONTRACTOR agrees that payment listed purchases all print and electronic rights including electronic reproduction, transmission, display or distribution of work prepared under this Contract. All publicly distributed copies of a copyrighted work prepared under this Contract shall indicate the name(s) of the author(s) of the work.
# REFERENCES
Arctur, D., E. Boghici (2018). Hurricane Harvey 2017 Story Map, HydroShare, https://doi.org/10.4211/hs.8161a96a08474d12bba219852409be61