Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
5bfc7af
add initial ReadTheDocs page
sclaw Aug 15, 2025
559a48a
update index
sclaw Aug 15, 2025
c589762
add pages to RTD
sclaw Aug 19, 2025
3afe469
update docs
sclaw Aug 20, 2025
d18a268
update readme and tech reference
sclaw Aug 26, 2025
ab22d9b
update gitignore for docs
sclaw Aug 28, 2025
9474145
continue doc work
sclaw Sep 18, 2025
c758f51
update documentation for formulation regionalization and parameter re…
sclaw Sep 22, 2025
53a8de8
Merge branch 'development' into slawson_NGWPC-6996
sclaw Sep 24, 2025
5e541c2
Merge branch 'development' into slawson_NGWPC-6996
sclaw Oct 27, 2025
9dd22b0
catch up docs for packaging updates
sclaw Oct 28, 2025
d13257e
spruce up docs
sclaw Oct 28, 2025
bd23768
add content for parreg tech ref
sclaw Oct 28, 2025
799b8ec
tidy docs
sclaw Oct 28, 2025
b2c6414
refactor for automated documentation builds
sclaw Oct 28, 2025
8bfce8c
update docs to quiet warnings and improve API reference
sclaw Nov 4, 2025
cb1bfab
fix logging
sclaw Nov 4, 2025
4493896
Merge branch 'development' into slawson_NGWPC-6996
sclaw Nov 4, 2025
d6d2312
clean up readme
sclaw Nov 6, 2025
157fa7a
updates to index.md
Nov 7, 2025
50b641b
updates to config schemas and documentation
Nov 10, 2025
ff08b5a
fix issue in documentation for dict[str, BaseModel] fields
Nov 14, 2025
53d55b2
Merge branch 'development' into yliu_NGWPC-8833
yuqiong77 Nov 14, 2025
2e9145d
Resolve merge conflicts
Nov 14, 2025
c36934f
Merge remote branch 'yliu_NGWPC-8833' into local branch
Nov 14, 2025
658fd61
Fix README from merging
Nov 14, 2025
d574125
add intro and TOC to config_builder page
Nov 14, 2025
e319b47
Set version pins for geopandas, shapely, pandas to match pending upda…
mxkpp Nov 14, 2025
14c8fbb
minor updates to schema page
Nov 15, 2025
4d195a6
Unify pydantic minimum version to currently latest patch release of 2.11
mxkpp Nov 16, 2025
29ab62a
update config builder index page
Nov 17, 2025
a20a285
add NGEN simulation to framework image
Nov 17, 2025
6d73be9
update to use load dot env instead of mounting s3
mdeshotel Nov 18, 2025
202eb60
fix nprocs log
mdeshotel Nov 18, 2025
d35f4da
use model_dump instead of __dict__for to_dict
mdeshotel Nov 18, 2025
e6ff2f0
add output docs & fix bugs
Nov 18, 2025
a532f1a
revert changes to conf.py that caused issues
Nov 18, 2025
59e0609
add ulimit -n 60000 to ngen call
mdeshotel Nov 19, 2025
abb2a1b
update paths in config
mdeshotel Nov 19, 2025
e8a71b8
fix path typo
mdeshotel Nov 19, 2025
5ac3c77
update parreg config
mdeshotel Nov 19, 2025
0dd7749
update readme
mdeshotel Nov 19, 2025
452eec8
update snow_17 path
mdeshotel Nov 21, 2025
b4deb91
extensive updates to docs
Nov 21, 2025
7a174fd
minor updates to parreg docs
Nov 21, 2025
1578705
updates to API
Nov 24, 2025
3fbaf67
fix formreg
mdeshotel Nov 24, 2025
e919f4d
reduce mounts
mdeshotel Nov 24, 2025
eb22c86
update paths
mdeshotel Nov 24, 2025
f4ee548
add dotenv to requirements
mdeshotel Nov 24, 2025
3ee48b1
fix typo in readme
mdeshotel Nov 25, 2025
be2afa2
fix typos
sclaw Nov 25, 2025
271bcf2
fix indentation
sclaw Nov 25, 2025
1ddee83
add deployment gh action for when github pages are enabled
sclaw Nov 25, 2025
eef0b09
Merge pull request #1 from NGWPC/yliu_NGWPC-8833
yuqiong77 Nov 25, 2025
014a182
Merge remote-tracking branch 'origin/development' into mdeshotel_NGWP…
Nov 25, 2025
41bd4c5
minor updates to parref tech reference
Nov 25, 2025
be1d923
fix typo in prereg tech reference
Nov 25, 2025
155f58e
Merge pull request #2 from NGWPC/mdeshotel_NGWPC-7004
yuqiong77 Nov 25, 2025
69f8a1f
Merge remote-tracking branch 'origin/development' into maxkipp-ngwpc-…
mxkpp Nov 25, 2025
6ce71c9
udpated region-mgr.sh to allow HTTPS for git cloning
miguelp1986 Nov 25, 2025
6cf2cb1
udpated region-mgr.sh to allow HTTPS for git cloning
miguelp1986 Nov 25, 2025
3202cd4
Merge pull request #3 from NGWPC/maxkipp-ngwpc-8941-upgrade-shapely-2
mxkpp Nov 26, 2025
815af7f
remove trailing comma in ProximityPairer class
miguelp1986 Nov 26, 2025
12afbbb
Merge pull request #4 from NGWPC/pena-9003
miguelp1986 Nov 28, 2025
2cc215a
Merge pull request #6 from NGWPC/development
cmaynard-ngwpc Dec 3, 2025
c589a42
Merge pull request #7 from NGWPC/ngwpc-candidate
cmaynard-ngwpc Dec 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: documentation

