{ "cells": [ { "cell_type": "markdown", "id": "b703ed1a-0f4e-459a-91e5-a287b2fc0c78", "metadata": {}, "source": [ "# Plot returned point data" ] }, { "cell_type": "markdown", "id": "34b48d99", "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_plot_data.ipynb)" ] }, { "cell_type": "markdown", "id": "9c743a1d-aaca-4bc9-9893-2cb10f380c47", "metadata": {}, "source": [ "This notebook provides some examples for how to use [matplotlib](https://matplotlib.org/stable/) to plot the data returned from hf_hydrodata's `get_point_data` function. \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, "id": "25b54786-6383-4bf7-aedc-6cea175c1b8a", "metadata": {}, "outputs": [], "source": [ "# Import packages\n", "from hf_hydrodata import register_api_pin, get_point_data, get_point_metadata\n", "from matplotlib import pyplot as plt\n", "import pandas as pd" ] }, { "cell_type": "code", "execution_count": null, "id": "0481473b-b6a9-4de6-8661-ab4dad5f5c33", "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", "id": "029f18cf-d33b-405d-b4aa-86d466005b3d", "metadata": {}, "source": [ "## Example 1: Plot data for a single site location for one Water Year" ] }, { "cell_type": "markdown", "id": "1f94706f-4ed3-45d0-99db-40fabec543f7", "metadata": {}, "source": [ "In this example, we are going to work with daily streamflow data. However all non-instantaneous data is returned in the same format so this code is transferrable to other types of data requests. " ] }, { "cell_type": "code", "execution_count": 2, "id": "5dd17d09-bcdf-41cf-8a6e-db39aaf04504", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | 01401000 | \n", "
|---|---|
| date | \n", "\n", " |
| 2021-10-01 | \n", "0.495250 | \n", "
| 2021-10-02 | \n", "0.345260 | \n", "
| 2021-10-03 | \n", "0.325450 | \n", "
| 2021-10-04 | \n", "0.316960 | \n", "
| 2021-10-05 | \n", "0.333940 | \n", "
| ... | \n", "... | \n", "
| 2022-09-26 | \n", "0.061694 | \n", "
| 2022-09-27 | \n", "0.049808 | \n", "
| 2022-09-28 | \n", "0.058864 | \n", "
| 2022-09-29 | \n", "0.050657 | \n", "
| 2022-09-30 | \n", "0.046129 | \n", "
365 rows × 1 columns
\n", "