{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Querying data from the USGS National Water Information System\n", "\n", "\n", "The USGS National Water Information System (NWIS) provides access to surface-water data at approximately 8,500 sites. The data are served online—most in near realtime—to meet many diverse needs. For additional information regarding NWIS, visit the [USGS website](https://waterdata.usgs.gov/nwis)." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from HydroGenerate.hydropower_potential import calculate_hp_potential\n", "import pandas as pd\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##### Use streamflow data from a USGS stream gauge. \n", "\n", "The USGS has a Python package (**_dataretrieval_**) designed to simplify the process of loading hydrologic data into the Python environment. **_dataretrieval_** can be pip installed into a Python environment. The example code shows how to donwload data using **_dataretrieval_** and format it for hydropower potential evaluation in **_HydroGenerate_**. The example used, and additional information, is avlaiable as a [HydroShare Resource](http://www.hydroshare.org/resource/c97c32ecf59b4dff90ef013030c54264). Information about **_dataretrieval_** is avaliable directly on the [USGS GitHUb Repository](https://github.com/DOI-USGS/dataretrieval-python)." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# Install dataretrieval, if it doesn't exist in Python environment, using: \n", "# !pip install dataretrieval" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# import data retrieval\n", "from dataretrieval import nwis" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "# Set the parameters needed to retrieve data\n", "siteNumber = \"10109000\" # LOGAN RIVER ABOVE STATE DAM, NEAR LOGAN, UT\n", "parameterCode = \"00060\" # Discharge\n", "startDate = \"2010-01-01\"\n", "endDate = \"2020-12-31\"\n", "\n", "# Retrieve the data\n", "dailyStreamflow = nwis.get_dv(sites=siteNumber, parameterCd=parameterCode, start=startDate, end=endDate) " ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | 00060_Mean | \n", "00060_Mean_cd | \n", "site_no | \n", "
---|---|---|---|
datetime | \n", "\n", " | \n", " | \n", " |
2010-01-01 00:00:00+00:00 | \n", "108.0 | \n", "A | \n", "10109000 | \n", "
2010-01-02 00:00:00+00:00 | \n", "107.0 | \n", "A | \n", "10109000 | \n", "
2010-01-03 00:00:00+00:00 | \n", "106.0 | \n", "A | \n", "10109000 | \n", "
2010-01-04 00:00:00+00:00 | \n", "102.0 | \n", "A | \n", "10109000 | \n", "
2010-01-05 00:00:00+00:00 | \n", "105.0 | \n", "A | \n", "10109000 | \n", "