Graphical Tools for creating Next Gen Water model input data.
Project description
NGIAB Data Preprocess
This repository contains tools for preparing data to run a next gen simulation using NGIAB. The tools allow you to select a catchment of interest on an interactive map, choose a date range, and prepare the data with just a few clicks!
Table of Contents
- What does this tool do?
- Requirements
- Installation and Running
- Development Installation
- Usage
- CLI Documentation
What does this tool do?
This tool prepares data to run a next gen simulation by creating a run package that can be used with NGIAB. It picks default data sources, the v20.1 hydrofabric and nwm retrospective v3 forcing data.
Requirements
- This tool is officially supported on macOS or Ubuntu (tested on 22.04 & 24.04). To use it on Windows, please install WSL.
Installation and Running
# optional but highly encouraged: create a virtual environment
python3 -m venv env
source env/bin/activate
# installing and running the tool
pip install 'ngiab_data_preprocess[plot]' # [plot] needed to install the evaluation and plotting module
python -m map_app
# CLI instructions at the bottom of the README
The first time you run this command, it will download the hydrofabric and model parameter files from Lynker Spatial. If you already have them, place conus.gpkg
and model_attributes.parquet
into modules/data_sources/
.
Development Installation
Click to expand installation steps
To install and run the tool, follow these steps:
- Clone the repository:
git clone https://github.com/CIROH-UA/NGIAB_data_preprocess cd NGIAB_data_preprocess
- Create a virtual environment and activate it:
python3 -m venv env source env/bin/activate
- Install the tool:
pip install -e .
- Run the map app:
python -m map_app
Usage
Running the command python -m map_app
will open the app in a new browser tab. Alternatively, you can manually open it by going to http://localhost:5000 with the app running.
To use the tool:
- Select the catchment you're interested in on the map.
- Pick the time period you want to simulate.
- Click the following buttons in order:
- Create subset gpkg
- Create Forcing from Zarrs
- Create Realization
Once all the steps are finished, you can run NGIAB on the folder shown underneath the subset button.
Note: When using the tool, the output will be stored in the ./output/<your-input-feature>/
folder. There is no overwrite protection on the folders.
CLI Documentation
Click to expand CLI documentation
Arguments
-h
,--help
: Show the help message and exit.-i INPUT_FEATURE
,--input_feature INPUT_FEATURE
: ID of feature to subset. Providing a prefix will automatically convert to catid, e.g., cat-5173 or gage-01646500 or wb-1234.-l
,--latlon
: Use latitude and longitude instead of catid. Expects comma-separated values via the CLI, e.g.,python -m ngiab_data_cli -i 54.33,-69.4 -l -s
.-g
,--gage
: Use gage ID instead of catid. Expects a single gage ID via the CLI, e.g.,python -m ngiab_data_cli -i 01646500 -g -s
.-s
,--subset
: Subset the hydrofabric to the given feature.-f
,--forcings
: Generate forcings for the given feature.-r
,--realization
: Create a realization for the given feature.--start_date START_DATE
,--start START_DATE
: Start date for forcings/realization (format YYYY-MM-DD).--end_date END_DATE
,--end END_DATE
: End date for forcings/realization (format YYYY-MM-DD).-o OUTPUT_NAME
,--output_name OUTPUT_NAME
: Name of the output folder.-D
,--debug
: Enable debug logging.--run
: Automatically run Next Gen against the output folder.--validate
: Run every missing step required to run ngiab.--eval
: Evaluate performance of the model after running and plot streamflow at USGS gages.-a
,--all
: Run all operations: subset, forcings, realization, run Next Gen, and evaluate.
Usage Notes
- If your input has a prefix of
gage-
, you do not need to pass-g
. - The
-l
,-g
,-s
,-f
,-r
flags can be combined like normal CLI flags. For example, to subset, generate forcings, and create a realization, you can use-sfr
or-s -f -r
. - When using the
--all
flag, it automatically setssubset
,forcings
,realization
,run
, andeval
toTrue
. - Using the
--run
flag automatically sets the--validate
flag.
Examples
-
Subset hydrofabric using catchment ID:
python -m ngiab_data_cli -i cat-7080 -s
-
Generate forcings using a single catchment ID:
python -m ngiab_data_cli -i cat-5173 -f --start 2022-01-01 --end 2022-02-28
-
Create realization using a lat/lon pair and output to a named folder:
python -m ngiab_data_cli -i 54.33,-69.4 -l -r --start 2022-01-01 --end 2022-02-28 -o custom_output
-
Perform all operations using a lat/lon pair:
python -m ngiab_data_cli -i 54.33,-69.4 -l -s -f -r --start 2022-01-01 --end 2022-02-28
-
Subset hydrofabric using gage ID:
python -m ngiab_data_cli -i 10154200 -g -s # or python -m ngiab_data_cli -i gage-10154200 -s
-
Generate forcings using a single gage ID:
python -m ngiab_data_cli -i 01646500 -g -f --start 2022-01-01 --end 2022-02-28
-
Run all operations, including Next Gen and evaluation/plotting:
python -m ngiab_data_cli -i cat-5173 -a --start 2022-01-01 --end 2022-02-28
Output
The script creates an output folder named after the first catchment ID in the input file, the provided output name, or derived from the first lat/lon pair or gage ID. This folder will contain the results of the subsetting, forcings generation, realization creation, Next Gen run (if applicable), and evaluation (if applicable) operations.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ngiab_data_preprocess-2.2.1.tar.gz
.
File metadata
- Download URL: ngiab_data_preprocess-2.2.1.tar.gz
- Upload date:
- Size: 1.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50f6c4d222bc06b0b5b73bd93405851af71d17a67a8153ad5e0f7eb7d591ac51 |
|
MD5 | 19a7c7940d15ba674d0dbc884f087286 |
|
BLAKE2b-256 | 544184f699727caa1d36a4b98da11141be54c43e0953f52a788f7e721c4fa6c5 |
Provenance
The following attestation bundles were made for ngiab_data_preprocess-2.2.1.tar.gz
:
Publisher:
publish.yml
on CIROH-UA/NGIAB_data_preprocess
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
ngiab_data_preprocess-2.2.1.tar.gz
- Subject digest:
50f6c4d222bc06b0b5b73bd93405851af71d17a67a8153ad5e0f7eb7d591ac51
- Sigstore transparency entry: 145988430
- Sigstore integration time:
- Predicate type:
File details
Details for the file ngiab_data_preprocess-2.2.1-py3-none-any.whl
.
File metadata
- Download URL: ngiab_data_preprocess-2.2.1-py3-none-any.whl
- Upload date:
- Size: 1.6 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 243d5c888694aef42044becf9cf181645fb7a13ed681d3fae3cb38e143746518 |
|
MD5 | 3f506db89bb13b0c3f04316400b6c474 |
|
BLAKE2b-256 | 9b8d89f29af6c493814833120fee4696bc35148c7a16d7ebef17157e20f15571 |
Provenance
The following attestation bundles were made for ngiab_data_preprocess-2.2.1-py3-none-any.whl
:
Publisher:
publish.yml
on CIROH-UA/NGIAB_data_preprocess
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
ngiab_data_preprocess-2.2.1-py3-none-any.whl
- Subject digest:
243d5c888694aef42044becf9cf181645fb7a13ed681d3fae3cb38e143746518
- Sigstore transparency entry: 145988432
- Sigstore integration time:
- Predicate type: