{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Filter point observations to pre-defined site networks" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To launch this notebook interactively in a Jupyter notebook-like browser interface, please click the \"Launch Binder\" button below. Note that Binder may take several minutes to launch.\n", "\n", "[](https://mybinder.org/v2/gh/hydroframe/subsettools-binder/HEAD?labpath=hf_hydrodata/point/example_site_networks.ipynb)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This notebook showcases functionality of the `get_point_data` and `get_point_metadata` functions to filter sites based on a pre-defined site network. \n", "\n", "For USGS stream gages, the currently-supported set of site networks include:\n", "\n", " - [GAGESII](https://pubs.usgs.gov/publication/70046617) ('gagesii')\n", " - [GAGESII reference gages](https://pubs.usgs.gov/publication/70046617) ('gagesii_reference')\n", " - [HCDN-2009](https://water.usgs.gov/osw/hcdn-2009/) ('hcdn2009')\n", " - [CAMELS](https://ral.ucar.edu/solutions/products/camels) ('camels')\n", " - [NWM](https://essd.copernicus.org/articles/13/3263/2021/) ('nwm')\n", "\n", "For USGS groundwater wells, the currently-supported set of site networks include:\n", "\n", " - [Climate Response Network](https://water.usgs.gov/ogw/networks.html) ('climate_response_network')\n", "\n", "Please see the full [point module](https://hf-hydrodata.readthedocs.io) documentation for information on what data is available, our data collection process, and new features we are working on! Our [Metadata Description](https://hf-hydrodata.readthedocs.io/en/latest/available_metadata.html#point-observations-metadata) page itemizes the fields that get returned from `get_point_metadata`." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# Import packages\n", "from hf_hydrodata import register_api_pin, get_point_data, get_point_metadata\n", "import pandas as pd" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# You need to register on https://hydrogen.princeton.edu/pin \n", "# and run the following with your registered information\n", "# before you can use the hydrodata utilities\n", "register_api_pin(\"your_email\", \"your_pin\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note that `get_point_data` and `get_point_metadata` require mandatory parameters of `dataset`, `variable`, `temporal_resolution`, and `aggregation` (and `depth_level` if asking for soil moisture data). Please see [the documentation](https://hf-hydrodata.readthedocs.io/en/latest/available_data.html) for information about what point observation datasets are available and the parameters used to query them. \n", "\n", "The [hf_hydrodata API Reference](https://hf-hydrodata.readthedocs.io/en/latest/hf_hydrodata.point.html) includes information on what optional filtering parameters are available. These include filters for things like a geographic region or date range. Those parameters work cumulatively, so if `state` and `site_ids` are both supplied, for example, then only sites within `site_ids` that are *also* in `state` will be returned." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example: Query stream gage data for GAGES-II sites in Colorado" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In this example, we are interested in querying the stream gages that are part of the GAGES-II network within the state of Colorado (`state = 'CO'`). We'll focus on data within Water Year 2003, so we'll set `date_start='2002-10-01'` and `date_end='2003-09-30'`. Note that we are setting `site_networks='gagesii'` to get only stream gages that are part of the GAGES-II network." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | date | \n", "06614800 | \n", "06620000 | \n", "06659580 | \n", "06696980 | \n", "06700000 | \n", "06701500 | \n", "06701620 | \n", "06701900 | \n", "06707500 | \n", "... | \n", "09371000 | \n", "09371010 | \n", "09371492 | \n", "09371520 | \n", "09372000 | \n", "393109104464500 | \n", "394308105413800 | \n", "394839104570300 | \n", "401733105392404 | \n", "402114105350101 | \n", "
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", "2002-10-01 | \n", "0.019810 | \n", "0.97635 | \n", "NaN | \n", "0.116879 | \n", "NaN | \n", "8.4051 | \n", "NaN | \n", "9.5371 | \n", "11.3766 | \n", "... | \n", "0.000000 | \n", "14.1500 | \n", "0.023489 | \n", "0.46978 | \n", "0.274793 | \n", "0.048110 | \n", "0.61977 | \n", "1.26784 | \n", "0.071316 | \n", "0.33677 | \n", "
| 1 | \n", "2002-10-02 | \n", "0.021508 | \n", "1.01031 | \n", "NaN | \n", "0.148009 | \n", "NaN | \n", "8.3485 | \n", "NaN | \n", "9.8767 | \n", "12.1690 | \n", "... | \n", "0.066505 | \n", "15.6782 | \n", "0.040469 | \n", "0.53204 | \n", "0.285830 | \n", "0.281868 | \n", "0.81504 | \n", "2.81019 | \n", "0.071316 | \n", "0.39903 | \n", "
| 2 | \n", "2002-10-03 | \n", "0.022357 | \n", "1.23388 | \n", "NaN | \n", "0.164140 | \n", "NaN | \n", "7.1882 | \n", "NaN | \n", "8.5466 | \n", "10.2729 | \n", "... | \n", "0.155650 | \n", "19.1874 | \n", "0.091975 | \n", "1.10936 | \n", "0.472610 | \n", "0.249889 | \n", "0.88862 | \n", "1.23954 | \n", "0.069618 | \n", "0.46695 | \n", "
| 3 | \n", "2002-10-04 | \n", "0.025753 | \n", "1.81969 | \n", "NaN | \n", "0.146877 | \n", "NaN | \n", "5.3204 | \n", "NaN | \n", "5.9996 | \n", "8.2919 | \n", "... | \n", "0.350920 | \n", "19.6119 | \n", "0.043582 | \n", "0.50657 | \n", "0.894280 | \n", "0.219325 | \n", "0.70184 | \n", "0.68769 | \n", "0.068203 | \n", "0.43299 | \n", "
| 4 | \n", "2002-10-05 | \n", "0.024621 | \n", "1.98100 | \n", "NaN | \n", "0.143198 | \n", "NaN | \n", "4.4997 | \n", "NaN | \n", "5.0374 | \n", "6.5090 | \n", "... | \n", "0.060279 | \n", "22.7249 | \n", "0.026885 | \n", "0.47261 | \n", "0.585810 | \n", "0.191591 | \n", "0.64807 | \n", "0.47827 | \n", "0.066788 | \n", "0.43865 | \n", "
5 rows × 290 columns
\n", "| \n", " | site_id | \n", "site_name | \n", "site_type | \n", "agency | \n", "state | \n", "latitude | \n", "longitude | \n", "first_date_data_available | \n", "last_date_data_available | \n", "record_count | \n", "... | \n", "doi | \n", "huc8 | \n", "conus1_x | \n", "conus1_y | \n", "conus2_x | \n", "conus2_y | \n", "gagesii_drainage_area | \n", "gagesii_class | \n", "gagesii_site_elevation | \n", "usgs_drainage_area | \n", "
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", "06614800 | \n", "MICHIGAN RIVER NEAR CAMERON PASS, CO | \n", "stream gauge | \n", "USGS | \n", "CO | \n", "40.496094 | \n", "-105.865012 | \n", "1973-10-01 | \n", "2023-12-01 | \n", "18322 | \n", "... | \n", "None | \n", "10180001 | \n", "1054 | \n", "818 | \n", "1481 | \n", "1764 | \n", "4.02840 | \n", "Ref | \n", "3188.0 | \n", "1.54 | \n", "
| 1 | \n", "06620000 | \n", "NORTH PLATTE RIVER NEAR NORTHGATE, CO | \n", "stream gauge | \n", "USGS | \n", "CO | \n", "40.936639 | \n", "-106.339194 | \n", "1904-06-01 | \n", "2023-12-01 | \n", "39782 | \n", "... | \n", "None | \n", "10180001 | \n", "1020 | \n", "870 | \n", "1448 | \n", "1817 | \n", "3702.63700 | \n", "Non-ref | \n", "2388.0 | \n", "1431.00 | \n", "
| 2 | \n", "06659580 | \n", "SAND CREEK AT COLORADO-WYOMING STATE LINE | \n", "stream gauge | \n", "USGS | \n", "CO | \n", "40.993650 | \n", "-105.759703 | \n", "1968-10-01 | \n", "2020-09-01 | \n", "10075 | \n", "... | \n", "None | \n", "10180010 | \n", "nan | \n", "nan | \n", "1496 | \n", "1814 | \n", "79.11089 | \n", "Non-ref | \n", "2323.0 | \n", "29.20 | \n", "
| 3 | \n", "06696980 | \n", "TARRYALL CREEK AT UPPER STATION NEAR COMO, CO | \n", "stream gauge | \n", "USGS | \n", "CO | \n", "39.339433 | \n", "-105.911681 | \n", "1978-06-01 | \n", "2023-10-13 | \n", "5420 | \n", "... | \n", "None | \n", "10190001 | \n", "1036 | \n", "690 | \n", "1466 | \n", "1639 | \n", "61.90650 | \n", "Ref | \n", "3040.0 | \n", "23.90 | \n", "
| 4 | \n", "06700000 | \n", "SOUTH PLATTE RIVER ABOVE CHEESMAN LAKE, CO. | \n", "stream gauge | \n", "USGS | \n", "CO | \n", "39.162769 | \n", "-105.310273 | \n", "1924-10-01 | \n", "2023-09-30 | \n", "9523 | \n", "... | \n", "None | \n", "10190002 | \n", "nan | \n", "nan | \n", "1515 | \n", "1617 | \n", "4213.53800 | \n", "Non-ref | \n", "2092.0 | \n", "1627.00 | \n", "
5 rows × 23 columns
\n", "