This repository contains a Python script that retrieves and compares streamflow data from two sources:
- National Water Model (NWM)
- Retrieves v2.1 and v3 streamflow data directly from AWS using the Zarr format.
- USGS
- Retrieves real-time streamflow data using the USGS Water Services API.
The script plots the streamflow time series from these sources on a single graph, making it easy to visually compare the datasets.
Below is a sample output showing daily streamflow data at a specific location:
- Data Retrieval:
- Retrieves NWM data (v2.1 and v3) directly from AWS without downloading the entire dataset.
- USGS Integration:
- Converts USGS streamflow data from cubic feet per second (cfs) to cubic meters per second (cms).
- Time Series Alignment:
- Truncates datasets to ensure that all data series have the same length for consistent plotting.
- Visualization:
- Uses Matplotlib to produce a clear plot with daily tick intervals.
-
Clone the Repository:
git clone https://github.com/yourusername/streamflow-data-plotter.git cd streamflow-data-plotter -
Set Up a Virtual Environment (Optional but Recommended):
python3 -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install Dependencies:
pip install -r requirements.txt
Example
requirements.txt:xarray numpy s3fs matplotlib requests pandas
Run the script:
python streamflow_plotter.py