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 NextGen-based 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!
| Funding for this project was provided by the National Oceanic & Atmospheric Administration (NOAA), awarded to the Cooperative Institute for Research to Operations in Hydrology (CIROH) through the NOAA Cooperative Agreement with The University of Alabama (NA22NWS4320003). |
Table of Contents
- What does this tool do?
- Limitations
- Requirements
- Installation and running
- Map interface documentation
- CLI documentation
- Realization information
What does this tool do?
This tool prepares data to run a NextGen-based simulation by creating a run package that can be used with NGIAB. It uses geometry and model attributes from the v2.2 hydrofabric more information on all data sources here. The raw forcing data is nwm retrospective v3 forcing data or the AORC 1km gridded data depending on user input
- Subsets (delineates) everything upstream of your point of interest (catchment, gage, flowpath etc) from the hydrofabric. This subset is output as a geopackage (.gpkg).
- Calculates forcings as a weighted mean of the gridded NWM or AORC forcings. Weights are calculated using exact extract and computed with numpy.
- Creates configuration files for a default NGIAB model run.
- realization.json - ngen model configuration
- troute.yaml - routing configuration.
- per catchment model configuration
- Optionally performs a non-interactive Docker-based NGIAB run.
Limitations
This tool cannot do the following:
Custom realizations
This tool currently only outputs a single, default realization, which is described in "Realization information". Support for additional model configurations is planned, but not currently available.
Calibration
If available, this repository will download calibrated parameters from the Community Hydrofabric AWS S3 bucket. However, many gages and catchments will not have such parameters available. In these cases, Data Preprocess will output realizations with default values.
For automatic calibration, please see ngiab-cal, which is under active development.
Evaluation
For automatic evaluation using TEEHR, please run NGIAB interactively using the guide.sh script.
Visualisation
For automatic interactive visualisation, please run NGIAB interactively using the guide.sh script
Requirements
This tool is officially supported on macOS and Ubuntu (tested on 22.04 & 24.04). To use it on Windows, please install WSL.
It is also highly recommended to use Astral UV to install and run this tool. Installing the project via pip without the use of a virtual environment creates a severe risk of dependency conflicts.
Installation and running
Running without install
This package supports pipx and uvx, which means you can run the tool without installing it. No virtual environment needed, just UV.
# Run these from anywhere!
uvx --from ngiab-data-preprocess cli --help # Running the CLI
uvx ngiab-prep --help # Alias for the CLI
uvx --from ngiab-data-preprocess map_app # Running the map interface
For uv installation
Click here to expand
# Install UV
curl -LsSf https://astral.sh/uv/install.sh | sh
# It can be installed via pip if that fails
# pip install uv
# Create a virtual environment in the current directory
uv venv
# Install the tool in the virtual environment
uv pip install ngiab_data_preprocess
# To run the cli
uv run cli --help
# To run the map
uv run map_app
UV automatically detects any virtual environments in the current directory and will use them when you use uv run.
For legacy pip installation
Click here to expand
# If you're installing this on jupyterhub / 2i2c you HAVE TO DEACTIVATE THE CONDA ENV
(notebook) jovyan@jupyter-user:~$ conda deactivate
jovyan@jupyter-user:~$
# The interactive map won't work on 2i2c
# This tool is likely to not work without a virtual environment
python3 -m venv .venv
source .venv/bin/activate
# installing and running the tool
pip install 'ngiab_data_preprocess'
python -m map_app
# CLI instructions at the bottom of the README
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:
uv venv - Install the tool:
uv pip install -e .
- Run the map app:
uv run map_app
Map interface documentation
Running the map interface app
Running the map_app tool will open the app in a new browser tab.
Install-free: uvx --from ngiab-data-preprocess map_app
Installed with uv: uv run map_app
Using the map interface
- 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 default output will be stored in the ~/ngiab_preprocess_output/<your-input-feature>/ folder. There is no overwrite protection on the folders.
CLI documentation
Running the CLI
Install-free: uvx ngiab-prep
Installed with uv: uv run cli
Arguments
-h,--help: Show the help message and exit.--output_root: Path to new default directory where outputs in the future will be stored.-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.--vpu VPU_ID: The id of the vpu to subset e.g 01. 10 = 10L + 10U and 03 = 03N + 03S + 03W.--helpwill display all the options.-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.--subset_type: Specify the subset type.nexus: get everything flowing into the downstream nexus of the selected catchment.catchment: get everything flowing into the selected catchment.-f,--forcings: Generate forcings for the given feature.-r,--realization: Create a realization for the given feature.--lstm: Configures the data for the python lstm.--lstm_rust: Configures the data for the rust lstm.--dhbv2: Configures the data for the dHBV2 model.--summa: Configures the data for the SUMMA model.--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.--source: The datasource you want to use, eithernwmfor retrospective v3 oraorc. Default isnwm.-D,--debug: Enable debug logging.--nwm_gw: Use NWM retrospective output groundwater level for CFE initial groundwater state.--run: Automatically run NGIAB's docker distribution against the output folder.--validate: Run every missing step required to run NGIAB.-a,--all: Run all operations. Equivalent to-sfrand--run.
Usage notes
- If your input has a prefix of
gage-, you do not need to pass-g. - The
-l,-g,-s,-f,-rflags can be combined like normal CLI flags. For example, to subset, generate forcings, and create a realization, you can use-sfror-s -f -r. - When using the
--allflag, it automatically setssubset,forcings,realization, andruntoTrue. - Using the
--runflag automatically sets the--validateflag.
Examples
-
Prepare everything for an NGIAB run at a given gage:
uvx ngiab-prep -i gage-10154200 -sfr --start 2022-01-01 --end 2022-02-28 # add --run or replace -sfr with --all to run NGIAB, too # to name the folder, add -o folder_name
-
Subset the hydrofabric using a catchment ID or VPU:
uvx ngiab-prep -i cat-7080 -s uvx ngiab-prep --vpu 01 -s
-
Generate forcings using a single catchment ID:
uvx ngiab-prep -i cat-5173 -f --start 2022-01-01 --end 2022-02-28
-
Create realization using a latitude/longitude pair and output to a named folder:
uvx ngiab-prep -i 33.22,-87.54 -l -r --start 2022-01-01 --end 2022-02-28 -o custom_output
-
Perform all operations using a latitude/longitude pair:
uvx ngiab-prep -i 33.22,-87.54 -l -s -f -r --start 2022-01-01 --end 2022-02-28
-
Subset the hydrofabric using a gage ID:
uvx ngiab-prep -i 10154200 -g -s # or uvx ngiab-prep -i gage-10154200 -s
-
Generate forcings using a single gage ID:
uvx ngiab-prep -i 01646500 -g -f --start 2022-01-01 --end 2022-02-28
Realization information
This tool currently offers three realizations.
NOAH + CFE (Default)
This realization is intended to be roughly comparable to earlier versions of the National Water Model.
- NOAH-OWP-Modular: A refactoring of Noah-MP, a land-surface model. Used to model groundwater properties.
- Conceptual Functional Equivalent (CFE): A simplified conceptual approximation of versions 1.2, 2.0, and 2.1 of the National Water Model. Used to model precipitation and evaporation.
- SLoTH: A module used to feed through unchanged values. In this default configuration, it simply forces certain soil moisture and ice fraction properties to zero.
LSTM (Python)
This realization will run the python lstm. It's designed to work with ngiab using these example weights generously contributed by jmframe/lstm
LSTM (Rust)
This realization will run the rust port of the python lstm above. It's an experimental drop in replacement that should produce identical results with a ~2-5x speedup depending on your setup.
SUMMA
This realization will run the SUMMA model (version linked is what's currently in nextgen in a box).
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ngiab_data_preprocess-4.8.0.tar.gz.
File metadata
- Download URL: ngiab_data_preprocess-4.8.0.tar.gz
- Upload date:
- Size: 463.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3c11bab9f2d8768699423707ce15ba32181dd53a769c4a2c2eab6179a32c710
|
|
| MD5 |
9febc58582cebcf868334624315792db
|
|
| BLAKE2b-256 |
a88012b023186ed7053252f03c2debfafa63b99328ca4d3b101254496e569df0
|
Provenance
The following attestation bundles were made for ngiab_data_preprocess-4.8.0.tar.gz:
Publisher:
publish.yml on CIROH-UA/NGIAB_data_preprocess
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ngiab_data_preprocess-4.8.0.tar.gz -
Subject digest:
f3c11bab9f2d8768699423707ce15ba32181dd53a769c4a2c2eab6179a32c710 - Sigstore transparency entry: 958588752
- Sigstore integration time:
-
Permalink:
CIROH-UA/NGIAB_data_preprocess@1043287c8e2c543e2183aa6891e91dda32ae05b6 -
Branch / Tag:
refs/tags/v4.8.0 - Owner: https://github.com/CIROH-UA
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1043287c8e2c543e2183aa6891e91dda32ae05b6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file ngiab_data_preprocess-4.8.0-py3-none-any.whl.
File metadata
- Download URL: ngiab_data_preprocess-4.8.0-py3-none-any.whl
- Upload date:
- Size: 380.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c51696ebfb2946af4ab3ab34fe7d44c307b2776506a768051b6ca3dd32fdd58
|
|
| MD5 |
76c1a8e1af8726e5333d4dd84e8d1851
|
|
| BLAKE2b-256 |
d9e83acd8d3adc758bc58aa9c939f4d8298335453b406b93c00dcf0a9848b049
|
Provenance
The following attestation bundles were made for ngiab_data_preprocess-4.8.0-py3-none-any.whl:
Publisher:
publish.yml on CIROH-UA/NGIAB_data_preprocess
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ngiab_data_preprocess-4.8.0-py3-none-any.whl -
Subject digest:
2c51696ebfb2946af4ab3ab34fe7d44c307b2776506a768051b6ca3dd32fdd58 - Sigstore transparency entry: 958588817
- Sigstore integration time:
-
Permalink:
CIROH-UA/NGIAB_data_preprocess@1043287c8e2c543e2183aa6891e91dda32ae05b6 -
Branch / Tag:
refs/tags/v4.8.0 - Owner: https://github.com/CIROH-UA
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1043287c8e2c543e2183aa6891e91dda32ae05b6 -
Trigger Event:
release
-
Statement type: