Building Hydrofabric & Processing Ancillary Data
The following schema is the proposed data model for NGWPC hydrofabric datasets produced by this repo.
The central table (or FACT Table) is Flowpaths. Each flowpath has a downstream, and upstream nexus point, allowing for traversal of a river network through a single table. Additionally, there is a 1:1 relationship between flowpath and divide.
The tables highlighted in green are the infomation needed for lumped modeling to take place. Lumped models require attributes, the shape of the divide that is being modeled, and a nexus point for flow to be aggregated to.
The tables highlighted in blue contain the information needed for routing at a high resolution. T-Route is expected to run at a fine-scale (~300m segments) with many virtual_flowpaths. Each virtual flowpath is delineated based on the reference fabric, and there should be a many -> one relationship between virtual_flowpaths and flowpaths, with some virtual flowpaths not being represented in the flowpaths table. These non-represented flowpaths have the parameter of routing_segment set to False, and will have flow estimated through flow-scaling.
The NGWPC Hydrofabric is build using many reference materials:
- Reference Flowpaths
- Reference Reservoirs
- USGS/ENVCA/CADWR/TXDOT Streamflow Gages
- NHD+
To ensure flowpaths can be mapped to back to the materials that created them, each of the reference materials is mapped to flowpaths, hydrolocations, and virtual flowpaths. The following IDs pairings are used:
- Reference Flowpaths ->
ref_fp_id - Reference Reservoirs ->
dam_id - USGS/ENVCA/CADWR/TXDOT Streamflow Gages ->
site_no - NHD+ ->
nhd_feature_id
Run these commands from the repository root.
This repo is managed through UV
The following command installs the project's base dependencies, the docs optional extra, and all dependency groups (dev, examples, and tests):
uv sync --all-extras --all-groupsPython 3.12 or newer is required.
just calls series of commands called "recipes" similar to a make file. Install on linux with apt get just or follow linked readme for other platforms. After installing just, you can use the following commands to set up the data sources for nhf-builds. You can also use just to build hydrofabrics for each domain or specify a config.
Provide AWS credentials in the current shell:
export AWS_DEFAULT_REGION="us-east-1"
export AWS_ACCESS_KEY_ID="..."
export AWS_SECRET_ACCESS_KEY="..."
export AWS_SESSION_TOKEN="..." # Required for temporary credentialsVerify that AWS recognizes the credentials:
aws sts get-caller-identityThen sync the input data for the desired domain:
just sync # CONUS
just sync-ak # Alaska
just sync-hi # Hawaii
just sync-prvi # Puerto Rico and the US Virgin IslandsTo select a different OCONUS reference-fabric version, pass the oconus-version variable:
just oconus-version=0.1.8 sync-akWarning: The sync recipes overwrite the corresponding input datasets under
data/.
Exporting AWS credentials in the shell is functionally sufficient because just and its child processes inherit those environment variables. The justfile also automatically loads variables from a repository-root .env file.
Avoid committing credentials or entering long-lived secrets directly into commands that may be saved in shell history. When available, prefer an AWS SSO or named-profile workflow for data synchronization:
aws sso login --profile ngwpc-test
AWS_PROFILE=ngwpc-test just syncAn AWS profile is sufficient for the aws s3 commands used by the sync recipes. Some hydrofabric build paths access S3 credentials directly through AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_SESSION_TOKEN, so a profile alone may not be sufficient for every build configuration.
Run the main build script directly with the CONUS example configuration:
uv run python scripts/hf_runner.py --config configs/example_config.yamlAlternatively, use a domain-specific just recipe:
just build-conus
just build-ak
just build-hi
just build-prviRun the build with a custom configuration:
just build "configs/my_custom_config.yaml"uv run pytest testsuv run pytest tests/test_config.pyuv run pytest tests/test_config.py::test_from_yaml_1For a test method defined inside a class, include the class name in the pytest node ID. For example:
uv run pytest tests/test_graph.py::TestBuildGraphUnit::test_simple_linear_networkTo ensure that hydrofabric-builds follows the specified structure, be sure to install the local dev dependencies and run uv run pre-commit install