on:
push:
branches: [ "documentation" ]

permissions:
contents: write

jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
run: |
pip install -r docs/source/requirements.txt
pip install .
- name: Debug Python imports
run: |
python -c "import nwm_region_mgr.parreg.config_schema; print('Import OK')"
- name: Sphinx build
run: |
sphinx-build docs/source docs/build
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: docs/build/
force_orphan: true
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ __pycache__/
# Editor configs
.vscode/

# Documentation
docs/build/*
docs/source/API/*
!docs/source/API/index.rst
# Specific project paths
pkgs/parreg/build
pkgs/parreg/tests/test_data/test_outputs
nwm-rte
nwm-rte
14 changes: 14 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Copyright 2025 Raytheon Company

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

Licensed under: https://opensource.org/license/bsd-2-clause

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

All rights reserved. Based on Government sponsored work under contract GS-35F-204GA.

-----------------
136 changes: 74 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,45 @@
# nwm-region-mgr
# Formulation and Parameter Regionalization for the NextGen Framework
[![Build](https://img.shields.io/github/actions/workflow/status/ngwpc/nwm-region-mgr/ci.yaml?branch=main)](.github/workflows/ci.yml)
[![License: BSD 2-Clause](https://img.shields.io/badge/License-BSD%202--Clause-orange.svg)](https://opensource.org/license/bsd-2-clause)
[![Release](https://img.shields.io/github/v/release/ngwpc/nwm-region-mgr)](https://github.com/NGWPC/nwm-region-mgr)
![Code Style: Ruff](https://img.shields.io/badge/code%20style-ruff-orange.svg)
![Linter: Ruff](https://img.shields.io/badge/linter-ruff-orange)

## Name
NGEN/NWM Regionalization
<img src="docs/source/_images/overview.png" alt="overview" width="600"/>

## Description
This repository includes packages for conducting formulation and parameter regionalizations for NextGen modules,
as well as scripts/workflows to run ngen simulations and evaluation.
- parreg: parameter regionalization
- formreg: formulation regionalization
- utils: utility functions shared by parreg and formreg

`nwm_region_mgr` is a Python package for identifying optimal model formulations and parameter values in ungauged catchments. It leverages calibration data from gauged catchments to improve hydrologic modeling and forecasting skill across regions, playing a key role in the NextGen and NWM ecosystem.


## Key Features

- **Formulation Regionalization** – Ranks NextGen model formulations for ungauged catchments based on similarity to gauged sites.
- **Parameter Regionalization** – Estimates parameter values by intelligently transferring calibrations across catchments.
- **Clustering Methods** – Groups catchments with shared hydrologic characteristics using multiple clustering approaches.
- **Diagnostic Plots** – Generates clear plots and maps that explain formulation and parameter choices.
- **Scalable Workflows** – Efficiently supports studies from individual watersheds to CONUS-wide applications.
- **Customizable Configurations** – Full control of workflows via human-readable config files.
## Docker Run Time Environment (RTE)
### Step 0. Build Docker image
### Step 0. Build Docker image and download data
#### a) Sample input data can be downloaded from: **s3://ngwpc-dev/regionalization/data**

#### b) Build Docker image
`Note` This step is only necessary if a docker image doesn't already exists or if updates to the code base have been implemented. The short flag `-d` can also be used in place of `--docker`

```bash
cd nwm-region-mgr
```
```bash
./region-mgr.sh -docker
./region-mgr.sh --docker
```
### Step 1. Run regionalization
#### a) Run both formulation and parameter regionalization together:
```bash
./region-mgr.sh --formreg --parreg
```
#### b) Run formulation regionalization alone:

#### a) Run formulation regionalization alone (no parreg):
The short flag `-f` can also be used in place of `--formreg`.
```bash
./region-mgr.sh --formreg
```
#### c) Run parameter regionalization alone:
#### b) Run parameter regionalization (formreg is also ran as a prerequisite):
The short flag `-p` can also be used in place of `--parreg`.
```bash
./region-mgr.sh --parreg
Expand All @@ -52,39 +61,41 @@ The short flag `-e` can also be used in place of `--eval`.
### Steps 0-4
Alternatively the user can run steps 0-4 in all at once in series:
```bash
./region-mgr.sh -dfpne
./region-mgr.sh -dpne
```
## Desktop Run Time Environment (RTE)
## Desktop/Workspace Run Time Environment (RTE)
### Clone & Build

#### 1. clone ngen-region-mgr from Github

```bash
cd [NGEN_REG_ROOT]
git clone -b development --recurse-submodules https://github.com/NGWPC/nwm-region-mgr.git
git clone https://github.com/NGWPC/nwm-region-mgr.git
cd nwm-region-mgr
```

#### 2. create python venv

Create a virtual environment to isolate the dependencies of this library from your base Python environment.
```bash
cd [VENV_ROOT]
/usr/bin/python3.11 -m venv venv
source venv/bin/activate
pip install --upgrade pip
python3.11 -m venv .venv
source .venv/bin/activate
pip pip install --upgrade pip
```

#### 3. install nwm-region-mgr

You will then be able to install nwm_region_mgr. There are a few variants that users may be interested in.

```bash
cd [NGEN_REG_ROOT]
pip install . # to install formreg and utils only
# OR
pip install .[parreg] # to install formreg, utils, and parreg
# Regular package install
pip install .
# Install the package in edit mode (for development)
pip install -e .
# Install additional dependencies for parameter regionalization
pip install .[parreg]
# Install dependencies for docs and dev
pip install .[docs,dev]
```

where [VENV_ROOT] and [NGEN_REG_ROOT] refer to the directory to install python venv and nwm-region-mgr
in your local workspace, respectively


### STEP 1: Run regionalization to produce regionalized parameters and formulations

#### 1) Set up configuration yaml files
Expand All @@ -94,17 +105,18 @@ Three yaml config files are needed to run regionalization
- **onfig_formreg.yaml**: specific settings for the formulation regionalization process.
- **config_parreg.yaml**: specific settings for the parameter regionalization process.

Follow the sample [config files](https://github.com/NGWPC/nwm-region-mgr/tree/development/sample_files/configs) to set up the configurations for your regionalization application as needed.
Follow the sample config files (nwm_region_mgr/sample_files/configs) to set up the configurations
for your regionalization application as needed.

Sample input data can be downloaded from **s3://ngwpc-dev/Yuqiong.Liu/repos/nwm-region-mgr**
Sample input data can be downloaded from **s3://ngwpc-dev/regionalization/**


#### 2) Run the regionalization script

```bash
python [NGEN_REG_ROOT]/nwm-region-mgr/regionalization.py [COFIG_DIR]
```
Where:
Where:
- [NGEN_REG_ROOT] refers to the directory where nwm-region-mgr is installed
- [COFIG_DIR] refers to the directory containing the three config files as noted in 1), e.g.,

Expand All @@ -114,35 +126,35 @@ python regionalization.py sample_files/configs

### STEP 2: Run NGEN simulation with regionalized parameters

- #### Run natively in workspace
- ##### 1) Install [ngen](https://github.com/NGWPC/ngen) and all submodules in its own venv
You may want to follow the following Confluence pages:
- [Clone ngen](https://confluence.nextgenwaterprediction.com/display/NGWPC/Clone+NGWPC+GitHub+Code)
- [Build ngen](https://confluence.nextgenwaterprediction.com/display/NGWPC/Build+ngen+completely)
#### Run natively in workspace
##### 1) Install [ngen](https://github.com/NGWPC/ngen) and all submodules in its own venv
You may want to follow the following Confluence pages:
- [Clone ngen](https://confluence.nextgenwaterprediction.com/display/NGWPC/Clone+NGWPC+GitHub+Code)
- [Build ngen](https://confluence.nextgenwaterprediction.com/display/NGWPC/Build+ngen+completely)

- ##### 2) Install [mswm](https://github.com/NGWPC/nwm-msw-mgr) in its own venv

- ##### 3) Activate MSWM venv, e.g.
```bash
source ~/repos/nwm-msw-mgr/venv/bin/activate
```
- ##### 4) Set up MSWM configuration as shown in [run_ngen_vpu.sh](https://github.com/NGWPC/nwm-region-mgr/blob/development/run_ngen_vpu.sh)

- ##### 5) Run MSWM and ngen simulation
```bash
cd ~/repos/nwm-region-mgr
./run_ngen_vpu.sh
```
- ##### 6) Check inputs, outputs and logs
All input, output and log files from running MSWM and NGEN can be found in *[work_dir]/regionalization/[run_name]/[vpu]*
##### 2) Install [mswm](https://github.com/NGWPC/nwm-msw-mgr) in its own venv

##### 3) Activate MSWM venv, e.g.
```bash
source ~/repos/nwm-msw-mgr/venv/bin/activate
```
##### 4) Set up MSWM configuration as shown in [run_ngen_vpu.sh](https://github.com/NGWPC/nwm-region-mgr/blob/development/run_ngen_vpu.sh)

##### 5) Run MSWM and ngen simulation
```bash
cd ~/repos/nwm-region-mgr
./run_ngen_vpu.sh
```
##### 6) Check inputs, outputs and logs
All input, output and log files from running MSWM and NGEN can be found in *[work_dir]/regionalization/[run_name]/[vpu]*
(as defined in **run_ngen_vpu.sh**)

- ##### 7) If ngen fails at t-route
Check if all NGEN cat-*.csv and nex-*.csv output files are generated; if yes,
##### 7) If ngen fails at t-route
Check if all NGEN cat-*.csv and nex-*.csv output files are generated; if yes,
run t-route separately from the Output directory where ngen outputs are located, e.g.,
```bash
python -m nwm_routing -f -V4 ../Input/vpu_09_troute_config_region.yaml
```
```bash
python -m nwm_routing -f -V4 ../Input/vpu_09_troute_config_region.yaml
```

### STEP 3: Evaluate NGEN simulation with nwm.verf

Expand Down
12 changes: 12 additions & 0 deletions docs/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Define variables for Sphinx
SPHINXAPIDOC = sphinx-apidoc
SPHINXBUILD = sphinx-build
SOURCEDIR = source
BUILDDIR = build

clean:
rm -rf $(BUILDDIR)/*
rm -rf $(SOURCEDIR)/API/_autosummary

html: clean
$(SPHINXBUILD) -b html $(SOURCEDIR) $(BUILDDIR)
Loading