Skip to content

Instantly share code, notes, and snippets.

@rsignell-usgs
Created June 21, 2022 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rsignell-usgs/fb167783124bfeee49cf6a75c8546616 to your computer and use it in GitHub Desktop.
Save rsignell-usgs/fb167783124bfeee49cf6a75c8546616 to your computer and use it in GitHub Desktop.
02_nwm_benchmark_analysis.ipynb
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"id": "4e11273a-f755-46a7-994d-7bb4e5367e9e",
"metadata": {
"tags": []
},
"source": [
"#\n",
"# HyTEST hydrologic model benchmark assessment: standard metric analyses\n",
"**Last Update, May 2022**\n",
"\n",
"**Timothy Hodson and Rich Signell**\n",
"\n",
"## About\n",
"This notebook demonstrates a computational workflow for benchmarking daily streamflow simulated from the National Water Model Retrospective version 2.1, and is meant to provide an adaptable template for benchmarking other Earth-system models and datasets. \n",
"\n",
"The HyTEST benchmark workflow consists of three components:\n",
"1. a set of model predictions and observations, or evaluation data, to compare.\n",
"1. the spatiotemporal domain over which to compute benchmark results.\n",
"1. a set of statistical metrics with which to generate benchmark results. In this notebook, we focus on the standard statistical metric suite version 1.0, sometimes referred to as the traditional statistical metrics.\n",
"\n",
"The workflow loads the model predictions and observations, subsets the data to the specified domain of the benchmark, and finally calculates metrics for the given data over that given domain. Any benchmark result is fully reproducible, given a workflow notebook and the correct versions of each of these three components.\n",
"\n",
"In practice, the datasets may be too large to fit in memory or to transfer, so this notebook will demonstrate several open-source Python libraries for 'moving the computations to the data.' Some of these tools are relatively new, but they are quickly becoming standards within the Earth-science community.\n",
"\n",
"The notebook is organized into a series of helper functions that handle tasks like loading data, configuring compute resources, and computing metrics over a chunk of data. Once these are defined, the analysis can be run in a few lines of code. The output generated from this notebook can serve as the beginning step in a workflow notebook specified to visualizations."
]
},
{
"cell_type": "markdown",
"id": "a32021b3-9141-4acb-9256-b66cf9a08c0d",
"metadata": {},
"source": [
"## 0. Setup\n",
"### 0.0. Load libraries\n",
"Prior to beginning, ensure that following Python librariers are installed and loaded"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "efa7e186-83be-4dae-87d8-d469beb4a147",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/rsignell/miniconda3/envs/pangeo/lib/python3.9/site-packages/dask_jobqueue/core.py:20: FutureWarning: tmpfile is deprecated and will be removed in a future release. Please use dask.utils.tmpfile instead.\n",
" from distributed.utils import tmpfile\n"
]
}
],
"source": [
"from dask_jobqueue import SLURMCluster\n",
"from dask.distributed import Client, LocalCluster\n",
"import dask.bag as db\n",
"\n",
"import xarray as xr\n",
"import numpy as np\n",
"import pandas as pd\n",
"import intake\n",
"import dask\n",
"import os"
]
},
{
"cell_type": "markdown",
"id": "d1db8121-7e23-4b52-8694-4e9fa1a17478",
"metadata": {},
"source": [
"### 0.1. Configure cluster\n",
"The notebook shows example configurations that might be used for three different computing resources supported by USGS, including Denali, Tallgrass, and Cloud.\n",
"\n",
"First, select the computing resource on which to run your analysis. Options include:\n",
"1) denali\n",
"2) tallgrass\n",
"3) local\n",
"4) esip-qhub-gateway-v0.4"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "18bdcad1-d21d-4340-99ac-9d4ad032685c",
"metadata": {},
"outputs": [],
"source": [
"resource = 'tallgrass' #denali, tallgrass, local, esip-qhub-gateway-v0.4"
]
},
{
"cell_type": "markdown",
"id": "67bdb0cd-89ec-4f07-bf68-b60b8e231140",
"metadata": {},
"source": [
"How to configure the cluster will vary among these resources, so we've created a helper function to take care of that."
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "303173a5-4ee8-4b39-9949-1e3d48d89156",
"metadata": {},
"outputs": [],
"source": [
"project = os.environ['SLURM_JOB_ACCOUNT']"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "c9abd71d-312d-4c5f-b520-077c80862314",
"metadata": {},
"outputs": [],
"source": [
"def configure_cluster(resource):\n",
" ''' Helper function to configure cluster\n",
" '''\n",
" if resource == 'denali':\n",
" cluster = LocalCluster(threads_per_worker=1)\n",
" client = Client(cluster)\n",
" \n",
" elif resource == 'tallgrass':\n",
" project = os.environ['SLURM_JOB_ACCOUNT']\n",
" \n",
" cluster = SLURMCluster(processes=1,cores=1, \n",
" memory='10GB', interface='ib0',\n",
" project=project, walltime='01:00:00', \n",
" job_extra={'hint': 'multithread'})\n",
" cluster.scale(10)\n",
" client = Client(cluster)\n",
" \n",
" elif resource == 'local':\n",
" import warnings\n",
" warnings.warn(\"Running locally can result in costly data transfers!\\n\")\n",
" n_cores = os.cpu_count() # set to match your machine\n",
" cluster = LocalCluster(threads_per_worker=n_cores)\n",
" client = Client(cluster)\n",
" \n",
" elif resource in ['esip-qhub-gateway-v0.4']: \n",
" import sys\n",
" sys.path.append(os.path.join(os.environ['HOME'],'shared','users','lib'))\n",
" import ebdpy as ebd\n",
" ebd.set_credentials(profile='esip-qhub')\n",
"\n",
" aws_profile = 'esip-qhub'\n",
" aws_region = 'us-west-2'\n",
" endpoint = f's3.{aws_region}.amazonaws.com'\n",
" ebd.set_credentials(profile=aws_profile, region=aws_region, endpoint=endpoint)\n",
" worker_max = 30\n",
" client,cluster = ebd.start_dask_cluster(profile=aws_profile, worker_max=worker_max, \n",
" region=aws_region, use_existing_cluster=True,\n",
" adaptive_scaling=False, wait_for_cluster=False, \n",
" worker_profile='Medium Worker', propagate_env=True)\n",
" \n",
" return client, cluster"
]
},
{
"cell_type": "markdown",
"id": "8713623c-d507-4213-b534-5204bd9e56a9",
"metadata": {},
"source": [
"## 1. Define performance benchmark\n",
"A performance benchmark consists of three components: (1) a set of predictions and observations, (2) the domain over which to benchmark (3) a set of statistical metrics with which to produce benchmark results. The basic workflow is to load the predictions and observations, subset them to the domain of the benchmark, then calculate metrics on the data over that domain.\n",
"\n",
"### 1.0 Load data\n",
"Let's begin by introducing [Intake](https://github.com/intake/intake), which is a set of tools for loading and sharing data in data science projects. Data from this project are stored within an Intake catalog. We can inpsect that catalog with the following lines."
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "b7743279-a185-408f-81cf-0aedad65c085",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['conus404-40year-onprem', 'conus404-40year-cloud', 'conus404-40year-daily-cloud', 'nwis-streamflow-usgs-gages-onprem', 'nwis-streamflow-usgs-gages-cloud', 'nwm21-streamflow-usgs-gages-onprem', 'nwm21-streamflow-usgs-gages-cloud', 'nwm21-streamflow-cloud', 'nwm21-scores', 'lcmap-cloud', 'gridmet-kerchunk-esip', 'gridmet-kerchunk-esip-10x', 'gridmet-kerchunk-esip-100mb']\n"
]
}
],
"source": [
"url = 'https://raw.githubusercontent.com/USGS-python/hytest-catalogs/main/hytest_intake_catalog.yml'\n",
"cat = intake.open_catalog(url)\n",
"print(list(cat))"
]
},
{
"cell_type": "markdown",
"id": "956fd92a-1659-4192-b7b5-367a823f266e",
"metadata": {},
"source": [
"Above, you should see several or more data filenames of models, data hubs, and location descriptions.\n",
"\n",
"- Files ending in \"-onprem\" are data that are located on HPC resources. Files ending in \"-cloud\", pertain to data housed on cloud, and \"-esip\" pertain to data housed in qhub. \n",
"- Files with 'conus404' in the description pertain to the CONUS404 dataset. Uncalibrated, calibrated? DOI to cite?\n",
" - Files with 'nwm21' pertain to the National Water Model retrospective version 2.1, and may have a variable such as 'streamflow' to designate the simulated variable.\n",
"- Files with 'nwis' pertain to data from USGS National Water Inventory System (NWIS) which is observational streamflow data, parameter code '00060', stat_cd = \"00003\" (mean)\n",
"- Files with 'streamflow' pertain to the variable that is housed in that data file.\n",
"\n",
"Using the Intake catalog, we define another helper function that loads our data from the appropriate location depending on where the computation will be run."
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "32aaac3f-dd7b-4d8e-9a02-2f97efe00d60",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The history saving thread hit an unexpected error (OperationalError('disk I/O error')).History will not be written to the database.\n"
]
},
{
"data": {
"text/html": [
"<div><svg style=\"position: absolute; width: 0; height: 0; overflow: hidden\">\n",
"<defs>\n",
"<symbol id=\"icon-database\" viewBox=\"0 0 32 32\">\n",
"<path d=\"M16 0c-8.837 0-16 2.239-16 5v4c0 2.761 7.163 5 16 5s16-2.239 16-5v-4c0-2.761-7.163-5-16-5z\"></path>\n",
"<path d=\"M16 17c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
"<path d=\"M16 26c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
"</symbol>\n",
"<symbol id=\"icon-file-text2\" viewBox=\"0 0 32 32\">\n",
"<path d=\"M28.681 7.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-15.5c-1.378 0-2.5 1.121-2.5 2.5v27c0 1.378 1.122 2.5 2.5 2.5h23c1.378 0 2.5-1.122 2.5-2.5v-19.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 5.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-23c-0.271 0-0.5-0.229-0.5-0.5v-27c0-0.271 0.229-0.5 0.5-0.5 0 0 15.499-0 15.5 0v7c0 0.552 0.448 1 1 1h7v19.5z\"></path>\n",
"<path d=\"M23 26h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"<path d=\"M23 22h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"<path d=\"M23 18h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"</symbol>\n",
"</defs>\n",
"</svg>\n",
"<style>/* CSS stylesheet for displaying xarray objects in jupyterlab.\n",
" *\n",
" */\n",
"\n",
":root {\n",
" --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1));\n",
" --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54));\n",
" --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38));\n",
" --xr-border-color: var(--jp-border-color2, #e0e0e0);\n",
" --xr-disabled-color: var(--jp-layout-color3, #bdbdbd);\n",
" --xr-background-color: var(--jp-layout-color0, white);\n",
" --xr-background-color-row-even: var(--jp-layout-color1, white);\n",
" --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee);\n",
"}\n",
"\n",
"html[theme=dark],\n",
"body.vscode-dark {\n",
" --xr-font-color0: rgba(255, 255, 255, 1);\n",
" --xr-font-color2: rgba(255, 255, 255, 0.54);\n",
" --xr-font-color3: rgba(255, 255, 255, 0.38);\n",
" --xr-border-color: #1F1F1F;\n",
" --xr-disabled-color: #515151;\n",
" --xr-background-color: #111111;\n",
" --xr-background-color-row-even: #111111;\n",
" --xr-background-color-row-odd: #313131;\n",
"}\n",
"\n",
".xr-wrap {\n",
" display: block !important;\n",
" min-width: 300px;\n",
" max-width: 700px;\n",
"}\n",
"\n",
".xr-text-repr-fallback {\n",
" /* fallback to plain text repr when CSS is not injected (untrusted notebook) */\n",
" display: none;\n",
"}\n",
"\n",
".xr-header {\n",
" padding-top: 6px;\n",
" padding-bottom: 6px;\n",
" margin-bottom: 4px;\n",
" border-bottom: solid 1px var(--xr-border-color);\n",
"}\n",
"\n",
".xr-header > div,\n",
".xr-header > ul {\n",
" display: inline;\n",
" margin-top: 0;\n",
" margin-bottom: 0;\n",
"}\n",
"\n",
".xr-obj-type,\n",
".xr-array-name {\n",
" margin-left: 2px;\n",
" margin-right: 10px;\n",
"}\n",
"\n",
".xr-obj-type {\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-sections {\n",
" padding-left: 0 !important;\n",
" display: grid;\n",
" grid-template-columns: 150px auto auto 1fr 20px 20px;\n",
"}\n",
"\n",
".xr-section-item {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-section-item input {\n",
" display: none;\n",
"}\n",
"\n",
".xr-section-item input + label {\n",
" color: var(--xr-disabled-color);\n",
"}\n",
"\n",
".xr-section-item input:enabled + label {\n",
" cursor: pointer;\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-section-item input:enabled + label:hover {\n",
" color: var(--xr-font-color0);\n",
"}\n",
"\n",
".xr-section-summary {\n",
" grid-column: 1;\n",
" color: var(--xr-font-color2);\n",
" font-weight: 500;\n",
"}\n",
"\n",
".xr-section-summary > span {\n",
" display: inline-block;\n",
" padding-left: 0.5em;\n",
"}\n",
"\n",
".xr-section-summary-in:disabled + label {\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-section-summary-in + label:before {\n",
" display: inline-block;\n",
" content: '►';\n",
" font-size: 11px;\n",
" width: 15px;\n",
" text-align: center;\n",
"}\n",
"\n",
".xr-section-summary-in:disabled + label:before {\n",
" color: var(--xr-disabled-color);\n",
"}\n",
"\n",
".xr-section-summary-in:checked + label:before {\n",
" content: '▼';\n",
"}\n",
"\n",
".xr-section-summary-in:checked + label > span {\n",
" display: none;\n",
"}\n",
"\n",
".xr-section-summary,\n",
".xr-section-inline-details {\n",
" padding-top: 4px;\n",
" padding-bottom: 4px;\n",
"}\n",
"\n",
".xr-section-inline-details {\n",
" grid-column: 2 / -1;\n",
"}\n",
"\n",
".xr-section-details {\n",
" display: none;\n",
" grid-column: 1 / -1;\n",
" margin-bottom: 5px;\n",
"}\n",
"\n",
".xr-section-summary-in:checked ~ .xr-section-details {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-array-wrap {\n",
" grid-column: 1 / -1;\n",
" display: grid;\n",
" grid-template-columns: 20px auto;\n",
"}\n",
"\n",
".xr-array-wrap > label {\n",
" grid-column: 1;\n",
" vertical-align: top;\n",
"}\n",
"\n",
".xr-preview {\n",
" color: var(--xr-font-color3);\n",
"}\n",
"\n",
".xr-array-preview,\n",
".xr-array-data {\n",
" padding: 0 5px !important;\n",
" grid-column: 2;\n",
"}\n",
"\n",
".xr-array-data,\n",
".xr-array-in:checked ~ .xr-array-preview {\n",
" display: none;\n",
"}\n",
"\n",
".xr-array-in:checked ~ .xr-array-data,\n",
".xr-array-preview {\n",
" display: inline-block;\n",
"}\n",
"\n",
".xr-dim-list {\n",
" display: inline-block !important;\n",
" list-style: none;\n",
" padding: 0 !important;\n",
" margin: 0;\n",
"}\n",
"\n",
".xr-dim-list li {\n",
" display: inline-block;\n",
" padding: 0;\n",
" margin: 0;\n",
"}\n",
"\n",
".xr-dim-list:before {\n",
" content: '(';\n",
"}\n",
"\n",
".xr-dim-list:after {\n",
" content: ')';\n",
"}\n",
"\n",
".xr-dim-list li:not(:last-child):after {\n",
" content: ',';\n",
" padding-right: 5px;\n",
"}\n",
"\n",
".xr-has-index {\n",
" font-weight: bold;\n",
"}\n",
"\n",
".xr-var-list,\n",
".xr-var-item {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-var-item > div,\n",
".xr-var-item label,\n",
".xr-var-item > .xr-var-name span {\n",
" background-color: var(--xr-background-color-row-even);\n",
" margin-bottom: 0;\n",
"}\n",
"\n",
".xr-var-item > .xr-var-name:hover span {\n",
" padding-right: 5px;\n",
"}\n",
"\n",
".xr-var-list > li:nth-child(odd) > div,\n",
".xr-var-list > li:nth-child(odd) > label,\n",
".xr-var-list > li:nth-child(odd) > .xr-var-name span {\n",
" background-color: var(--xr-background-color-row-odd);\n",
"}\n",
"\n",
".xr-var-name {\n",
" grid-column: 1;\n",
"}\n",
"\n",
".xr-var-dims {\n",
" grid-column: 2;\n",
"}\n",
"\n",
".xr-var-dtype {\n",
" grid-column: 3;\n",
" text-align: right;\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-var-preview {\n",
" grid-column: 4;\n",
"}\n",
"\n",
".xr-var-name,\n",
".xr-var-dims,\n",
".xr-var-dtype,\n",
".xr-preview,\n",
".xr-attrs dt {\n",
" white-space: nowrap;\n",
" overflow: hidden;\n",
" text-overflow: ellipsis;\n",
" padding-right: 10px;\n",
"}\n",
"\n",
".xr-var-name:hover,\n",
".xr-var-dims:hover,\n",
".xr-var-dtype:hover,\n",
".xr-attrs dt:hover {\n",
" overflow: visible;\n",
" width: auto;\n",
" z-index: 1;\n",
"}\n",
"\n",
".xr-var-attrs,\n",
".xr-var-data {\n",
" display: none;\n",
" background-color: var(--xr-background-color) !important;\n",
" padding-bottom: 5px !important;\n",
"}\n",
"\n",
".xr-var-attrs-in:checked ~ .xr-var-attrs,\n",
".xr-var-data-in:checked ~ .xr-var-data {\n",
" display: block;\n",
"}\n",
"\n",
".xr-var-data > table {\n",
" float: right;\n",
"}\n",
"\n",
".xr-var-name span,\n",
".xr-var-data,\n",
".xr-attrs {\n",
" padding-left: 25px !important;\n",
"}\n",
"\n",
".xr-attrs,\n",
".xr-var-attrs,\n",
".xr-var-data {\n",
" grid-column: 1 / -1;\n",
"}\n",
"\n",
"dl.xr-attrs {\n",
" padding: 0;\n",
" margin: 0;\n",
" display: grid;\n",
" grid-template-columns: 125px auto;\n",
"}\n",
"\n",
".xr-attrs dt,\n",
".xr-attrs dd {\n",
" padding: 0;\n",
" margin: 0;\n",
" float: left;\n",
" padding-right: 10px;\n",
" width: auto;\n",
"}\n",
"\n",
".xr-attrs dt {\n",
" font-weight: normal;\n",
" grid-column: 1;\n",
"}\n",
"\n",
".xr-attrs dt:hover span {\n",
" display: inline-block;\n",
" background: var(--xr-background-color);\n",
" padding-right: 10px;\n",
"}\n",
"\n",
".xr-attrs dd {\n",
" grid-column: 2;\n",
" white-space: pre-wrap;\n",
" word-break: break-all;\n",
"}\n",
"\n",
".xr-icon-database,\n",
".xr-icon-file-text2 {\n",
" display: inline-block;\n",
" vertical-align: middle;\n",
" width: 1em;\n",
" height: 1.5em !important;\n",
" stroke-width: 0;\n",
" stroke: currentColor;\n",
" fill: currentColor;\n",
"}\n",
"</style><pre class='xr-text-repr-fallback'>&lt;xarray.Dataset&gt;\n",
"Dimensions: (gage_id: 7994, time: 15310)\n",
"Coordinates:\n",
" * gage_id (gage_id) &lt;U20 &#x27;USGS-01030350&#x27; ... &#x27;USGS-10254970&#x27;\n",
" * time (time) datetime64[ns] 1979-02-01T05:00:00 ... 2020-12-31T05...\n",
"Data variables:\n",
" alt_acy_va (gage_id) float64 dask.array&lt;chunksize=(1,), meta=np.ndarray&gt;\n",
" alt_datum_cd (gage_id) &lt;U6 dask.array&lt;chunksize=(1,), meta=np.ndarray&gt;\n",
" alt_va (gage_id) float32 dask.array&lt;chunksize=(1,), meta=np.ndarray&gt;\n",
" begin_date (gage_id) &lt;U10 dask.array&lt;chunksize=(1,), meta=np.ndarray&gt;\n",
" dec_lat_va (gage_id) float32 dask.array&lt;chunksize=(1,), meta=np.ndarray&gt;\n",
" dec_long_va (gage_id) float32 dask.array&lt;chunksize=(1,), meta=np.ndarray&gt;\n",
" end_date (gage_id) &lt;U10 dask.array&lt;chunksize=(1,), meta=np.ndarray&gt;\n",
" huc_cd (gage_id) &lt;U8 dask.array&lt;chunksize=(1,), meta=np.ndarray&gt;\n",
" station_nm (gage_id) &lt;U43 dask.array&lt;chunksize=(1,), meta=np.ndarray&gt;\n",
" streamflow (time, gage_id) float32 dask.array&lt;chunksize=(15310, 1), meta=np.ndarray&gt;\n",
"Attributes:\n",
" tz: UTC</pre><div class='xr-wrap' style='display:none'><div class='xr-header'><div class='xr-obj-type'>xarray.Dataset</div></div><ul class='xr-sections'><li class='xr-section-item'><input id='section-712682da-bb2b-4cc3-9e36-4b7f4fbdeb64' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-712682da-bb2b-4cc3-9e36-4b7f4fbdeb64' class='xr-section-summary' title='Expand/collapse section'>Dimensions:</label><div class='xr-section-inline-details'><ul class='xr-dim-list'><li><span class='xr-has-index'>gage_id</span>: 7994</li><li><span class='xr-has-index'>time</span>: 15310</li></ul></div><div class='xr-section-details'></div></li><li class='xr-section-item'><input id='section-75894057-855f-4692-97da-aee85ad11448' class='xr-section-summary-in' type='checkbox' checked><label for='section-75894057-855f-4692-97da-aee85ad11448' class='xr-section-summary' >Coordinates: <span>(2)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>gage_id</span></div><div class='xr-var-dims'>(gage_id)</div><div class='xr-var-dtype'>&lt;U20</div><div class='xr-var-preview xr-preview'>&#x27;USGS-01030350&#x27; ... &#x27;USGS-10254970&#x27;</div><input id='attrs-3f085fa3-2b68-4468-a237-cea8d615e7fe' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-3f085fa3-2b68-4468-a237-cea8d615e7fe' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-ec44e072-5758-4829-a17c-14aa50b72998' class='xr-var-data-in' type='checkbox'><label for='data-ec44e072-5758-4829-a17c-14aa50b72998' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([&#x27;USGS-01030350&#x27;, &#x27;USGS-01030500&#x27;, &#x27;USGS-06741510&#x27;, ..., &#x27;USGS-12399500&#x27;,\n",
" &#x27;USGS-12306500&#x27;, &#x27;USGS-10254970&#x27;], dtype=&#x27;&lt;U20&#x27;)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>time</span></div><div class='xr-var-dims'>(time)</div><div class='xr-var-dtype'>datetime64[ns]</div><div class='xr-var-preview xr-preview'>1979-02-01T05:00:00 ... 2020-12-...</div><input id='attrs-8d22a81c-f49c-42b1-881a-4011463baeec' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-8d22a81c-f49c-42b1-881a-4011463baeec' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-b0529a38-b196-46c9-980d-cf1075ed011e' class='xr-var-data-in' type='checkbox'><label for='data-b0529a38-b196-46c9-980d-cf1075ed011e' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([&#x27;1979-02-01T05:00:00.000000000&#x27;, &#x27;1979-02-02T05:00:00.000000000&#x27;,\n",
" &#x27;1979-02-03T05:00:00.000000000&#x27;, ..., &#x27;2020-12-29T05:00:00.000000000&#x27;,\n",
" &#x27;2020-12-30T05:00:00.000000000&#x27;, &#x27;2020-12-31T05:00:00.000000000&#x27;],\n",
" dtype=&#x27;datetime64[ns]&#x27;)</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-752c1d60-8573-4c5e-9f1a-808cab535dba' class='xr-section-summary-in' type='checkbox' checked><label for='section-752c1d60-8573-4c5e-9f1a-808cab535dba' class='xr-section-summary' >Data variables: <span>(10)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span>alt_acy_va</span></div><div class='xr-var-dims'>(gage_id)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>dask.array&lt;chunksize=(1,), meta=np.ndarray&gt;</div><input id='attrs-dbd7fe78-029c-4eec-8570-03748496ed47' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-dbd7fe78-029c-4eec-8570-03748496ed47' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-f7b60df9-9fc7-4f57-9fa3-5c9893bf4f5a' class='xr-var-data-in' type='checkbox'><label for='data-f7b60df9-9fc7-4f57-9fa3-5c9893bf4f5a' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>altitude_accuracy</dd></dl></div><div class='xr-var-data'><table>\n",
" <tr>\n",
" <td>\n",
" <table>\n",
" <thead>\n",
" <tr>\n",
" <td> </td>\n",
" <th> Array </th>\n",
" <th> Chunk </th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" \n",
" <tr>\n",
" <th> Bytes </th>\n",
" <td> 62.45 kiB </td>\n",
" <td> 8 B </td>\n",
" </tr>\n",
" \n",
" <tr>\n",
" <th> Shape </th>\n",
" <td> (7994,) </td>\n",
" <td> (1,) </td>\n",
" </tr>\n",
" <tr>\n",
" <th> Count </th>\n",
" <td> 7995 Tasks </td>\n",
" <td> 7994 Chunks </td>\n",
" </tr>\n",
" <tr>\n",
" <th> Type </th>\n",
" <td> float64 </td>\n",
" <td> numpy.ndarray </td>\n",
" </tr>\n",
" </tbody>\n",
" </table>\n",
" </td>\n",
" <td>\n",
" <svg width=\"170\" height=\"75\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"0\" y1=\"0\" x2=\"120\" y2=\"0\" style=\"stroke-width:2\" />\n",
" <line x1=\"0\" y1=\"25\" x2=\"120\" y2=\"25\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"25\" style=\"stroke-width:2\" />\n",
" <line x1=\"6\" y1=\"0\" x2=\"6\" y2=\"25\" />\n",
" <line x1=\"12\" y1=\"0\" x2=\"12\" y2=\"25\" />\n",
" <line x1=\"18\" y1=\"0\" x2=\"18\" y2=\"25\" />\n",
" <line x1=\"25\" y1=\"0\" x2=\"25\" y2=\"25\" />\n",
" <line x1=\"31\" y1=\"0\" x2=\"31\" y2=\"25\" />\n",
" <line x1=\"37\" y1=\"0\" x2=\"37\" y2=\"25\" />\n",
" <line x1=\"44\" y1=\"0\" x2=\"44\" y2=\"25\" />\n",
" <line x1=\"50\" y1=\"0\" x2=\"50\" y2=\"25\" />\n",
" <line x1=\"56\" y1=\"0\" x2=\"56\" y2=\"25\" />\n",
" <line x1=\"63\" y1=\"0\" x2=\"63\" y2=\"25\" />\n",
" <line x1=\"69\" y1=\"0\" x2=\"69\" y2=\"25\" />\n",
" <line x1=\"75\" y1=\"0\" x2=\"75\" y2=\"25\" />\n",
" <line x1=\"82\" y1=\"0\" x2=\"82\" y2=\"25\" />\n",
" <line x1=\"88\" y1=\"0\" x2=\"88\" y2=\"25\" />\n",
" <line x1=\"94\" y1=\"0\" x2=\"94\" y2=\"25\" />\n",
" <line x1=\"101\" y1=\"0\" x2=\"101\" y2=\"25\" />\n",
" <line x1=\"107\" y1=\"0\" x2=\"107\" y2=\"25\" />\n",
" <line x1=\"113\" y1=\"0\" x2=\"113\" y2=\"25\" />\n",
" <line x1=\"120\" y1=\"0\" x2=\"120\" y2=\"25\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"0.0,0.0 120.0,0.0 120.0,25.412616514582485 0.0,25.412616514582485\" style=\"fill:#8B4903A0;stroke-width:0\"/>\n",
"\n",
" <!-- Text -->\n",
" <text x=\"60.000000\" y=\"45.412617\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >7994</text>\n",
" <text x=\"140.000000\" y=\"12.706308\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(0,140.000000,12.706308)\">1</text>\n",
"</svg>\n",
" </td>\n",
" </tr>\n",
"</table></div></li><li class='xr-var-item'><div class='xr-var-name'><span>alt_datum_cd</span></div><div class='xr-var-dims'>(gage_id)</div><div class='xr-var-dtype'>&lt;U6</div><div class='xr-var-preview xr-preview'>dask.array&lt;chunksize=(1,), meta=np.ndarray&gt;</div><input id='attrs-b2ff1a9b-cf99-4558-9219-0aa6f11b96ae' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-b2ff1a9b-cf99-4558-9219-0aa6f11b96ae' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-8b53719a-a83f-4a5d-92eb-7a1ff4511ef1' class='xr-var-data-in' type='checkbox'><label for='data-8b53719a-a83f-4a5d-92eb-7a1ff4511ef1' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>altitude_datum</dd></dl></div><div class='xr-var-data'><table>\n",
" <tr>\n",
" <td>\n",
" <table>\n",
" <thead>\n",
" <tr>\n",
" <td> </td>\n",
" <th> Array </th>\n",
" <th> Chunk </th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" \n",
" <tr>\n",
" <th> Bytes </th>\n",
" <td> 187.36 kiB </td>\n",
" <td> 24 B </td>\n",
" </tr>\n",
" \n",
" <tr>\n",
" <th> Shape </th>\n",
" <td> (7994,) </td>\n",
" <td> (1,) </td>\n",
" </tr>\n",
" <tr>\n",
" <th> Count </th>\n",
" <td> 7995 Tasks </td>\n",
" <td> 7994 Chunks </td>\n",
" </tr>\n",
" <tr>\n",
" <th> Type </th>\n",
" <td> <U6 </td>\n",
" <td> numpy.ndarray </td>\n",
" </tr>\n",
" </tbody>\n",
" </table>\n",
" </td>\n",
" <td>\n",
" <svg width=\"170\" height=\"75\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"0\" y1=\"0\" x2=\"120\" y2=\"0\" style=\"stroke-width:2\" />\n",
" <line x1=\"0\" y1=\"25\" x2=\"120\" y2=\"25\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"25\" style=\"stroke-width:2\" />\n",
" <line x1=\"6\" y1=\"0\" x2=\"6\" y2=\"25\" />\n",
" <line x1=\"12\" y1=\"0\" x2=\"12\" y2=\"25\" />\n",
" <line x1=\"18\" y1=\"0\" x2=\"18\" y2=\"25\" />\n",
" <line x1=\"25\" y1=\"0\" x2=\"25\" y2=\"25\" />\n",
" <line x1=\"31\" y1=\"0\" x2=\"31\" y2=\"25\" />\n",
" <line x1=\"37\" y1=\"0\" x2=\"37\" y2=\"25\" />\n",
" <line x1=\"44\" y1=\"0\" x2=\"44\" y2=\"25\" />\n",
" <line x1=\"50\" y1=\"0\" x2=\"50\" y2=\"25\" />\n",
" <line x1=\"56\" y1=\"0\" x2=\"56\" y2=\"25\" />\n",
" <line x1=\"63\" y1=\"0\" x2=\"63\" y2=\"25\" />\n",
" <line x1=\"69\" y1=\"0\" x2=\"69\" y2=\"25\" />\n",
" <line x1=\"75\" y1=\"0\" x2=\"75\" y2=\"25\" />\n",
" <line x1=\"82\" y1=\"0\" x2=\"82\" y2=\"25\" />\n",
" <line x1=\"88\" y1=\"0\" x2=\"88\" y2=\"25\" />\n",
" <line x1=\"94\" y1=\"0\" x2=\"94\" y2=\"25\" />\n",
" <line x1=\"101\" y1=\"0\" x2=\"101\" y2=\"25\" />\n",
" <line x1=\"107\" y1=\"0\" x2=\"107\" y2=\"25\" />\n",
" <line x1=\"113\" y1=\"0\" x2=\"113\" y2=\"25\" />\n",
" <line x1=\"120\" y1=\"0\" x2=\"120\" y2=\"25\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"0.0,0.0 120.0,0.0 120.0,25.412616514582485 0.0,25.412616514582485\" style=\"fill:#8B4903A0;stroke-width:0\"/>\n",
"\n",
" <!-- Text -->\n",
" <text x=\"60.000000\" y=\"45.412617\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >7994</text>\n",
" <text x=\"140.000000\" y=\"12.706308\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(0,140.000000,12.706308)\">1</text>\n",
"</svg>\n",
" </td>\n",
" </tr>\n",
"</table></div></li><li class='xr-var-item'><div class='xr-var-name'><span>alt_va</span></div><div class='xr-var-dims'>(gage_id)</div><div class='xr-var-dtype'>float32</div><div class='xr-var-preview xr-preview'>dask.array&lt;chunksize=(1,), meta=np.ndarray&gt;</div><input id='attrs-6bcc8941-9e11-4dd0-9cf7-c1dfd5b730a7' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-6bcc8941-9e11-4dd0-9cf7-c1dfd5b730a7' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-c6eb2605-6652-4e7c-9865-017df8e51ae6' class='xr-var-data-in' type='checkbox'><label for='data-c6eb2605-6652-4e7c-9865-017df8e51ae6' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>altitude</dd><dt><span>units :</span></dt><dd>ft</dd></dl></div><div class='xr-var-data'><table>\n",
" <tr>\n",
" <td>\n",
" <table>\n",
" <thead>\n",
" <tr>\n",
" <td> </td>\n",
" <th> Array </th>\n",
" <th> Chunk </th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" \n",
" <tr>\n",
" <th> Bytes </th>\n",
" <td> 31.23 kiB </td>\n",
" <td> 4 B </td>\n",
" </tr>\n",
" \n",
" <tr>\n",
" <th> Shape </th>\n",
" <td> (7994,) </td>\n",
" <td> (1,) </td>\n",
" </tr>\n",
" <tr>\n",
" <th> Count </th>\n",
" <td> 7995 Tasks </td>\n",
" <td> 7994 Chunks </td>\n",
" </tr>\n",
" <tr>\n",
" <th> Type </th>\n",
" <td> float32 </td>\n",
" <td> numpy.ndarray </td>\n",
" </tr>\n",
" </tbody>\n",
" </table>\n",
" </td>\n",
" <td>\n",
" <svg width=\"170\" height=\"75\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"0\" y1=\"0\" x2=\"120\" y2=\"0\" style=\"stroke-width:2\" />\n",
" <line x1=\"0\" y1=\"25\" x2=\"120\" y2=\"25\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"25\" style=\"stroke-width:2\" />\n",
" <line x1=\"6\" y1=\"0\" x2=\"6\" y2=\"25\" />\n",
" <line x1=\"12\" y1=\"0\" x2=\"12\" y2=\"25\" />\n",
" <line x1=\"18\" y1=\"0\" x2=\"18\" y2=\"25\" />\n",
" <line x1=\"25\" y1=\"0\" x2=\"25\" y2=\"25\" />\n",
" <line x1=\"31\" y1=\"0\" x2=\"31\" y2=\"25\" />\n",
" <line x1=\"37\" y1=\"0\" x2=\"37\" y2=\"25\" />\n",
" <line x1=\"44\" y1=\"0\" x2=\"44\" y2=\"25\" />\n",
" <line x1=\"50\" y1=\"0\" x2=\"50\" y2=\"25\" />\n",
" <line x1=\"56\" y1=\"0\" x2=\"56\" y2=\"25\" />\n",
" <line x1=\"63\" y1=\"0\" x2=\"63\" y2=\"25\" />\n",
" <line x1=\"69\" y1=\"0\" x2=\"69\" y2=\"25\" />\n",
" <line x1=\"75\" y1=\"0\" x2=\"75\" y2=\"25\" />\n",
" <line x1=\"82\" y1=\"0\" x2=\"82\" y2=\"25\" />\n",
" <line x1=\"88\" y1=\"0\" x2=\"88\" y2=\"25\" />\n",
" <line x1=\"94\" y1=\"0\" x2=\"94\" y2=\"25\" />\n",
" <line x1=\"101\" y1=\"0\" x2=\"101\" y2=\"25\" />\n",
" <line x1=\"107\" y1=\"0\" x2=\"107\" y2=\"25\" />\n",
" <line x1=\"113\" y1=\"0\" x2=\"113\" y2=\"25\" />\n",
" <line x1=\"120\" y1=\"0\" x2=\"120\" y2=\"25\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"0.0,0.0 120.0,0.0 120.0,25.412616514582485 0.0,25.412616514582485\" style=\"fill:#8B4903A0;stroke-width:0\"/>\n",
"\n",
" <!-- Text -->\n",
" <text x=\"60.000000\" y=\"45.412617\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >7994</text>\n",
" <text x=\"140.000000\" y=\"12.706308\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(0,140.000000,12.706308)\">1</text>\n",
"</svg>\n",
" </td>\n",
" </tr>\n",
"</table></div></li><li class='xr-var-item'><div class='xr-var-name'><span>begin_date</span></div><div class='xr-var-dims'>(gage_id)</div><div class='xr-var-dtype'>&lt;U10</div><div class='xr-var-preview xr-preview'>dask.array&lt;chunksize=(1,), meta=np.ndarray&gt;</div><input id='attrs-f3ae46fd-4caf-439c-9ab4-568c99a7e686' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-f3ae46fd-4caf-439c-9ab4-568c99a7e686' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-3f9cbf0c-ff73-4c7d-98cc-a89676a58cf4' class='xr-var-data-in' type='checkbox'><label for='data-3f9cbf0c-ff73-4c7d-98cc-a89676a58cf4' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>availablity_begin_date</dd></dl></div><div class='xr-var-data'><table>\n",
" <tr>\n",
" <td>\n",
" <table>\n",
" <thead>\n",
" <tr>\n",
" <td> </td>\n",
" <th> Array </th>\n",
" <th> Chunk </th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" \n",
" <tr>\n",
" <th> Bytes </th>\n",
" <td> 312.27 kiB </td>\n",
" <td> 40 B </td>\n",
" </tr>\n",
" \n",
" <tr>\n",
" <th> Shape </th>\n",
" <td> (7994,) </td>\n",
" <td> (1,) </td>\n",
" </tr>\n",
" <tr>\n",
" <th> Count </th>\n",
" <td> 7995 Tasks </td>\n",
" <td> 7994 Chunks </td>\n",
" </tr>\n",
" <tr>\n",
" <th> Type </th>\n",
" <td> <U10 </td>\n",
" <td> numpy.ndarray </td>\n",
" </tr>\n",
" </tbody>\n",
" </table>\n",
" </td>\n",
" <td>\n",
" <svg width=\"170\" height=\"75\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"0\" y1=\"0\" x2=\"120\" y2=\"0\" style=\"stroke-width:2\" />\n",
" <line x1=\"0\" y1=\"25\" x2=\"120\" y2=\"25\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"25\" style=\"stroke-width:2\" />\n",
" <line x1=\"6\" y1=\"0\" x2=\"6\" y2=\"25\" />\n",
" <line x1=\"12\" y1=\"0\" x2=\"12\" y2=\"25\" />\n",
" <line x1=\"18\" y1=\"0\" x2=\"18\" y2=\"25\" />\n",
" <line x1=\"25\" y1=\"0\" x2=\"25\" y2=\"25\" />\n",
" <line x1=\"31\" y1=\"0\" x2=\"31\" y2=\"25\" />\n",
" <line x1=\"37\" y1=\"0\" x2=\"37\" y2=\"25\" />\n",
" <line x1=\"44\" y1=\"0\" x2=\"44\" y2=\"25\" />\n",
" <line x1=\"50\" y1=\"0\" x2=\"50\" y2=\"25\" />\n",
" <line x1=\"56\" y1=\"0\" x2=\"56\" y2=\"25\" />\n",
" <line x1=\"63\" y1=\"0\" x2=\"63\" y2=\"25\" />\n",
" <line x1=\"69\" y1=\"0\" x2=\"69\" y2=\"25\" />\n",
" <line x1=\"75\" y1=\"0\" x2=\"75\" y2=\"25\" />\n",
" <line x1=\"82\" y1=\"0\" x2=\"82\" y2=\"25\" />\n",
" <line x1=\"88\" y1=\"0\" x2=\"88\" y2=\"25\" />\n",
" <line x1=\"94\" y1=\"0\" x2=\"94\" y2=\"25\" />\n",
" <line x1=\"101\" y1=\"0\" x2=\"101\" y2=\"25\" />\n",
" <line x1=\"107\" y1=\"0\" x2=\"107\" y2=\"25\" />\n",
" <line x1=\"113\" y1=\"0\" x2=\"113\" y2=\"25\" />\n",
" <line x1=\"120\" y1=\"0\" x2=\"120\" y2=\"25\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"0.0,0.0 120.0,0.0 120.0,25.412616514582485 0.0,25.412616514582485\" style=\"fill:#8B4903A0;stroke-width:0\"/>\n",
"\n",
" <!-- Text -->\n",
" <text x=\"60.000000\" y=\"45.412617\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >7994</text>\n",
" <text x=\"140.000000\" y=\"12.706308\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(0,140.000000,12.706308)\">1</text>\n",
"</svg>\n",
" </td>\n",
" </tr>\n",
"</table></div></li><li class='xr-var-item'><div class='xr-var-name'><span>dec_lat_va</span></div><div class='xr-var-dims'>(gage_id)</div><div class='xr-var-dtype'>float32</div><div class='xr-var-preview xr-preview'>dask.array&lt;chunksize=(1,), meta=np.ndarray&gt;</div><input id='attrs-a10a6579-f41c-4bd3-b5ea-ee228e6dd4f2' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-a10a6579-f41c-4bd3-b5ea-ee228e6dd4f2' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-3db4509b-2402-4b7b-acbd-cac6bf0b4347' class='xr-var-data-in' type='checkbox'><label for='data-3db4509b-2402-4b7b-acbd-cac6bf0b4347' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>latitude</dd><dt><span>units :</span></dt><dd>decimal_degrees</dd></dl></div><div class='xr-var-data'><table>\n",
" <tr>\n",
" <td>\n",
" <table>\n",
" <thead>\n",
" <tr>\n",
" <td> </td>\n",
" <th> Array </th>\n",
" <th> Chunk </th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" \n",
" <tr>\n",
" <th> Bytes </th>\n",
" <td> 31.23 kiB </td>\n",
" <td> 4 B </td>\n",
" </tr>\n",
" \n",
" <tr>\n",
" <th> Shape </th>\n",
" <td> (7994,) </td>\n",
" <td> (1,) </td>\n",
" </tr>\n",
" <tr>\n",
" <th> Count </th>\n",
" <td> 7995 Tasks </td>\n",
" <td> 7994 Chunks </td>\n",
" </tr>\n",
" <tr>\n",
" <th> Type </th>\n",
" <td> float32 </td>\n",
" <td> numpy.ndarray </td>\n",
" </tr>\n",
" </tbody>\n",
" </table>\n",
" </td>\n",
" <td>\n",
" <svg width=\"170\" height=\"75\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"0\" y1=\"0\" x2=\"120\" y2=\"0\" style=\"stroke-width:2\" />\n",
" <line x1=\"0\" y1=\"25\" x2=\"120\" y2=\"25\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"25\" style=\"stroke-width:2\" />\n",
" <line x1=\"6\" y1=\"0\" x2=\"6\" y2=\"25\" />\n",
" <line x1=\"12\" y1=\"0\" x2=\"12\" y2=\"25\" />\n",
" <line x1=\"18\" y1=\"0\" x2=\"18\" y2=\"25\" />\n",
" <line x1=\"25\" y1=\"0\" x2=\"25\" y2=\"25\" />\n",
" <line x1=\"31\" y1=\"0\" x2=\"31\" y2=\"25\" />\n",
" <line x1=\"37\" y1=\"0\" x2=\"37\" y2=\"25\" />\n",
" <line x1=\"44\" y1=\"0\" x2=\"44\" y2=\"25\" />\n",
" <line x1=\"50\" y1=\"0\" x2=\"50\" y2=\"25\" />\n",
" <line x1=\"56\" y1=\"0\" x2=\"56\" y2=\"25\" />\n",
" <line x1=\"63\" y1=\"0\" x2=\"63\" y2=\"25\" />\n",
" <line x1=\"69\" y1=\"0\" x2=\"69\" y2=\"25\" />\n",
" <line x1=\"75\" y1=\"0\" x2=\"75\" y2=\"25\" />\n",
" <line x1=\"82\" y1=\"0\" x2=\"82\" y2=\"25\" />\n",
" <line x1=\"88\" y1=\"0\" x2=\"88\" y2=\"25\" />\n",
" <line x1=\"94\" y1=\"0\" x2=\"94\" y2=\"25\" />\n",
" <line x1=\"101\" y1=\"0\" x2=\"101\" y2=\"25\" />\n",
" <line x1=\"107\" y1=\"0\" x2=\"107\" y2=\"25\" />\n",
" <line x1=\"113\" y1=\"0\" x2=\"113\" y2=\"25\" />\n",
" <line x1=\"120\" y1=\"0\" x2=\"120\" y2=\"25\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"0.0,0.0 120.0,0.0 120.0,25.412616514582485 0.0,25.412616514582485\" style=\"fill:#8B4903A0;stroke-width:0\"/>\n",
"\n",
" <!-- Text -->\n",
" <text x=\"60.000000\" y=\"45.412617\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >7994</text>\n",
" <text x=\"140.000000\" y=\"12.706308\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(0,140.000000,12.706308)\">1</text>\n",
"</svg>\n",
" </td>\n",
" </tr>\n",
"</table></div></li><li class='xr-var-item'><div class='xr-var-name'><span>dec_long_va</span></div><div class='xr-var-dims'>(gage_id)</div><div class='xr-var-dtype'>float32</div><div class='xr-var-preview xr-preview'>dask.array&lt;chunksize=(1,), meta=np.ndarray&gt;</div><input id='attrs-33084c68-ec01-42be-9e9d-8c0ce343f60c' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-33084c68-ec01-42be-9e9d-8c0ce343f60c' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-3258a36f-749c-498d-b542-a03293ac0297' class='xr-var-data-in' type='checkbox'><label for='data-3258a36f-749c-498d-b542-a03293ac0297' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>longitude</dd><dt><span>units :</span></dt><dd>decimal_degrees</dd></dl></div><div class='xr-var-data'><table>\n",
" <tr>\n",
" <td>\n",
" <table>\n",
" <thead>\n",
" <tr>\n",
" <td> </td>\n",
" <th> Array </th>\n",
" <th> Chunk </th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" \n",
" <tr>\n",
" <th> Bytes </th>\n",
" <td> 31.23 kiB </td>\n",
" <td> 4 B </td>\n",
" </tr>\n",
" \n",
" <tr>\n",
" <th> Shape </th>\n",
" <td> (7994,) </td>\n",
" <td> (1,) </td>\n",
" </tr>\n",
" <tr>\n",
" <th> Count </th>\n",
" <td> 7995 Tasks </td>\n",
" <td> 7994 Chunks </td>\n",
" </tr>\n",
" <tr>\n",
" <th> Type </th>\n",
" <td> float32 </td>\n",
" <td> numpy.ndarray </td>\n",
" </tr>\n",
" </tbody>\n",
" </table>\n",
" </td>\n",
" <td>\n",
" <svg width=\"170\" height=\"75\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"0\" y1=\"0\" x2=\"120\" y2=\"0\" style=\"stroke-width:2\" />\n",
" <line x1=\"0\" y1=\"25\" x2=\"120\" y2=\"25\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"25\" style=\"stroke-width:2\" />\n",
" <line x1=\"6\" y1=\"0\" x2=\"6\" y2=\"25\" />\n",
" <line x1=\"12\" y1=\"0\" x2=\"12\" y2=\"25\" />\n",
" <line x1=\"18\" y1=\"0\" x2=\"18\" y2=\"25\" />\n",
" <line x1=\"25\" y1=\"0\" x2=\"25\" y2=\"25\" />\n",
" <line x1=\"31\" y1=\"0\" x2=\"31\" y2=\"25\" />\n",
" <line x1=\"37\" y1=\"0\" x2=\"37\" y2=\"25\" />\n",
" <line x1=\"44\" y1=\"0\" x2=\"44\" y2=\"25\" />\n",
" <line x1=\"50\" y1=\"0\" x2=\"50\" y2=\"25\" />\n",
" <line x1=\"56\" y1=\"0\" x2=\"56\" y2=\"25\" />\n",
" <line x1=\"63\" y1=\"0\" x2=\"63\" y2=\"25\" />\n",
" <line x1=\"69\" y1=\"0\" x2=\"69\" y2=\"25\" />\n",
" <line x1=\"75\" y1=\"0\" x2=\"75\" y2=\"25\" />\n",
" <line x1=\"82\" y1=\"0\" x2=\"82\" y2=\"25\" />\n",
" <line x1=\"88\" y1=\"0\" x2=\"88\" y2=\"25\" />\n",
" <line x1=\"94\" y1=\"0\" x2=\"94\" y2=\"25\" />\n",
" <line x1=\"101\" y1=\"0\" x2=\"101\" y2=\"25\" />\n",
" <line x1=\"107\" y1=\"0\" x2=\"107\" y2=\"25\" />\n",
" <line x1=\"113\" y1=\"0\" x2=\"113\" y2=\"25\" />\n",
" <line x1=\"120\" y1=\"0\" x2=\"120\" y2=\"25\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"0.0,0.0 120.0,0.0 120.0,25.412616514582485 0.0,25.412616514582485\" style=\"fill:#8B4903A0;stroke-width:0\"/>\n",
"\n",
" <!-- Text -->\n",
" <text x=\"60.000000\" y=\"45.412617\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >7994</text>\n",
" <text x=\"140.000000\" y=\"12.706308\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(0,140.000000,12.706308)\">1</text>\n",
"</svg>\n",
" </td>\n",
" </tr>\n",
"</table></div></li><li class='xr-var-item'><div class='xr-var-name'><span>end_date</span></div><div class='xr-var-dims'>(gage_id)</div><div class='xr-var-dtype'>&lt;U10</div><div class='xr-var-preview xr-preview'>dask.array&lt;chunksize=(1,), meta=np.ndarray&gt;</div><input id='attrs-0170d604-7700-4b23-baa0-a9914b37d1cc' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-0170d604-7700-4b23-baa0-a9914b37d1cc' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-86aa0e75-eca3-4809-ba94-37b29c8db1e6' class='xr-var-data-in' type='checkbox'><label for='data-86aa0e75-eca3-4809-ba94-37b29c8db1e6' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>availablity_end_date</dd></dl></div><div class='xr-var-data'><table>\n",
" <tr>\n",
" <td>\n",
" <table>\n",
" <thead>\n",
" <tr>\n",
" <td> </td>\n",
" <th> Array </th>\n",
" <th> Chunk </th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" \n",
" <tr>\n",
" <th> Bytes </th>\n",
" <td> 312.27 kiB </td>\n",
" <td> 40 B </td>\n",
" </tr>\n",
" \n",
" <tr>\n",
" <th> Shape </th>\n",
" <td> (7994,) </td>\n",
" <td> (1,) </td>\n",
" </tr>\n",
" <tr>\n",
" <th> Count </th>\n",
" <td> 7995 Tasks </td>\n",
" <td> 7994 Chunks </td>\n",
" </tr>\n",
" <tr>\n",
" <th> Type </th>\n",
" <td> <U10 </td>\n",
" <td> numpy.ndarray </td>\n",
" </tr>\n",
" </tbody>\n",
" </table>\n",
" </td>\n",
" <td>\n",
" <svg width=\"170\" height=\"75\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"0\" y1=\"0\" x2=\"120\" y2=\"0\" style=\"stroke-width:2\" />\n",
" <line x1=\"0\" y1=\"25\" x2=\"120\" y2=\"25\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"25\" style=\"stroke-width:2\" />\n",
" <line x1=\"6\" y1=\"0\" x2=\"6\" y2=\"25\" />\n",
" <line x1=\"12\" y1=\"0\" x2=\"12\" y2=\"25\" />\n",
" <line x1=\"18\" y1=\"0\" x2=\"18\" y2=\"25\" />\n",
" <line x1=\"25\" y1=\"0\" x2=\"25\" y2=\"25\" />\n",
" <line x1=\"31\" y1=\"0\" x2=\"31\" y2=\"25\" />\n",
" <line x1=\"37\" y1=\"0\" x2=\"37\" y2=\"25\" />\n",
" <line x1=\"44\" y1=\"0\" x2=\"44\" y2=\"25\" />\n",
" <line x1=\"50\" y1=\"0\" x2=\"50\" y2=\"25\" />\n",
" <line x1=\"56\" y1=\"0\" x2=\"56\" y2=\"25\" />\n",
" <line x1=\"63\" y1=\"0\" x2=\"63\" y2=\"25\" />\n",
" <line x1=\"69\" y1=\"0\" x2=\"69\" y2=\"25\" />\n",
" <line x1=\"75\" y1=\"0\" x2=\"75\" y2=\"25\" />\n",
" <line x1=\"82\" y1=\"0\" x2=\"82\" y2=\"25\" />\n",
" <line x1=\"88\" y1=\"0\" x2=\"88\" y2=\"25\" />\n",
" <line x1=\"94\" y1=\"0\" x2=\"94\" y2=\"25\" />\n",
" <line x1=\"101\" y1=\"0\" x2=\"101\" y2=\"25\" />\n",
" <line x1=\"107\" y1=\"0\" x2=\"107\" y2=\"25\" />\n",
" <line x1=\"113\" y1=\"0\" x2=\"113\" y2=\"25\" />\n",
" <line x1=\"120\" y1=\"0\" x2=\"120\" y2=\"25\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"0.0,0.0 120.0,0.0 120.0,25.412616514582485 0.0,25.412616514582485\" style=\"fill:#8B4903A0;stroke-width:0\"/>\n",
"\n",
" <!-- Text -->\n",
" <text x=\"60.000000\" y=\"45.412617\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >7994</text>\n",
" <text x=\"140.000000\" y=\"12.706308\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(0,140.000000,12.706308)\">1</text>\n",
"</svg>\n",
" </td>\n",
" </tr>\n",
"</table></div></li><li class='xr-var-item'><div class='xr-var-name'><span>huc_cd</span></div><div class='xr-var-dims'>(gage_id)</div><div class='xr-var-dtype'>&lt;U8</div><div class='xr-var-preview xr-preview'>dask.array&lt;chunksize=(1,), meta=np.ndarray&gt;</div><input id='attrs-1875db74-be7f-4a32-8425-57208d1ce2d0' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-1875db74-be7f-4a32-8425-57208d1ce2d0' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-34976a93-7fd4-41a6-ae82-f0c6759c70ff' class='xr-var-data-in' type='checkbox'><label for='data-34976a93-7fd4-41a6-ae82-f0c6759c70ff' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>hydrologic_unit_code</dd></dl></div><div class='xr-var-data'><table>\n",
" <tr>\n",
" <td>\n",
" <table>\n",
" <thead>\n",
" <tr>\n",
" <td> </td>\n",
" <th> Array </th>\n",
" <th> Chunk </th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" \n",
" <tr>\n",
" <th> Bytes </th>\n",
" <td> 249.81 kiB </td>\n",
" <td> 32 B </td>\n",
" </tr>\n",
" \n",
" <tr>\n",
" <th> Shape </th>\n",
" <td> (7994,) </td>\n",
" <td> (1,) </td>\n",
" </tr>\n",
" <tr>\n",
" <th> Count </th>\n",
" <td> 7995 Tasks </td>\n",
" <td> 7994 Chunks </td>\n",
" </tr>\n",
" <tr>\n",
" <th> Type </th>\n",
" <td> <U8 </td>\n",
" <td> numpy.ndarray </td>\n",
" </tr>\n",
" </tbody>\n",
" </table>\n",
" </td>\n",
" <td>\n",
" <svg width=\"170\" height=\"75\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"0\" y1=\"0\" x2=\"120\" y2=\"0\" style=\"stroke-width:2\" />\n",
" <line x1=\"0\" y1=\"25\" x2=\"120\" y2=\"25\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"25\" style=\"stroke-width:2\" />\n",
" <line x1=\"6\" y1=\"0\" x2=\"6\" y2=\"25\" />\n",
" <line x1=\"12\" y1=\"0\" x2=\"12\" y2=\"25\" />\n",
" <line x1=\"18\" y1=\"0\" x2=\"18\" y2=\"25\" />\n",
" <line x1=\"25\" y1=\"0\" x2=\"25\" y2=\"25\" />\n",
" <line x1=\"31\" y1=\"0\" x2=\"31\" y2=\"25\" />\n",
" <line x1=\"37\" y1=\"0\" x2=\"37\" y2=\"25\" />\n",
" <line x1=\"44\" y1=\"0\" x2=\"44\" y2=\"25\" />\n",
" <line x1=\"50\" y1=\"0\" x2=\"50\" y2=\"25\" />\n",
" <line x1=\"56\" y1=\"0\" x2=\"56\" y2=\"25\" />\n",
" <line x1=\"63\" y1=\"0\" x2=\"63\" y2=\"25\" />\n",
" <line x1=\"69\" y1=\"0\" x2=\"69\" y2=\"25\" />\n",
" <line x1=\"75\" y1=\"0\" x2=\"75\" y2=\"25\" />\n",
" <line x1=\"82\" y1=\"0\" x2=\"82\" y2=\"25\" />\n",
" <line x1=\"88\" y1=\"0\" x2=\"88\" y2=\"25\" />\n",
" <line x1=\"94\" y1=\"0\" x2=\"94\" y2=\"25\" />\n",
" <line x1=\"101\" y1=\"0\" x2=\"101\" y2=\"25\" />\n",
" <line x1=\"107\" y1=\"0\" x2=\"107\" y2=\"25\" />\n",
" <line x1=\"113\" y1=\"0\" x2=\"113\" y2=\"25\" />\n",
" <line x1=\"120\" y1=\"0\" x2=\"120\" y2=\"25\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"0.0,0.0 120.0,0.0 120.0,25.412616514582485 0.0,25.412616514582485\" style=\"fill:#8B4903A0;stroke-width:0\"/>\n",
"\n",
" <!-- Text -->\n",
" <text x=\"60.000000\" y=\"45.412617\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >7994</text>\n",
" <text x=\"140.000000\" y=\"12.706308\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(0,140.000000,12.706308)\">1</text>\n",
"</svg>\n",
" </td>\n",
" </tr>\n",
"</table></div></li><li class='xr-var-item'><div class='xr-var-name'><span>station_nm</span></div><div class='xr-var-dims'>(gage_id)</div><div class='xr-var-dtype'>&lt;U43</div><div class='xr-var-preview xr-preview'>dask.array&lt;chunksize=(1,), meta=np.ndarray&gt;</div><input id='attrs-ef057720-6f8c-445d-84fd-5d29e2a783ff' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-ef057720-6f8c-445d-84fd-5d29e2a783ff' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-13351a41-ae7a-4780-9592-600af91c5c53' class='xr-var-data-in' type='checkbox'><label for='data-13351a41-ae7a-4780-9592-600af91c5c53' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>station_name</dd></dl></div><div class='xr-var-data'><table>\n",
" <tr>\n",
" <td>\n",
" <table>\n",
" <thead>\n",
" <tr>\n",
" <td> </td>\n",
" <th> Array </th>\n",
" <th> Chunk </th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" \n",
" <tr>\n",
" <th> Bytes </th>\n",
" <td> 1.31 MiB </td>\n",
" <td> 172 B </td>\n",
" </tr>\n",
" \n",
" <tr>\n",
" <th> Shape </th>\n",
" <td> (7994,) </td>\n",
" <td> (1,) </td>\n",
" </tr>\n",
" <tr>\n",
" <th> Count </th>\n",
" <td> 7995 Tasks </td>\n",
" <td> 7994 Chunks </td>\n",
" </tr>\n",
" <tr>\n",
" <th> Type </th>\n",
" <td> <U43 </td>\n",
" <td> numpy.ndarray </td>\n",
" </tr>\n",
" </tbody>\n",
" </table>\n",
" </td>\n",
" <td>\n",
" <svg width=\"170\" height=\"75\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"0\" y1=\"0\" x2=\"120\" y2=\"0\" style=\"stroke-width:2\" />\n",
" <line x1=\"0\" y1=\"25\" x2=\"120\" y2=\"25\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"25\" style=\"stroke-width:2\" />\n",
" <line x1=\"6\" y1=\"0\" x2=\"6\" y2=\"25\" />\n",
" <line x1=\"12\" y1=\"0\" x2=\"12\" y2=\"25\" />\n",
" <line x1=\"18\" y1=\"0\" x2=\"18\" y2=\"25\" />\n",
" <line x1=\"25\" y1=\"0\" x2=\"25\" y2=\"25\" />\n",
" <line x1=\"31\" y1=\"0\" x2=\"31\" y2=\"25\" />\n",
" <line x1=\"37\" y1=\"0\" x2=\"37\" y2=\"25\" />\n",
" <line x1=\"44\" y1=\"0\" x2=\"44\" y2=\"25\" />\n",
" <line x1=\"50\" y1=\"0\" x2=\"50\" y2=\"25\" />\n",
" <line x1=\"56\" y1=\"0\" x2=\"56\" y2=\"25\" />\n",
" <line x1=\"63\" y1=\"0\" x2=\"63\" y2=\"25\" />\n",
" <line x1=\"69\" y1=\"0\" x2=\"69\" y2=\"25\" />\n",
" <line x1=\"75\" y1=\"0\" x2=\"75\" y2=\"25\" />\n",
" <line x1=\"82\" y1=\"0\" x2=\"82\" y2=\"25\" />\n",
" <line x1=\"88\" y1=\"0\" x2=\"88\" y2=\"25\" />\n",
" <line x1=\"94\" y1=\"0\" x2=\"94\" y2=\"25\" />\n",
" <line x1=\"101\" y1=\"0\" x2=\"101\" y2=\"25\" />\n",
" <line x1=\"107\" y1=\"0\" x2=\"107\" y2=\"25\" />\n",
" <line x1=\"113\" y1=\"0\" x2=\"113\" y2=\"25\" />\n",
" <line x1=\"120\" y1=\"0\" x2=\"120\" y2=\"25\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"0.0,0.0 120.0,0.0 120.0,25.412616514582485 0.0,25.412616514582485\" style=\"fill:#8B4903A0;stroke-width:0\"/>\n",
"\n",
" <!-- Text -->\n",
" <text x=\"60.000000\" y=\"45.412617\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >7994</text>\n",
" <text x=\"140.000000\" y=\"12.706308\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(0,140.000000,12.706308)\">1</text>\n",
"</svg>\n",
" </td>\n",
" </tr>\n",
"</table></div></li><li class='xr-var-item'><div class='xr-var-name'><span>streamflow</span></div><div class='xr-var-dims'>(time, gage_id)</div><div class='xr-var-dtype'>float32</div><div class='xr-var-preview xr-preview'>dask.array&lt;chunksize=(15310, 1), meta=np.ndarray&gt;</div><input id='attrs-9f7239d3-42e2-4540-b49e-875ee0bd1d6c' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-9f7239d3-42e2-4540-b49e-875ee0bd1d6c' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-433a7341-e2cb-4d51-8daf-2d55530bd278' class='xr-var-data-in' type='checkbox'><label for='data-433a7341-e2cb-4d51-8daf-2d55530bd278' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>units :</span></dt><dd>cms</dd></dl></div><div class='xr-var-data'><table>\n",
" <tr>\n",
" <td>\n",
" <table>\n",
" <thead>\n",
" <tr>\n",
" <td> </td>\n",
" <th> Array </th>\n",
" <th> Chunk </th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" \n",
" <tr>\n",
" <th> Bytes </th>\n",
" <td> 466.87 MiB </td>\n",
" <td> 59.80 kiB </td>\n",
" </tr>\n",
" \n",
" <tr>\n",
" <th> Shape </th>\n",
" <td> (15310, 7994) </td>\n",
" <td> (15310, 1) </td>\n",
" </tr>\n",
" <tr>\n",
" <th> Count </th>\n",
" <td> 7995 Tasks </td>\n",
" <td> 7994 Chunks </td>\n",
" </tr>\n",
" <tr>\n",
" <th> Type </th>\n",
" <td> float32 </td>\n",
" <td> numpy.ndarray </td>\n",
" </tr>\n",
" </tbody>\n",
" </table>\n",
" </td>\n",
" <td>\n",
" <svg width=\"112\" height=\"170\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"0\" y1=\"0\" x2=\"62\" y2=\"0\" style=\"stroke-width:2\" />\n",
" <line x1=\"0\" y1=\"120\" x2=\"62\" y2=\"120\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"120\" style=\"stroke-width:2\" />\n",
" <line x1=\"3\" y1=\"0\" x2=\"3\" y2=\"120\" />\n",
" <line x1=\"6\" y1=\"0\" x2=\"6\" y2=\"120\" />\n",
" <line x1=\"9\" y1=\"0\" x2=\"9\" y2=\"120\" />\n",
" <line x1=\"13\" y1=\"0\" x2=\"13\" y2=\"120\" />\n",
" <line x1=\"16\" y1=\"0\" x2=\"16\" y2=\"120\" />\n",
" <line x1=\"19\" y1=\"0\" x2=\"19\" y2=\"120\" />\n",
" <line x1=\"23\" y1=\"0\" x2=\"23\" y2=\"120\" />\n",
" <line x1=\"26\" y1=\"0\" x2=\"26\" y2=\"120\" />\n",
" <line x1=\"29\" y1=\"0\" x2=\"29\" y2=\"120\" />\n",
" <line x1=\"32\" y1=\"0\" x2=\"32\" y2=\"120\" />\n",
" <line x1=\"36\" y1=\"0\" x2=\"36\" y2=\"120\" />\n",
" <line x1=\"39\" y1=\"0\" x2=\"39\" y2=\"120\" />\n",
" <line x1=\"42\" y1=\"0\" x2=\"42\" y2=\"120\" />\n",
" <line x1=\"46\" y1=\"0\" x2=\"46\" y2=\"120\" />\n",
" <line x1=\"49\" y1=\"0\" x2=\"49\" y2=\"120\" />\n",
" <line x1=\"52\" y1=\"0\" x2=\"52\" y2=\"120\" />\n",
" <line x1=\"56\" y1=\"0\" x2=\"56\" y2=\"120\" />\n",
" <line x1=\"59\" y1=\"0\" x2=\"59\" y2=\"120\" />\n",
" <line x1=\"62\" y1=\"0\" x2=\"62\" y2=\"120\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"0.0,0.0 62.65708687132593,0.0 62.65708687132593,120.0 0.0,120.0\" style=\"fill:#8B4903A0;stroke-width:0\"/>\n",
"\n",
" <!-- Text -->\n",
" <text x=\"31.328543\" y=\"140.000000\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >7994</text>\n",
" <text x=\"82.657087\" y=\"60.000000\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(-90,82.657087,60.000000)\">15310</text>\n",
"</svg>\n",
" </td>\n",
" </tr>\n",
"</table></div></li></ul></div></li><li class='xr-section-item'><input id='section-7b3db991-8b41-444b-94f0-e1330aa33bda' class='xr-section-summary-in' type='checkbox' checked><label for='section-7b3db991-8b41-444b-94f0-e1330aa33bda' class='xr-section-summary' >Attributes: <span>(1)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'><dt><span>tz :</span></dt><dd>UTC</dd></dl></div></li></ul></div></div>"
],
"text/plain": [
"<xarray.Dataset>\n",
"Dimensions: (gage_id: 7994, time: 15310)\n",
"Coordinates:\n",
" * gage_id (gage_id) <U20 'USGS-01030350' ... 'USGS-10254970'\n",
" * time (time) datetime64[ns] 1979-02-01T05:00:00 ... 2020-12-31T05...\n",
"Data variables:\n",
" alt_acy_va (gage_id) float64 dask.array<chunksize=(1,), meta=np.ndarray>\n",
" alt_datum_cd (gage_id) <U6 dask.array<chunksize=(1,), meta=np.ndarray>\n",
" alt_va (gage_id) float32 dask.array<chunksize=(1,), meta=np.ndarray>\n",
" begin_date (gage_id) <U10 dask.array<chunksize=(1,), meta=np.ndarray>\n",
" dec_lat_va (gage_id) float32 dask.array<chunksize=(1,), meta=np.ndarray>\n",
" dec_long_va (gage_id) float32 dask.array<chunksize=(1,), meta=np.ndarray>\n",
" end_date (gage_id) <U10 dask.array<chunksize=(1,), meta=np.ndarray>\n",
" huc_cd (gage_id) <U8 dask.array<chunksize=(1,), meta=np.ndarray>\n",
" station_nm (gage_id) <U43 dask.array<chunksize=(1,), meta=np.ndarray>\n",
" streamflow (time, gage_id) float32 dask.array<chunksize=(15310, 1), meta=np.ndarray>\n",
"Attributes:\n",
" tz: UTC"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"observations_ds = cat[f'nwis-streamflow-usgs-gages-onprem'].to_dask()\n",
"observations_ds"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "258ddbbe-ebd2-452c-ac86-5fd20831181d",
"metadata": {},
"outputs": [],
"source": [
"def load_streamflow_data(resource):\n",
" ''' Helper function to load observations and model predictions from Intake.\n",
" \n",
" Some initial preprocessing is also done here, like converting the datasets to the same type.\n",
" '''\n",
" if resource in ['tallgrass','denali']:\n",
" location = 'onprem'\n",
" \n",
" elif resource in ['esip-qhub-gateway-v0.4']:\n",
" location = 'cloud'\n",
"\n",
" url = 'https://raw.githubusercontent.com/USGS-python/hytest-catalogs/main/hytest_intake_catalog.yml'\n",
" cat = intake.open_catalog(url)\n",
"\n",
" observations_ds = cat[f'nwis-streamflow-usgs-gages-{location}'].to_dask()\n",
" model_ds = cat[f'nwm21-streamflow-usgs-gages-{location}'].to_dask()\n",
" \n",
" observations = observations_ds['streamflow']\n",
" model = model_ds['streamflow'].astype('float32')\n",
"\n",
" observations.name = 'observed'\n",
" model.name = 'predicted'\n",
" \n",
" return observations, model"
]
},
{
"cell_type": "markdown",
"id": "a95c773a-9ec3-42b5-8d1b-66d0b9735181",
"metadata": {},
"source": [
"Let's demo that helper, and show how to select data for a single streamgage."
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "83bed5fb-6f3f-408f-be98-abc0f29665cf",
"metadata": {},
"outputs": [],
"source": [
"obs, pred = load_streamflow_data(resource)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "663ce1de-7b05-4afb-87a1-334ef2b22689",
"metadata": {},
"outputs": [],
"source": [
"#obs"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "92c7625e-d67c-41bc-9c2e-271542546135",
"metadata": {},
"outputs": [],
"source": [
"#pred"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "9550137d-e140-4ce7-b101-9eaeaa7cc13d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 11.8 ms, sys: 443 µs, total: 12.2 ms\n",
"Wall time: 12.7 ms\n"
]
},
{
"data": {
"text/plain": [
"time\n",
"2020-12-27 05:00:00 4.643963\n",
"2020-12-28 05:00:00 3.596240\n",
"2020-12-29 05:00:00 2.831685\n",
"2020-12-30 05:00:00 2.392774\n",
"2020-12-31 05:00:00 2.092615\n",
"Name: observed, dtype: float32"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"%%time\n",
"# time it takes to read a single gage\n",
"gage_id = 'USGS-01030350'\n",
"obs.sel(gage_id=gage_id).load(scheduler='threads').to_series().tail()"
]
},
{
"cell_type": "markdown",
"id": "d8b8921f-5b2c-43fc-a3d7-98ba79972421",
"metadata": {},
"source": [
"### 1.1 Load benchmark locations\n",
"Each benchmark is defined over a specific domain (typically bounded in space and time, with the two related in some aspects). Benchmark spatiotemporal domains are published to ScienceBase within the [HyTEST directory](https://www.sciencebase.gov/catalog/item/61dd751ed34ed7929401a4bd), or they can be defined within the notebook if a user chooses. For this example, we use the Cobalt gages, avaliable for download on ScienceBase ([Foks et al., 2022](https://doi.org/10.5066/P972P42Z))."
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "4b33e0ed-cbd2-4fa1-8213-c27314de6c91",
"metadata": {},
"outputs": [],
"source": [
"import fsspec\n",
"#fs = fsspec.filesystem('https', anon=True)\n",
"url = 'https://raw.githubusercontent.com/USGS-python/hytest-evaluation-workflows/main/misc/streamflow_gages_v1_n5390.csv'\n",
"benchmark_ds = pd.read_csv(url, dtype={'site_no':str, 'huc_cd':str, 'reachcode':str, 'comid':str, 'gagesII_class':str, 'aggecoregion': str}).set_index('site_no').to_xarray()"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "b9370c57-51de-4361-855b-874dfc7c2838",
"metadata": {},
"outputs": [],
"source": [
"# Format the site_no\n",
"benchmark_ds['site_no'] = [f'USGS-{site}' for site in benchmark_ds['site_no'].values]\n",
"benchmark_gages = benchmark_ds['site_no'].values.tolist()"
]
},
{
"cell_type": "markdown",
"id": "14c78ae4-9da7-4461-aa30-2a2c68e67dc7",
"metadata": {},
"source": [
"### 1.2. Load statistical metrics\n",
"This demo computes a benchmark for the National Water Model (NWM) Retrospective version 2.1 using a suite of traditional metrics (referred to as the \"standard statistical suite version 1.0\"). In practice these may be loaded from external libraries. Ideally, the future version of this notebook would be configured to load a specific version of that library, which would be used to uniquely identify the benchmark to run. Additionally, future specific metrics packages could be loaded with `httpimport`. \n",
"\n",
"Below is the definition of the version 1.0 standard statistical suite (10 metrics total; Towler et al., in draft) that is calculated in this notebook, with references.\n",
"\n",
"| Metric | Reference |\n",
"| :----------- | :----------- |\n",
"| Nash-Sutcliffe efficiency (NSE) | Nash, J. E., & Sutcliffe, J. V. (1970). River flow forecasting through conceptual models part I—A discussion of principles. Journal of hydrology, 10(3), 282-290. |\n",
"| Kling-Gupta efficiency (KGE) | Gupta, H. V., Kling, H., Yilmaz, K. K., & Martinez, G. F. (2009). Decomposition of the mean squared error and NSE performance criteria: Implications for improving hydrological modelling. Journal of hydrology, 377(1-2), 80-91. |\n",
"| logNSE | Oudin, L., Andréassian, V., Mathevet, T., Perrin, C., & Michel, C. (2006). Dynamic averaging of rainfall‐runoff model simulations from complementary model parameterizations. Water Resources Research, 42(7). |\n",
"| percent bias | a measure of the mean tendency of simulated values to be greater or less than associated observed values, units of percent |\n",
"| ratio of standard deviation |standard deviation of simulated values divided by the standard deviation of observed values|\n",
"| Pearson Correlation | K. Pearson (1896, 1900, 1920) |\n",
"|Spearman Correlation | Charles Spearman (1904, 1910) |\n",
"|percent bias in midsegment slope of the flow-duration curve (FDC) between Q20-Q70 | Yilmaz, K. K., Gupta, H. V., & Wagener, T. (2008). A process‐based diagnostic approach to model evaluation: Application to the NWS distributed hydrologic model. Water Resources Research, 44(9). |\n",
"|percent bias in FDC low-segment volume (Q0-Q30)| Yilmaz, K. K., Gupta, H. V., & Wagener, T. (2008). A process‐based diagnostic approach to model evaluation: Application to the NWS distributed hydrologic model. Water Resources Research, 44(9). |\n",
"|percent bias in FDC high-segment volume (Q98-Q100) | Yilmaz, K. K., Gupta, H. V., & Wagener, T. (2008). A process‐based diagnostic approach to model evaluation: Application to the NWS distributed hydrologic model. Water Resources Research, 44(9). | "
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "d10b4efb-5e1f-4734-a4bf-c4acce45d62d",
"metadata": {},
"outputs": [],
"source": [
"'''\n",
"Global variance of observed data: dscore scorecard development\n",
"'''\n",
"def mse(obs):\n",
" \"\"\"\n",
" Calculate the global variance\n",
" \n",
" Args:\n",
" obs: numpy array of observed values\n",
" Returns:\n",
" variance\n",
" \"\"\"\n",
" return np.mean((obs - mod) ** 2)"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "62327185-50a2-4fa6-bdd1-5a876c918001",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"'''\n",
"A selection of traditional/standard statistical suite of metrics\n",
"'''\n",
"\n",
"import numpy as np\n",
"\n",
"def mse(obs, mod):\n",
" \"\"\"\n",
" Calculate the mean squared error (MSE)\n",
" \n",
" Args:\n",
" obs: numpy array of observed values\n",
" mod: numpy array of modeled values\n",
" Returns:\n",
" mean squared error\n",
" \"\"\"\n",
" return np.mean((obs - mod) ** 2)\n",
"\n",
"\n",
"def nse(obs, mod):\n",
" \"\"\"\n",
" Calculate the Nash-Sutcliffe Efficiency (NSE)\n",
" (https://www.sciencedirect.com/science/article/pii/0022169470902556?via%3Dihub)\n",
" \n",
" Args:\n",
" obs: numpy array of observed values\n",
" mod: numpy array of modeled values\n",
" Returns:\n",
" Nash-Sutcliffe Efficiency\n",
" \"\"\"\n",
" return 1 - (mse(obs, mod) / np.var(obs))\n",
"\n",
"\n",
"def pbias(obs, mod):\n",
" \"\"\"\n",
" Calculate the percent bias\n",
" \n",
" Args:\n",
" obs: numpy array of observed values\n",
" mod: numpy array of modeled values\n",
" Returns:\n",
" Percent bias\n",
" \"\"\"\n",
" return 100 * ((np.sum(mod - obs)) / (np.sum(obs)))\n",
"\n",
"\n",
"def pbias_percentile(obs, model, percentile, fun):\n",
" \"\"\"\n",
" Calculate the percent bias for a percentile bin\n",
" \n",
" Args:\n",
" obs: numpy array of observed values\n",
" mod: numpy array of modeled values\n",
" percentile: float\n",
" fun: comparison function (e.g., np.greater)\n",
" Returns:\n",
" Percent bias for bin\n",
" \"\"\"\n",
" threshold = np.percentile(obs, q=percentile)\n",
" i = fun(obs, threshold)\n",
" \n",
" return pbias(obs[i], model[i])\n",
" \n",
"\n",
"def pearson_r(obs, mod):\n",
" \"\"\"\n",
" Calculate Pearson's r\n",
" \n",
" Args:\n",
" obs: numpy array of observed values\n",
" mod: numpy array of modeled values\n",
" Returns:\n",
" Pearson's r\n",
" \"\"\"\n",
" #return np.cov(mod, obs) / np.sqrt( np.var(mod) * np.var(obs))\n",
" return np.corrcoef(mod, obs)[0,1]\n",
"\n",
"\n",
"def spearman_r(obs, mod):\n",
" \"\"\"\n",
" Calculate Spearman's r\n",
" \n",
" Args:\n",
" obs: numpy array of observed values\n",
" mod: numpy array of modeled values\n",
" Returns:\n",
" Spearman's r\n",
" \"\"\"\n",
" return pearson_r(np.argsort(mod), np.argsort(obs))\n",
"\n",
"\n",
"def kge(obs, mod):\n",
" \"\"\"\n",
" Calculate the Kling-Gupta Efficiency (KGE)\n",
" (https://www.sciencedirect.com/science/article/pii/S0022169409004843)\n",
" \n",
" Args:\n",
" obs: numpy array of observed values\n",
" mod: numpy array of modeled values\n",
" Returns:\n",
" Kling-Gupta Efficiency\n",
" \"\"\"\n",
" r = pearson_r(obs, mod)\n",
" alpha = sd_ratio(obs, mod)\n",
" beta = np.sum(mod) / np.sum(obs)\n",
" return 1 - np.sqrt((r-1)**2 + (alpha-1)**2 + (beta-1)**2)\n",
"\n",
"\n",
"def sd_ratio(obs, mod):\n",
" \"\"\"\n",
" Calculate the standard deviation ratio of the model predictions and observations\n",
" \n",
" Args:\n",
" obs: numpy array of observed values\n",
" mod: numpy array of modeled values\n",
" Returns:\n",
" Standard deviation ratio \n",
" \"\"\"\n",
" return np.std(mod) / np.std(obs)"
]
},
{
"cell_type": "markdown",
"id": "3b833ef3-e284-48db-be43-eb5d96840ed9",
"metadata": {},
"source": [
"### 1.3 Define benchmark function\n",
"For each streamgage, we will compute a series of performance metrics, and the results from streamgage will be appended into a single dataframe, with one row per gage and one column for metric. To paralleize this task, we create the helper function `compute_benchmark()`, which computes the benchmark for a particular streamgage. In parallel, each worker in the cluster is assigned a gage, loads the data for that gage, computes the benchmark, and all the results are gathered. In this example, the `compute_benchmark()` function converts the data to a `pandas.Series`, resamples the model and observation data to the same timeseries, then computes a series of metrics from the resampled data. Each metric is stored as an entry in another `pandas.Series` named scores, which is returned by `compute_benchmark()` upon completion."
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "455a39bd-c0fe-417a-be73-10299e7bac4b",
"metadata": {},
"outputs": [],
"source": [
"def compute_benchmark(gage_id, observations, predictions):\n",
" obs1 = observations.sel(gage_id=gage_id).load(scheduler='single-threaded').to_series()\n",
" mod1 = predictions.sel(gage_id=gage_id).load(scheduler='single-threaded').to_series().resample('1D', offset='5h').mean() # Resampling could be done in preanalysis\n",
" \n",
" # make sure the indices match\n",
" obs1.index = obs1.index.to_period('D')\n",
" mod1.index = mod1.index.to_period('D')\n",
"\n",
" # merge obs and predictions and drop nans.\n",
" df = pd.merge(obs1, mod1, left_index=True, right_index=True).dropna(how='any')\n",
" obs1 = df['observed']\n",
" mod1 = df['predicted']\n",
" \n",
" # compute log flow for use in log NSE\n",
" threshold = 0.01\n",
" log_obs = np.log(obs1.where(obs1 > threshold, threshold))\n",
" log_model = np.log(mod1.where(mod1 > threshold, threshold))\n",
" \n",
" scores = pd.Series(dtype='float')\n",
" scores['nse'] = nse(obs1, mod1)\n",
" scores['log_nse'] = nse(log_obs, log_model)\n",
" scores['kge'] = kge(obs1, mod1)\n",
" \n",
" scores['pbias'] = pbias(obs1, mod1)\n",
" scores['pearson_r'] = pearson_r(obs1, mod1)\n",
" scores['spearman_r'] = spearman_r(obs1, mod1)\n",
" scores['sd_ratio'] = sd_ratio(obs1, mod1)\n",
" \n",
" # compute high flow and low flow bias (Yilmaz et al., 2008)\n",
" # Yilmaz, K. K., Gupta, H. V., & Wagener, T. (2008). \n",
" # A process‐based diagnostic approach to model evaluation: \n",
" # Application to the NWS distributed hydrologic model. \n",
" # Water Resources Research, 44(9).\n",
" high_percentile = 98\n",
" low_percentile = 30\n",
" \n",
" scores['pbias_q' + str(high_percentile)] = pbias_percentile(obs1, mod1, high_percentile, np.greater)\n",
" scores['pbias_q' + str(low_percentile)] = pbias_percentile(obs1, mod1, high_percentile, np.less_equal)\n",
" scores.name = gage_id\n",
" \n",
" #compute slope of the FDC curve (Yilmaz et al 2008)\n",
" # Yilmaz, K. K., Gupta, H. V., & Wagener, T. (2008). \n",
" # A process‐based diagnostic approach to model evaluation: \n",
" # Application to the NWS distributed hydrologic model. \n",
" # Water Resources Research, 44(9).\n",
" \n",
" return scores"
]
},
{
"cell_type": "markdown",
"id": "c0c9c760-d1eb-45f6-b191-ca13452515dd",
"metadata": {},
"source": [
"Run `compute_metrics()` and verify the output:"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "b9654f30-6839-48e1-8062-5817868766d1",
"metadata": {},
"outputs": [],
"source": [
"mod, obs = load_streamflow_data(resource)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "9fc67d14-ada2-444a-a6e7-09d973a1656f",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 97.6 ms, sys: 10.7 ms, total: 108 ms\n",
"Wall time: 110 ms\n"
]
},
{
"data": {
"text/plain": [
"nse 0.620564\n",
"log_nse 0.443106\n",
"kge 0.601091\n",
"pbias -12.807119\n",
"pearson_r 0.802874\n",
"spearman_r 0.009456\n",
"sd_ratio 0.677715\n",
"pbias_q98 -40.548834\n",
"pbias_q30 -7.946478\n",
"Name: USGS-01030350, dtype: float64"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"%%time\n",
"# run for a single site using 1 core\n",
"gage_id = 'USGS-01030350'\n",
"compute_benchmark(gage_id, obs, mod)"
]
},
{
"cell_type": "markdown",
"id": "96c10666-9dc3-44e7-b6e7-08e63a43545a",
"metadata": {},
"source": [
"## 2. Compute benchmark results"
]
},
{
"cell_type": "markdown",
"id": "5b63c23c-2cd8-42c2-8125-595567b26e66",
"metadata": {},
"source": [
"We will define one final function, that wraps `compute_benchmark()` in a `try` statement. That way, if an error occurs at a particular streamgage, the other streamgages will be unaffected. \n",
"\n",
"WARNING: While developing your code, we recommend against sequestering errors inside a `try`, because error messages are extremely useful when debugging code."
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "04d2e8df-dfab-4af6-873d-805c29dfe026",
"metadata": {},
"outputs": [],
"source": [
"def try_compute_benchmark(gage_id):\n",
" \"\"\"Wrapper function\n",
" \"\"\"\n",
" try:\n",
" return compute_benchmark(gage_id, obs, mod)\n",
" except:\n",
" return None"
]
},
{
"cell_type": "markdown",
"id": "906e5bd6-2065-4980-9bb2-4e899c94b820",
"metadata": {},
"source": [
"### 2.0 Setup cluster\n",
"Using our helper function, we can setup our analysis in two lines."
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "20c53cc2-5369-44f5-b101-200e4a5c3b46",
"metadata": {},
"outputs": [],
"source": [
"client, cluster = configure_cluster(resource)\n",
"mod, obs = load_streamflow_data(resource)"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "a7d78ab3-8a4d-41bf-83c8-5bc08876824d",
"metadata": {},
"outputs": [],
"source": [
"#cluster.scale(20)"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "2fbfb795-f152-41db-b507-1672e428f4bf",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
" <div style=\"width: 24px; height: 24px; background-color: #e1e1e1; border: 3px solid #9D9D9D; border-radius: 5px; position: absolute;\"> </div>\n",
" <div style=\"margin-left: 48px;\">\n",
" <h3 style=\"margin-bottom: 0px;\">Client</h3>\n",
" <p style=\"color: #9D9D9D; margin-bottom: 0px;\">Client-41d7e10d-f189-11ec-b282-a4bf014516d6</p>\n",
" <table style=\"width: 100%; text-align: left;\">\n",
"\n",
" <tr>\n",
" \n",
" <td style=\"text-align: left;\"><strong>Connection method:</strong> Cluster object</td>\n",
" <td style=\"text-align: left;\"><strong>Cluster type:</strong> dask_jobqueue.SLURMCluster</td>\n",
" \n",
" </tr>\n",
"\n",
" \n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Dashboard: </strong> <a href=\"/proxy/8787/status\" target=\"_blank\">/proxy/8787/status</a>\n",
" </td>\n",
" <td style=\"text-align: left;\"></td>\n",
" </tr>\n",
" \n",
"\n",
" </table>\n",
"\n",
" \n",
" <details>\n",
" <summary style=\"margin-bottom: 20px;\"><h3 style=\"display: inline;\">Cluster Info</h3></summary>\n",
" <div class=\"jp-RenderedHTMLCommon jp-RenderedHTML jp-mod-trusted jp-OutputArea-output\">\n",
" <div style=\"width: 24px; height: 24px; background-color: #e1e1e1; border: 3px solid #9D9D9D; border-radius: 5px; position: absolute;\">\n",
" </div>\n",
" <div style=\"margin-left: 48px;\">\n",
" <h3 style=\"margin-bottom: 0px; margin-top: 0px;\">SLURMCluster</h3>\n",
" <p style=\"color: #9D9D9D; margin-bottom: 0px;\">2308d24b</p>\n",
" <table style=\"width: 100%; text-align: left;\">\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Dashboard:</strong> <a href=\"/proxy/8787/status\" target=\"_blank\">/proxy/8787/status</a>\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Workers:</strong> 0\n",
" </td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Total threads:</strong> 0\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Total memory:</strong> 0 B\n",
" </td>\n",
" </tr>\n",
" \n",
" </table>\n",
"\n",
" <details>\n",
" <summary style=\"margin-bottom: 20px;\">\n",
" <h3 style=\"display: inline;\">Scheduler Info</h3>\n",
" </summary>\n",
"\n",
" <div style=\"\">\n",
" <div>\n",
" <div style=\"width: 24px; height: 24px; background-color: #FFF7E5; border: 3px solid #FF6132; border-radius: 5px; position: absolute;\"> </div>\n",
" <div style=\"margin-left: 48px;\">\n",
" <h3 style=\"margin-bottom: 0px;\">Scheduler</h3>\n",
" <p style=\"color: #9D9D9D; margin-bottom: 0px;\">Scheduler-a99f561c-dc86-4fc0-a63f-a70471c9129d</p>\n",
" <table style=\"width: 100%; text-align: left;\">\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Comm:</strong> tcp://172.22.0.5:39631\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Workers:</strong> 0\n",
" </td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Dashboard:</strong> <a href=\"/proxy/8787/status\" target=\"_blank\">/proxy/8787/status</a>\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Total threads:</strong> 0\n",
" </td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Started:</strong> Just now\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Total memory:</strong> 0 B\n",
" </td>\n",
" </tr>\n",
" </table>\n",
" </div>\n",
" </div>\n",
"\n",
" <details style=\"margin-left: 48px;\">\n",
" <summary style=\"margin-bottom: 20px;\">\n",
" <h3 style=\"display: inline;\">Workers</h3>\n",
" </summary>\n",
"\n",
" \n",
"\n",
" </details>\n",
"</div>\n",
"\n",
" </details>\n",
" </div>\n",
"</div>\n",
" </details>\n",
" \n",
"\n",
" </div>\n",
"</div>"
],
"text/plain": [
"<Client: 'tcp://172.22.0.5:39631' processes=0 threads=0, memory=0 B>"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"client"
]
},
{
"cell_type": "markdown",
"id": "69d168f9-4087-4567-8995-6111cca0c9b0",
"metadata": {},
"source": [
"### 2.1 Distribute with Dask bag - (applicable if on Cloud???)\n",
"Now to parallelize, we create a Dask bag from the list `benchmark_gages`, and pass `try_compute_benchmark` to each element in the bag."
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "9b0b820f-c1c0-4a95-a486-4e0ebdbc7b63",
"metadata": {},
"outputs": [],
"source": [
"b = db.from_sequence(benchmark_gages, npartitions=40)\n",
"b1 = b.map(try_compute_benchmark)"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "f6ca8d95-aeba-4592-8d9e-099b9034213f",
"metadata": {},
"outputs": [],
"source": [
"#b = db.from_sequence(urls[:90], npartitions=3)\n",
"#b1 = b.map(gen_json)"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "9b1dd87d-8020-493f-9479-40cd063da776",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 10.3 s, sys: 1.38 s, total: 11.7 s\n",
"Wall time: 1min 40s\n"
]
}
],
"source": [
"%%time\n",
"from dask.distributed import performance_report\n",
"with performance_report(filename=\"dask-report-whole.html\"):\n",
" results = b1.compute(retries=10)"
]
},
{
"cell_type": "markdown",
"id": "e839c494-65ab-4ed7-8c68-e548d9e1cd22",
"metadata": {},
"source": [
"Finally, concatenate the results from each gage into a single dataframe"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "43087ac2-278c-4c14-8ba5-811b941f0fc0",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div><svg style=\"position: absolute; width: 0; height: 0; overflow: hidden\">\n",
"<defs>\n",
"<symbol id=\"icon-database\" viewBox=\"0 0 32 32\">\n",
"<path d=\"M16 0c-8.837 0-16 2.239-16 5v4c0 2.761 7.163 5 16 5s16-2.239 16-5v-4c0-2.761-7.163-5-16-5z\"></path>\n",
"<path d=\"M16 17c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
"<path d=\"M16 26c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
"</symbol>\n",
"<symbol id=\"icon-file-text2\" viewBox=\"0 0 32 32\">\n",
"<path d=\"M28.681 7.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-15.5c-1.378 0-2.5 1.121-2.5 2.5v27c0 1.378 1.122 2.5 2.5 2.5h23c1.378 0 2.5-1.122 2.5-2.5v-19.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 5.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-23c-0.271 0-0.5-0.229-0.5-0.5v-27c0-0.271 0.229-0.5 0.5-0.5 0 0 15.499-0 15.5 0v7c0 0.552 0.448 1 1 1h7v19.5z\"></path>\n",
"<path d=\"M23 26h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"<path d=\"M23 22h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"<path d=\"M23 18h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
"</symbol>\n",
"</defs>\n",
"</svg>\n",
"<style>/* CSS stylesheet for displaying xarray objects in jupyterlab.\n",
" *\n",
" */\n",
"\n",
":root {\n",
" --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1));\n",
" --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54));\n",
" --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38));\n",
" --xr-border-color: var(--jp-border-color2, #e0e0e0);\n",
" --xr-disabled-color: var(--jp-layout-color3, #bdbdbd);\n",
" --xr-background-color: var(--jp-layout-color0, white);\n",
" --xr-background-color-row-even: var(--jp-layout-color1, white);\n",
" --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee);\n",
"}\n",
"\n",
"html[theme=dark],\n",
"body.vscode-dark {\n",
" --xr-font-color0: rgba(255, 255, 255, 1);\n",
" --xr-font-color2: rgba(255, 255, 255, 0.54);\n",
" --xr-font-color3: rgba(255, 255, 255, 0.38);\n",
" --xr-border-color: #1F1F1F;\n",
" --xr-disabled-color: #515151;\n",
" --xr-background-color: #111111;\n",
" --xr-background-color-row-even: #111111;\n",
" --xr-background-color-row-odd: #313131;\n",
"}\n",
"\n",
".xr-wrap {\n",
" display: block !important;\n",
" min-width: 300px;\n",
" max-width: 700px;\n",
"}\n",
"\n",
".xr-text-repr-fallback {\n",
" /* fallback to plain text repr when CSS is not injected (untrusted notebook) */\n",
" display: none;\n",
"}\n",
"\n",
".xr-header {\n",
" padding-top: 6px;\n",
" padding-bottom: 6px;\n",
" margin-bottom: 4px;\n",
" border-bottom: solid 1px var(--xr-border-color);\n",
"}\n",
"\n",
".xr-header > div,\n",
".xr-header > ul {\n",
" display: inline;\n",
" margin-top: 0;\n",
" margin-bottom: 0;\n",
"}\n",
"\n",
".xr-obj-type,\n",
".xr-array-name {\n",
" margin-left: 2px;\n",
" margin-right: 10px;\n",
"}\n",
"\n",
".xr-obj-type {\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-sections {\n",
" padding-left: 0 !important;\n",
" display: grid;\n",
" grid-template-columns: 150px auto auto 1fr 20px 20px;\n",
"}\n",
"\n",
".xr-section-item {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-section-item input {\n",
" display: none;\n",
"}\n",
"\n",
".xr-section-item input + label {\n",
" color: var(--xr-disabled-color);\n",
"}\n",
"\n",
".xr-section-item input:enabled + label {\n",
" cursor: pointer;\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-section-item input:enabled + label:hover {\n",
" color: var(--xr-font-color0);\n",
"}\n",
"\n",
".xr-section-summary {\n",
" grid-column: 1;\n",
" color: var(--xr-font-color2);\n",
" font-weight: 500;\n",
"}\n",
"\n",
".xr-section-summary > span {\n",
" display: inline-block;\n",
" padding-left: 0.5em;\n",
"}\n",
"\n",
".xr-section-summary-in:disabled + label {\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-section-summary-in + label:before {\n",
" display: inline-block;\n",
" content: '►';\n",
" font-size: 11px;\n",
" width: 15px;\n",
" text-align: center;\n",
"}\n",
"\n",
".xr-section-summary-in:disabled + label:before {\n",
" color: var(--xr-disabled-color);\n",
"}\n",
"\n",
".xr-section-summary-in:checked + label:before {\n",
" content: '▼';\n",
"}\n",
"\n",
".xr-section-summary-in:checked + label > span {\n",
" display: none;\n",
"}\n",
"\n",
".xr-section-summary,\n",
".xr-section-inline-details {\n",
" padding-top: 4px;\n",
" padding-bottom: 4px;\n",
"}\n",
"\n",
".xr-section-inline-details {\n",
" grid-column: 2 / -1;\n",
"}\n",
"\n",
".xr-section-details {\n",
" display: none;\n",
" grid-column: 1 / -1;\n",
" margin-bottom: 5px;\n",
"}\n",
"\n",
".xr-section-summary-in:checked ~ .xr-section-details {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-array-wrap {\n",
" grid-column: 1 / -1;\n",
" display: grid;\n",
" grid-template-columns: 20px auto;\n",
"}\n",
"\n",
".xr-array-wrap > label {\n",
" grid-column: 1;\n",
" vertical-align: top;\n",
"}\n",
"\n",
".xr-preview {\n",
" color: var(--xr-font-color3);\n",
"}\n",
"\n",
".xr-array-preview,\n",
".xr-array-data {\n",
" padding: 0 5px !important;\n",
" grid-column: 2;\n",
"}\n",
"\n",
".xr-array-data,\n",
".xr-array-in:checked ~ .xr-array-preview {\n",
" display: none;\n",
"}\n",
"\n",
".xr-array-in:checked ~ .xr-array-data,\n",
".xr-array-preview {\n",
" display: inline-block;\n",
"}\n",
"\n",
".xr-dim-list {\n",
" display: inline-block !important;\n",
" list-style: none;\n",
" padding: 0 !important;\n",
" margin: 0;\n",
"}\n",
"\n",
".xr-dim-list li {\n",
" display: inline-block;\n",
" padding: 0;\n",
" margin: 0;\n",
"}\n",
"\n",
".xr-dim-list:before {\n",
" content: '(';\n",
"}\n",
"\n",
".xr-dim-list:after {\n",
" content: ')';\n",
"}\n",
"\n",
".xr-dim-list li:not(:last-child):after {\n",
" content: ',';\n",
" padding-right: 5px;\n",
"}\n",
"\n",
".xr-has-index {\n",
" font-weight: bold;\n",
"}\n",
"\n",
".xr-var-list,\n",
".xr-var-item {\n",
" display: contents;\n",
"}\n",
"\n",
".xr-var-item > div,\n",
".xr-var-item label,\n",
".xr-var-item > .xr-var-name span {\n",
" background-color: var(--xr-background-color-row-even);\n",
" margin-bottom: 0;\n",
"}\n",
"\n",
".xr-var-item > .xr-var-name:hover span {\n",
" padding-right: 5px;\n",
"}\n",
"\n",
".xr-var-list > li:nth-child(odd) > div,\n",
".xr-var-list > li:nth-child(odd) > label,\n",
".xr-var-list > li:nth-child(odd) > .xr-var-name span {\n",
" background-color: var(--xr-background-color-row-odd);\n",
"}\n",
"\n",
".xr-var-name {\n",
" grid-column: 1;\n",
"}\n",
"\n",
".xr-var-dims {\n",
" grid-column: 2;\n",
"}\n",
"\n",
".xr-var-dtype {\n",
" grid-column: 3;\n",
" text-align: right;\n",
" color: var(--xr-font-color2);\n",
"}\n",
"\n",
".xr-var-preview {\n",
" grid-column: 4;\n",
"}\n",
"\n",
".xr-var-name,\n",
".xr-var-dims,\n",
".xr-var-dtype,\n",
".xr-preview,\n",
".xr-attrs dt {\n",
" white-space: nowrap;\n",
" overflow: hidden;\n",
" text-overflow: ellipsis;\n",
" padding-right: 10px;\n",
"}\n",
"\n",
".xr-var-name:hover,\n",
".xr-var-dims:hover,\n",
".xr-var-dtype:hover,\n",
".xr-attrs dt:hover {\n",
" overflow: visible;\n",
" width: auto;\n",
" z-index: 1;\n",
"}\n",
"\n",
".xr-var-attrs,\n",
".xr-var-data {\n",
" display: none;\n",
" background-color: var(--xr-background-color) !important;\n",
" padding-bottom: 5px !important;\n",
"}\n",
"\n",
".xr-var-attrs-in:checked ~ .xr-var-attrs,\n",
".xr-var-data-in:checked ~ .xr-var-data {\n",
" display: block;\n",
"}\n",
"\n",
".xr-var-data > table {\n",
" float: right;\n",
"}\n",
"\n",
".xr-var-name span,\n",
".xr-var-data,\n",
".xr-attrs {\n",
" padding-left: 25px !important;\n",
"}\n",
"\n",
".xr-attrs,\n",
".xr-var-attrs,\n",
".xr-var-data {\n",
" grid-column: 1 / -1;\n",
"}\n",
"\n",
"dl.xr-attrs {\n",
" padding: 0;\n",
" margin: 0;\n",
" display: grid;\n",
" grid-template-columns: 125px auto;\n",
"}\n",
"\n",
".xr-attrs dt,\n",
".xr-attrs dd {\n",
" padding: 0;\n",
" margin: 0;\n",
" float: left;\n",
" padding-right: 10px;\n",
" width: auto;\n",
"}\n",
"\n",
".xr-attrs dt {\n",
" font-weight: normal;\n",
" grid-column: 1;\n",
"}\n",
"\n",
".xr-attrs dt:hover span {\n",
" display: inline-block;\n",
" background: var(--xr-background-color);\n",
" padding-right: 10px;\n",
"}\n",
"\n",
".xr-attrs dd {\n",
" grid-column: 2;\n",
" white-space: pre-wrap;\n",
" word-break: break-all;\n",
"}\n",
"\n",
".xr-icon-database,\n",
".xr-icon-file-text2 {\n",
" display: inline-block;\n",
" vertical-align: middle;\n",
" width: 1em;\n",
" height: 1.5em !important;\n",
" stroke-width: 0;\n",
" stroke: currentColor;\n",
" fill: currentColor;\n",
"}\n",
"</style><pre class='xr-text-repr-fallback'>&lt;xarray.Dataset&gt;\n",
"Dimensions: (site_no: 5380)\n",
"Coordinates:\n",
" * site_no (site_no) object &#x27;USGS-01011000&#x27; ... &#x27;USGS-14400000&#x27;\n",
"Data variables:\n",
" nse (site_no) float64 0.6618 0.6257 0.6696 ... -1.795 0.442 0.7033\n",
" log_nse (site_no) float64 0.5815 0.7559 0.7477 ... -0.5326 0.8938 0.8817\n",
" kge (site_no) float64 0.6597 0.484 0.6578 ... -0.3789 0.5696 0.749\n",
" pbias (site_no) float64 -19.73 -22.89 -13.78 ... 97.32 15.17 -16.55\n",
" pearson_r (site_no) float64 0.8281 0.8747 0.8288 ... 0.5062 0.8506 0.8457\n",
" spearman_r (site_no) float64 0.008246 0.01449 ... 0.003048 -0.001196\n",
" sd_ratio (site_no) float64 0.7825 0.5548 0.7378 ... 1.843 1.374 0.8915\n",
" pbias_q98 (site_no) float64 -38.03 -51.44 -41.74 ... 7.288 17.9 -24.9\n",
" pbias_q30 (site_no) float64 -16.51 -18.83 -8.429 ... 121.0 14.53 -14.71</pre><div class='xr-wrap' style='display:none'><div class='xr-header'><div class='xr-obj-type'>xarray.Dataset</div></div><ul class='xr-sections'><li class='xr-section-item'><input id='section-60c90011-f3de-491f-99b3-fdc8a2432d86' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-60c90011-f3de-491f-99b3-fdc8a2432d86' class='xr-section-summary' title='Expand/collapse section'>Dimensions:</label><div class='xr-section-inline-details'><ul class='xr-dim-list'><li><span class='xr-has-index'>site_no</span>: 5380</li></ul></div><div class='xr-section-details'></div></li><li class='xr-section-item'><input id='section-7821fba2-1028-4e86-ad22-a63a947ef95c' class='xr-section-summary-in' type='checkbox' checked><label for='section-7821fba2-1028-4e86-ad22-a63a947ef95c' class='xr-section-summary' >Coordinates: <span>(1)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>site_no</span></div><div class='xr-var-dims'>(site_no)</div><div class='xr-var-dtype'>object</div><div class='xr-var-preview xr-preview'>&#x27;USGS-01011000&#x27; ... &#x27;USGS-14400000&#x27;</div><input id='attrs-c5b327a3-1061-46db-9ab4-308a05500f79' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-c5b327a3-1061-46db-9ab4-308a05500f79' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-b212ddf6-6e3f-4437-8e22-7beb7eaa52a1' class='xr-var-data-in' type='checkbox'><label for='data-b212ddf6-6e3f-4437-8e22-7beb7eaa52a1' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([&#x27;USGS-01011000&#x27;, &#x27;USGS-01013500&#x27;, &#x27;USGS-01015800&#x27;, ..., &#x27;USGS-14375100&#x27;,\n",
" &#x27;USGS-14377100&#x27;, &#x27;USGS-14400000&#x27;], dtype=object)</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-d9bdf0e9-81c3-4c80-8423-c2854a7246d6' class='xr-section-summary-in' type='checkbox' checked><label for='section-d9bdf0e9-81c3-4c80-8423-c2854a7246d6' class='xr-section-summary' >Data variables: <span>(9)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span>nse</span></div><div class='xr-var-dims'>(site_no)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>0.6618 0.6257 ... 0.442 0.7033</div><input id='attrs-ae2cff9f-d96d-4f07-b966-8c3982bba7e8' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-ae2cff9f-d96d-4f07-b966-8c3982bba7e8' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-f57d8c96-7776-49a4-b38a-6c40f917a28e' class='xr-var-data-in' type='checkbox'><label for='data-f57d8c96-7776-49a4-b38a-6c40f917a28e' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([ 0.66178277, 0.62569496, 0.66957918, ..., -1.79528367,\n",
" 0.44204189, 0.70329129])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>log_nse</span></div><div class='xr-var-dims'>(site_no)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>0.5815 0.7559 ... 0.8938 0.8817</div><input id='attrs-bd6ad3ae-a1e1-4da1-8fc3-39e8f97cd246' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-bd6ad3ae-a1e1-4da1-8fc3-39e8f97cd246' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-27cb8de6-301a-4a19-b583-f6803dd41b8a' class='xr-var-data-in' type='checkbox'><label for='data-27cb8de6-301a-4a19-b583-f6803dd41b8a' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([ 0.58152122, 0.7559449 , 0.74767238, ..., -0.53264478,\n",
" 0.89379175, 0.88165758])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>kge</span></div><div class='xr-var-dims'>(site_no)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>0.6597 0.484 ... 0.5696 0.749</div><input id='attrs-1f89070c-0ff2-4a6e-99b5-9118e2dead8f' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-1f89070c-0ff2-4a6e-99b5-9118e2dead8f' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-07174b8a-504d-4379-a485-a2e932217c5d' class='xr-var-data-in' type='checkbox'><label for='data-07174b8a-504d-4379-a485-a2e932217c5d' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([ 0.65974703, 0.48396325, 0.65783821, ..., -0.37890246,\n",
" 0.56960112, 0.74904792])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>pbias</span></div><div class='xr-var-dims'>(site_no)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>-19.73 -22.89 ... 15.17 -16.55</div><input id='attrs-b11ac0e9-9958-440e-9ed2-61895f03855b' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-b11ac0e9-9958-440e-9ed2-61895f03855b' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-82221172-1b2e-4ade-a8e1-3c3c742a007f' class='xr-var-data-in' type='checkbox'><label for='data-82221172-1b2e-4ade-a8e1-3c3c742a007f' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([-19.73418146, -22.88540006, -13.78096342, ..., 97.31692672,\n",
" 15.16975611, -16.5489614 ])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>pearson_r</span></div><div class='xr-var-dims'>(site_no)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>0.8281 0.8747 ... 0.8506 0.8457</div><input id='attrs-b11c27d7-cb7a-43df-8f96-2d0363f6f4d4' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-b11c27d7-cb7a-43df-8f96-2d0363f6f4d4' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-eaa00798-0298-448d-846d-d2b2bf748124' class='xr-var-data-in' type='checkbox'><label for='data-eaa00798-0298-448d-846d-d2b2bf748124' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([0.8281344 , 0.8746845 , 0.82875256, ..., 0.50618691, 0.85059877,\n",
" 0.8456936 ])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>spearman_r</span></div><div class='xr-var-dims'>(site_no)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>0.008246 0.01449 ... -0.001196</div><input id='attrs-78bb2564-d04b-4bd3-bafe-906fde12dbef' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-78bb2564-d04b-4bd3-bafe-906fde12dbef' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-85fbdf43-ca28-4515-977e-66671f6311a3' class='xr-var-data-in' type='checkbox'><label for='data-85fbdf43-ca28-4515-977e-66671f6311a3' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([ 0.00824647, 0.01448749, 0.01507141, ..., -0.00726967,\n",
" 0.0030484 , -0.00119604])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>sd_ratio</span></div><div class='xr-var-dims'>(site_no)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>0.7825 0.5548 ... 1.374 0.8915</div><input id='attrs-4fa7fb63-6dea-4602-9b75-14e44dcd3ee3' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-4fa7fb63-6dea-4602-9b75-14e44dcd3ee3' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-d61276b5-95f2-4e47-8af9-0e5b2ddac793' class='xr-var-data-in' type='checkbox'><label for='data-d61276b5-95f2-4e47-8af9-0e5b2ddac793' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([0.78253645, 0.55478576, 0.7377835 , ..., 1.84288969, 1.37404585,\n",
" 0.891466 ])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>pbias_q98</span></div><div class='xr-var-dims'>(site_no)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>-38.03 -51.44 -41.74 ... 17.9 -24.9</div><input id='attrs-f1b9d5e4-a276-4a24-be24-1dc54174d5c6' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-f1b9d5e4-a276-4a24-be24-1dc54174d5c6' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-08c6a362-c96e-47bb-9711-998201f6f58f' class='xr-var-data-in' type='checkbox'><label for='data-08c6a362-c96e-47bb-9711-998201f6f58f' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([-38.02942634, -51.43586993, -41.74281955, ..., 7.2878398 ,\n",
" 17.89539456, -24.90196824])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>pbias_q30</span></div><div class='xr-var-dims'>(site_no)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>-16.51 -18.83 ... 14.53 -14.71</div><input id='attrs-94e9daeb-16c4-4838-b331-909eec1dba71' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-94e9daeb-16c4-4838-b331-909eec1dba71' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-ed1dc5fb-d4df-433c-953a-ead395b8b914' class='xr-var-data-in' type='checkbox'><label for='data-ed1dc5fb-d4df-433c-953a-ead395b8b914' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([-16.51117802, -18.8289389 , -8.42872858, ..., 121.0223794 ,\n",
" 14.52753693, -14.71243799])</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-18ac3a3b-7efb-427e-9e5a-b608c3014f72' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-18ac3a3b-7efb-427e-9e5a-b608c3014f72' class='xr-section-summary' title='Expand/collapse section'>Attributes: <span>(0)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'></dl></div></li></ul></div></div>"
],
"text/plain": [
"<xarray.Dataset>\n",
"Dimensions: (site_no: 5380)\n",
"Coordinates:\n",
" * site_no (site_no) object 'USGS-01011000' ... 'USGS-14400000'\n",
"Data variables:\n",
" nse (site_no) float64 0.6618 0.6257 0.6696 ... -1.795 0.442 0.7033\n",
" log_nse (site_no) float64 0.5815 0.7559 0.7477 ... -0.5326 0.8938 0.8817\n",
" kge (site_no) float64 0.6597 0.484 0.6578 ... -0.3789 0.5696 0.749\n",
" pbias (site_no) float64 -19.73 -22.89 -13.78 ... 97.32 15.17 -16.55\n",
" pearson_r (site_no) float64 0.8281 0.8747 0.8288 ... 0.5062 0.8506 0.8457\n",
" spearman_r (site_no) float64 0.008246 0.01449 ... 0.003048 -0.001196\n",
" sd_ratio (site_no) float64 0.7825 0.5548 0.7378 ... 1.843 1.374 0.8915\n",
" pbias_q98 (site_no) float64 -38.03 -51.44 -41.74 ... 7.288 17.9 -24.9\n",
" pbias_q30 (site_no) float64 -16.51 -18.83 -8.429 ... 121.0 14.53 -14.71"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"results = [i for i in results if i is not None] # Drop entries where compute_metrics failed\n",
"\n",
"df_results = pd.concat(results, axis=1)\n",
"df_results = df_results.T\n",
"df_results.index.name = 'site_no'\n",
"#df_results.index = df_results.index.astype('<U15')\n",
"ds_results = df_results.to_xarray()\n",
"ds_results"
]
},
{
"cell_type": "markdown",
"id": "9ad992e5-b1d6-4a78-8c9f-88f616124169",
"metadata": {},
"source": [
"### 2.2 Save results to disk\n",
"Save results to disk as a 'csv' file format, which can then be uploaded to USGS ScienceBase.\n",
"This file will save to your HOME directory if you are working in the HPC environment."
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "ba6d6984-2026-4321-8944-9f416d929513",
"metadata": {},
"outputs": [],
"source": [
"ds_results.to_dataframe().to_csv('nwm_v2.1_streamflow_benchmark_test.csv')"
]
},
{
"cell_type": "markdown",
"id": "adc15622-ef6e-41d1-8b26-f389b429f5dc",
"metadata": {},
"source": [
"Then as a NetCDF, which we will later use for visualization. Let's add latitude and longitude from the benchmark data before writing the results to NetCDF"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "86e90005-11a6-4804-b828-0c6f96b360bc",
"metadata": {},
"outputs": [],
"source": [
"ds_results.merge(benchmark_ds, join='inner').to_netcdf('nwm_v2.1_streamflow_benchmark_test.nc')"
]
},
{
"cell_type": "markdown",
"id": "6862ab3e-c624-462f-87ac-83f6cbdfd82d",
"metadata": {},
"source": [
"The end."
]
},
{
"cell_type": "code",
"execution_count": 29,
"id": "57b0e7ee-1b50-4110-a93c-7384b932c050",
"metadata": {},
"outputs": [],
"source": [
"client.close(); cluster.close()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python [conda env:pangeo] *",
"language": "python",
"name": "conda-env-pangeo-py"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment