ngiab-data-preprocess 4.9.2__tar.gz → 4.9.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ngiab_data_preprocess-4.9.4/.dockerignore +6 -0
- ngiab_data_preprocess-4.9.4/.github/workflows/ci.yml +86 -0
- ngiab_data_preprocess-4.9.4/.github/workflows/docker.yml +40 -0
- ngiab_data_preprocess-4.9.4/CONTRIBUTING.md +39 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/PKG-INFO +8 -3
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/README.md +6 -1
- ngiab_data_preprocess-4.9.4/aws_tools/aws.dockerfile +28 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_processing/create_realization.py +99 -58
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_processing/dask_utils.py +33 -2
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_processing/file_paths.py +16 -7
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_processing/forcings.py +68 -12
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_processing/gpkg_utils.py +4 -4
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_processing/graph_utils.py +29 -9
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_processing/subset.py +6 -2
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/SUMMA/outputControl.txt +7 -7
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/catchment/noah-owp-modular-init.namelist.input +2 -2
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/source_validation.py +0 -70
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/ngiab_data_cli/__main__.py +19 -9
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/ngiab_data_cli/arguments.py +34 -6
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/ngiab_data_cli/forcing_cli.py +17 -2
- ngiab_data_preprocess-4.9.4/modules/ngiab_data_cli/subset_cli.py +62 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/ngiab_data_preprocess.egg-info/PKG-INFO +8 -3
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/ngiab_data_preprocess.egg-info/SOURCES.txt +33 -1
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/ngiab_data_preprocess.egg-info/entry_points.txt +1 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/ngiab_data_preprocess.egg-info/requires.txt +1 -1
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/pyproject.toml +6 -2
- ngiab_data_preprocess-4.9.4/stack.drawio.svg +4 -0
- ngiab_data_preprocess-4.9.4/tests/golden/config/cat-1555522-summa.json +14 -0
- ngiab_data_preprocess-4.9.4/tests/golden/config/cat-1555522.json +12 -0
- ngiab_data_preprocess-4.9.4/tests/golden/config/gage-10109001-summa.json +101 -0
- ngiab_data_preprocess-4.9.4/tests/golden/config/gage-10109001.json +795 -0
- ngiab_data_preprocess-4.9.4/tests/golden/geopackage/cat-1555522_subset.gpkg +0 -0
- ngiab_data_preprocess-4.9.4/tests/golden/geopackage/gage-10109001_subset.gpkg +0 -0
- ngiab_data_preprocess-4.9.4/tests/golden/netcdf/cat-1555522-attributes.json +124 -0
- ngiab_data_preprocess-4.9.4/tests/golden/netcdf/cat-1555522-coldState.json +272 -0
- ngiab_data_preprocess-4.9.4/tests/golden/netcdf/cat-1555522-trialParams.json +28 -0
- ngiab_data_preprocess-4.9.4/tests/golden/netcdf/gage-10109001-attributes.json +1342 -0
- ngiab_data_preprocess-4.9.4/tests/golden/netcdf/gage-10109001-coldState.json +3056 -0
- ngiab_data_preprocess-4.9.4/tests/golden/netcdf/gage-10109001-trialParams.json +202 -0
- ngiab_data_preprocess-4.9.4/tests/golden/realization/cfe-nom.json +97 -0
- ngiab_data_preprocess-4.9.4/tests/golden/realization/dhbv2-daily.json +54 -0
- ngiab_data_preprocess-4.9.4/tests/golden/realization/dhbv2.json +54 -0
- ngiab_data_preprocess-4.9.4/tests/golden/realization/lstm-py.json +45 -0
- ngiab_data_preprocess-4.9.4/tests/golden/realization/lstm-rs.json +46 -0
- ngiab_data_preprocess-4.9.4/tests/golden/realization/sacsma-nom.json +74 -0
- ngiab_data_preprocess-4.9.4/tests/golden/realization/snow17-nom-cfe.json +114 -0
- ngiab_data_preprocess-4.9.4/tests/golden/realization/summa.json +55 -0
- ngiab_data_preprocess-4.9.4/tests/test_cell_weights.py +24 -0
- ngiab_data_preprocess-4.9.4/tests/test_config_generation.py +286 -0
- ngiab_data_preprocess-4.9.4/tests/test_forcings_regression.py +308 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/tests/test_nan_impute.py +43 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/tests/test_ngiab_data_cli_regression.py +2 -0
- ngiab_data_preprocess-4.9.4/tests/test_realization_templates.py +106 -0
- ngiab_data_preprocess-4.9.4/tests/test_summa_config_generation.py +521 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/.github/pull_request_template.md +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/.github/workflows/build_only.yml +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/.github/workflows/publish.yml +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/.gitignore +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/CITATION.cff +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/LICENSE +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/ciroh-bgsafe.png +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_processing/dataset_utils.py +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_processing/datasets.py +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_processing/s3fs_utils.py +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/SUMMA/README.md +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/SUMMA/TBL_GENPARM.TBL +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/SUMMA/TBL_MPTABLE.TBL +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/SUMMA/TBL_SOILPARM.TBL +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/SUMMA/TBL_VEGPARM.TBL +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/SUMMA/basinParamInfo.txt +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/SUMMA/fileManager.txt +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/SUMMA/forcingFileList.txt +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/SUMMA/localParamInfo.txt +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/SUMMA/modelDecisions.txt +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/catchment/cfe.ini +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/catchment/dhbv2-daily.yaml +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/catchment/dhbv2.yaml +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/catchment/lstm.yml +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/catchment/sac-init.namelist.input +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/catchment/sac-params.txt +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/catchment/snow17-init.namelist.input +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/catchment/snow17-params.txt +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/catchment/summa.input +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/realization/cfe-nom.json +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/realization/dhbv2-daily.json +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/realization/dhbv2.json +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/realization/lstm-py.json +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/realization/lstm-rs.json +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/realization/sacsma-nom.json +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/realization/snow17-nom-cfe.json +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/realization/summa.json +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/ngen-routing-template.yaml +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/template.sql +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_sources/triggers.sql +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/map_app/__init__.py +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/map_app/__main__.py +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/map_app/static/css/console.css +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/map_app/static/css/main.css +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/map_app/static/css/toggle.css +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/map_app/static/js/console.js +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/map_app/static/js/data_processing.js +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/map_app/static/js/main.js +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/map_app/static/resources/loading.gif +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/map_app/static/resources/screenshot.jpg +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/map_app/templates/index.html +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/map_app/views.py +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/ngiab_data_cli/custom_logging.py +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/ngiab_data_preprocess.egg-info/dependency_links.txt +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/ngiab_data_preprocess.egg-info/top_level.txt +0 -0
- {ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/setup.cfg +0 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches: [main]
|
|
6
|
+
|
|
7
|
+
concurrency:
|
|
8
|
+
group: ci-${{ github.ref }}
|
|
9
|
+
cancel-in-progress: true
|
|
10
|
+
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
lint:
|
|
16
|
+
name: Ruff (changed files only)
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
with:
|
|
21
|
+
fetch-depth: 0 # need history to diff this PR against its base branch
|
|
22
|
+
|
|
23
|
+
- uses: astral-sh/setup-uv@v6
|
|
24
|
+
|
|
25
|
+
- name: Lint & format-check the Python files this PR changed
|
|
26
|
+
run: |
|
|
27
|
+
base='${{ github.event.pull_request.base.sha }}'
|
|
28
|
+
head='${{ github.event.pull_request.head.sha }}'
|
|
29
|
+
mapfile -t files < <(git diff --name-only --diff-filter=ACMR "$base"..."$head" -- '*.py')
|
|
30
|
+
if [ ${#files[@]} -eq 0 ]; then
|
|
31
|
+
echo "No Python files changed -- nothing to lint."
|
|
32
|
+
exit 0
|
|
33
|
+
fi
|
|
34
|
+
printf 'Linting %s changed file(s):\n' "${#files[@]}"
|
|
35
|
+
printf ' %s\n' "${files[@]}"
|
|
36
|
+
# Keep this ruff version in sync with your pre-commit hook.
|
|
37
|
+
uvx ruff@0.11.9 check -- "${files[@]}"
|
|
38
|
+
uvx ruff@0.11.9 format --check -- "${files[@]}"
|
|
39
|
+
|
|
40
|
+
test:
|
|
41
|
+
name: pytest (unit · hermetic)
|
|
42
|
+
runs-on: ubuntu-latest
|
|
43
|
+
strategy:
|
|
44
|
+
fail-fast: false
|
|
45
|
+
matrix:
|
|
46
|
+
python-version: ["3.10", "3.11"]
|
|
47
|
+
steps:
|
|
48
|
+
- uses: actions/checkout@v4
|
|
49
|
+
with:
|
|
50
|
+
fetch-depth: 0 # setuptools-scm derives the version from git history/tags
|
|
51
|
+
|
|
52
|
+
- uses: astral-sh/setup-uv@v6
|
|
53
|
+
with:
|
|
54
|
+
python-version: ${{ matrix.python-version }}
|
|
55
|
+
enable-cache: true
|
|
56
|
+
|
|
57
|
+
- name: Install project + dev group
|
|
58
|
+
run: uv sync
|
|
59
|
+
|
|
60
|
+
- name: Run unit tests (hermetic; excludes integration)
|
|
61
|
+
run: uv run pytest -m "not integration"
|
|
62
|
+
|
|
63
|
+
integration:
|
|
64
|
+
name: pytest (integration · live S3)
|
|
65
|
+
runs-on: ubuntu-latest
|
|
66
|
+
continue-on-error: true
|
|
67
|
+
timeout-minutes: 15 # bound it in case S3 stalls (the test caps itself at 600s)
|
|
68
|
+
strategy:
|
|
69
|
+
fail-fast: false
|
|
70
|
+
matrix:
|
|
71
|
+
python-version: ["3.10", "3.11"]
|
|
72
|
+
steps:
|
|
73
|
+
- uses: actions/checkout@v4
|
|
74
|
+
with:
|
|
75
|
+
fetch-depth: 0
|
|
76
|
+
|
|
77
|
+
- uses: astral-sh/setup-uv@v6
|
|
78
|
+
with:
|
|
79
|
+
python-version: ${{ matrix.python-version }}
|
|
80
|
+
enable-cache: true
|
|
81
|
+
|
|
82
|
+
- name: Install project + dev group
|
|
83
|
+
run: uv sync
|
|
84
|
+
|
|
85
|
+
- name: Run end-to-end integration tests (hit live AORC/NWM data)
|
|
86
|
+
run: uv run pytest -m integration --ignore tests/test_ngiab_data_cli_regression.py
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: Build and Push Preprocessor Docker Image
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches: [main]
|
|
6
|
+
release:
|
|
7
|
+
types: [published]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
build:
|
|
15
|
+
name: Build and Push
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- name: Checkout repository
|
|
20
|
+
uses: actions/checkout@v4
|
|
21
|
+
|
|
22
|
+
- name: Set up Docker Buildx
|
|
23
|
+
uses: docker/setup-buildx-action@v3
|
|
24
|
+
|
|
25
|
+
- name: Log in to Docker Hub
|
|
26
|
+
if: github.event_name == 'release'
|
|
27
|
+
uses: docker/login-action@v3
|
|
28
|
+
with:
|
|
29
|
+
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
30
|
+
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
31
|
+
|
|
32
|
+
- name: Build (and push image on release)
|
|
33
|
+
uses: docker/build-push-action@v6
|
|
34
|
+
with:
|
|
35
|
+
context: .
|
|
36
|
+
file: ./aws_tools/aws.dockerfile
|
|
37
|
+
push: ${{ github.event_name == 'release' }}
|
|
38
|
+
tags: |
|
|
39
|
+
awiciroh/preprocessor:latest
|
|
40
|
+
awiciroh/preprocessor:${{ github.sha }}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# How to contribute
|
|
2
|
+
|
|
3
|
+
Anyone may contribute. You do not need to be affiliated with CIROH or any partner institution. The expectations below exist to keep the projects reproducible and reviewable, not to gatekeep.
|
|
4
|
+
|
|
5
|
+
## Ways to contribute
|
|
6
|
+
|
|
7
|
+
File an issue (bugs, feature ideas, questions), open a pull request (code, configuration, tests, documentation), participate in GitHub Discussions, or improve the training and product docs.
|
|
8
|
+
|
|
9
|
+
## Standard pull request workflow
|
|
10
|
+
|
|
11
|
+
- Open or comment on an issue describing the change, so effort is not duplicated.
|
|
12
|
+
- Fork the repository (or branch, if you have write access). Name branches descriptively.
|
|
13
|
+
- Make focused changes; keep pull requests as small as practical. Signed commits are recommended.
|
|
14
|
+
- Add or update tests where applicable, and update documentation and any changelog the repository maintains.
|
|
15
|
+
- State whether the change affects model behavior, input-data assumptions, configuration, calibration, reproducibility, performance, or output interpretation, so the right reviewer is engaged.
|
|
16
|
+
- Open a pull request against the default branch, complete the PR template if present, and reference the related issue.
|
|
17
|
+
- Pass automated checks (CI, linting, tests). A maintainer reviews; address feedback.
|
|
18
|
+
|
|
19
|
+
## Contribution standards
|
|
20
|
+
|
|
21
|
+
Contributions are expected to be your own work (or properly attributed and compatibly licensed), to build and pass tests, to follow each repository's coding conventions, to include reasonable documentation, and to respect the Code of Conduct. Maintainers may request changes or, with explanation, decline contributions that fall outside project scope or that introduce incompatible licenses or unverifiable model artifacts.
|
|
22
|
+
|
|
23
|
+
## Recognition
|
|
24
|
+
|
|
25
|
+
Contributions are recognized through Git history, release notes, and citation metadata. The project values non-code contributions — documentation, evaluation, issue triage, mentoring — as first-class.
|
|
26
|
+
|
|
27
|
+
## Maintaining contributed models and components
|
|
28
|
+
|
|
29
|
+
Contributing a model, model configuration, or other substantial, separately identifiable component to NGIAB carries an ongoing responsibility: the contributor — or the institution or owner on whose behalf it was contributed — is expected to maintain it after integration. Maintenance means keeping the contribution working as the ecosystem evolves: updating it for changes in the NextGen framework, the hydrofabric, forcing formats, and the surrounding NGIAB/NRDS tooling; fixing defects attributable to the contribution; and responding to issues filed against it within a reasonable time. This responsibility attaches to substantial contributions (a BMI model, a standing NRDS configuration), not to one-off fixes to code that others maintain.
|
|
30
|
+
|
|
31
|
+
Because everything here is open source, maintenance can move: an owner who can no longer maintain a contribution may hand it off to another willing maintainer, the community may adopt it, or — if no one steps forward — it may be deprecated. The project does not guarantee to maintain contributed models on an owner's behalf.
|
|
32
|
+
|
|
33
|
+
**Unmaintained contributions.** If a contributed model or configuration breaks (for instance, after a framework or hydrofabric update) and the responsible owner is unresponsive for 30 days after a good-faith attempt to reach them, the maintainers may deprecate it or remove it from NGIAB, with notice and preservation of the public record.
|
|
34
|
+
|
|
35
|
+
## Software stack
|
|
36
|
+
|
|
37
|
+
Most contributions will improve our subsetting/forcing/realization modules or our user interfaces. For our full software stack, see below.
|
|
38
|
+
|
|
39
|
+

|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ngiab_data_preprocess
|
|
3
|
-
Version: 4.9.
|
|
3
|
+
Version: 4.9.4
|
|
4
4
|
Summary: Graphical Tools for creating Next Gen Water model input data.
|
|
5
5
|
Author-email: Josh Cunningham <jcunningham8@ua.edu>
|
|
6
6
|
Project-URL: Homepage, https://github.com/CIROH-UA/NGIAB_data_preprocess
|
|
@@ -33,7 +33,7 @@ Requires-Dist: bokeh==3.8.2
|
|
|
33
33
|
Requires-Dist: boto3
|
|
34
34
|
Requires-Dist: numcodecs<0.16.0
|
|
35
35
|
Requires-Dist: scipy>=1.15.3
|
|
36
|
-
Requires-Dist:
|
|
36
|
+
Requires-Dist: duckdb>=1.5.2
|
|
37
37
|
Provides-Extra: eval
|
|
38
38
|
Requires-Dist: ngiab_eval; extra == "eval"
|
|
39
39
|
Provides-Extra: plot
|
|
@@ -252,7 +252,9 @@ Installed with uv: `uv run cli`
|
|
|
252
252
|
- `--lstm_rust`: Configures the data for the [rust lstm](https://github.com/ciroh-ua/rust-lstm-1025/).
|
|
253
253
|
- `--dhbv2`: Configures the data for the hourly [dHBV2](https://github.com/mhpi/dhbv2).
|
|
254
254
|
- `--dhbv2_daily`: Configures the data for the daily [dHBV2](https://github.com/mhpi/dhbv2).
|
|
255
|
-
- `--summa`: Configures the data for the SUMMA model.
|
|
255
|
+
- `--summa`: Configures the data for the [SUMMA](https://github.com/CH-Earth/summa) model.
|
|
256
|
+
- `--snow17`: Configures the data for the [SNOW17](https://github.com/NOAA-OWP/snow17) model.
|
|
257
|
+
- `--sacsma`: Configures the data for the [SAC-SMA](https://github.com/NOAA-OWP/sac-sma) model.
|
|
256
258
|
- `--start_date START_DATE`, `--start START_DATE`: Start date for forcings/realization (format YYYY-MM-DD).
|
|
257
259
|
- `--end_date END_DATE`, `--end END_DATE`: End date for forcings/realization (format YYYY-MM-DD).
|
|
258
260
|
- `-o OUTPUT_NAME`, `--output_name OUTPUT_NAME`: Name of the output folder.
|
|
@@ -342,3 +344,6 @@ This tool currently offers three realizations.
|
|
|
342
344
|
|
|
343
345
|
## SUMMA
|
|
344
346
|
[This realization](https://github.com/CIROH-UA/NGIAB_data_preprocess/blob/main/modules/data_sources/config/realization/summa.json) will run the [SUMMA](https://github.com/CIROH-UA/ngen/tree/ngiab/extern/summa) model (version linked is what's currently in nextgen in a box).
|
|
347
|
+
|
|
348
|
+
# Citing this software
|
|
349
|
+
Arpita Patel, James Halgren, Zach Wills, et al. NextGen In A Box (NGIAB): Open-Source Containerization of the NextGen Framework to Enable Community-Driven Hydrology Modeling. Environmental Modelling & Software, page 106666, August 2025. ISSN 1364-8152. doi: 10.1016/j.envsoft.2025.106666. URL https://www.sciencedirect.com/science/article/pii/S1364815225003500.
|
|
@@ -210,7 +210,9 @@ Installed with uv: `uv run cli`
|
|
|
210
210
|
- `--lstm_rust`: Configures the data for the [rust lstm](https://github.com/ciroh-ua/rust-lstm-1025/).
|
|
211
211
|
- `--dhbv2`: Configures the data for the hourly [dHBV2](https://github.com/mhpi/dhbv2).
|
|
212
212
|
- `--dhbv2_daily`: Configures the data for the daily [dHBV2](https://github.com/mhpi/dhbv2).
|
|
213
|
-
- `--summa`: Configures the data for the SUMMA model.
|
|
213
|
+
- `--summa`: Configures the data for the [SUMMA](https://github.com/CH-Earth/summa) model.
|
|
214
|
+
- `--snow17`: Configures the data for the [SNOW17](https://github.com/NOAA-OWP/snow17) model.
|
|
215
|
+
- `--sacsma`: Configures the data for the [SAC-SMA](https://github.com/NOAA-OWP/sac-sma) model.
|
|
214
216
|
- `--start_date START_DATE`, `--start START_DATE`: Start date for forcings/realization (format YYYY-MM-DD).
|
|
215
217
|
- `--end_date END_DATE`, `--end END_DATE`: End date for forcings/realization (format YYYY-MM-DD).
|
|
216
218
|
- `-o OUTPUT_NAME`, `--output_name OUTPUT_NAME`: Name of the output folder.
|
|
@@ -300,3 +302,6 @@ This tool currently offers three realizations.
|
|
|
300
302
|
|
|
301
303
|
## SUMMA
|
|
302
304
|
[This realization](https://github.com/CIROH-UA/NGIAB_data_preprocess/blob/main/modules/data_sources/config/realization/summa.json) will run the [SUMMA](https://github.com/CIROH-UA/ngen/tree/ngiab/extern/summa) model (version linked is what's currently in nextgen in a box).
|
|
305
|
+
|
|
306
|
+
# Citing this software
|
|
307
|
+
Arpita Patel, James Halgren, Zach Wills, et al. NextGen In A Box (NGIAB): Open-Source Containerization of the NextGen Framework to Enable Community-Driven Hydrology Modeling. Environmental Modelling & Software, page 106666, August 2025. ISSN 1364-8152. doi: 10.1016/j.envsoft.2025.106666. URL https://www.sciencedirect.com/science/article/pii/S1364815225003500.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
FROM amazonlinux:2023 AS base
|
|
2
|
+
COPY --from=ghcr.io/astral-sh/uv:0.12.3 /uv /uvx /bin/
|
|
3
|
+
ENV UV_COMPILE_BYTECODE=1
|
|
4
|
+
|
|
5
|
+
RUN dnf -y install python3.11 python3.11-devel cmake gcc gcc-c++ make geos geos-devel
|
|
6
|
+
RUN ln -sf /usr/bin/python3.11 /usr/bin/python3 \
|
|
7
|
+
&& ln -sf /usr/bin/python3.11 /usr/bin/python
|
|
8
|
+
|
|
9
|
+
FROM base AS build
|
|
10
|
+
|
|
11
|
+
RUN mkdir /app
|
|
12
|
+
WORKDIR /app/
|
|
13
|
+
RUN uv venv -p 3.11
|
|
14
|
+
ENV PATH="/app/.venv/bin:$PATH"
|
|
15
|
+
# appease exact-extract with the special scikit-build-core version
|
|
16
|
+
COPY . .
|
|
17
|
+
RUN uv build \
|
|
18
|
+
&& echo "scikit-build-core<0.10" > /tmp/build-constraints.txt \
|
|
19
|
+
&& uv pip install dist/ngiab_data_preprocess-*.whl --build-constraint /tmp/build-constraints.txt
|
|
20
|
+
|
|
21
|
+
FROM amazonlinux:2023 AS runtime
|
|
22
|
+
|
|
23
|
+
RUN dnf -y install python3.11 \
|
|
24
|
+
&& dnf clean all \
|
|
25
|
+
&& rm -rf /var/cache/dnf
|
|
26
|
+
|
|
27
|
+
COPY --from=build /app/.venv /app/.venv
|
|
28
|
+
ENV PATH="/app/.venv/bin:$PATH"
|
|
@@ -9,6 +9,7 @@ from itertools import chain
|
|
|
9
9
|
from pathlib import Path
|
|
10
10
|
from typing import Dict, Optional
|
|
11
11
|
|
|
12
|
+
import duckdb
|
|
12
13
|
import numpy as np
|
|
13
14
|
import pandas
|
|
14
15
|
import psutil
|
|
@@ -18,7 +19,6 @@ import xarray as xr
|
|
|
18
19
|
from data_processing.dask_utils import temp_cluster
|
|
19
20
|
from data_processing.file_paths import FilePaths
|
|
20
21
|
from data_processing.gpkg_utils import get_cat_to_nhd_feature_id, get_table_crs_short
|
|
21
|
-
from data_sources.source_validation import download_dhbv_attributes, download_snow17_attributes, download_sacsma_attributes
|
|
22
22
|
from pyproj import Transformer
|
|
23
23
|
from tqdm.rich import tqdm
|
|
24
24
|
|
|
@@ -103,22 +103,28 @@ def make_noahowp_config(
|
|
|
103
103
|
end_datetime=end_datetime,
|
|
104
104
|
lat=row["latitude"],
|
|
105
105
|
lon=row["longitude"],
|
|
106
|
-
terrain_slope=
|
|
106
|
+
terrain_slope=np.degrees(
|
|
107
|
+
np.arctan(np.tan(np.radians(row["mean.slope"])) / 100)
|
|
108
|
+
),
|
|
107
109
|
azimuth=row["circ_mean.aspect"],
|
|
108
110
|
ISLTYP=int(row["mode.ISLTYP"]), # type: ignore
|
|
109
111
|
IVGTYP=int(row["mode.IVGTYP"]), # type: ignore
|
|
110
112
|
)
|
|
111
113
|
)
|
|
112
114
|
|
|
115
|
+
|
|
113
116
|
def make_snow17_config(
|
|
114
117
|
base_dir: Path, divide_conf_df: pandas.DataFrame, start_time: datetime, end_time: datetime
|
|
115
118
|
) -> None:
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
merged =
|
|
119
|
+
snow17_atts = duckdb.sql(f"""
|
|
120
|
+
SELECT * FROM '{FilePaths.snow17_attributes}'
|
|
121
|
+
WHERE divide_id IN {tuple(divide_conf_df["divide_id"])}
|
|
122
|
+
""").df()
|
|
123
|
+
|
|
124
|
+
merged = snow17_atts.merge(
|
|
125
|
+
divide_conf_df[["divide_id", "areasqkm", "lengthkm", "latitude", "mean.elevation"]],
|
|
126
|
+
on="divide_id",
|
|
127
|
+
)
|
|
122
128
|
|
|
123
129
|
start_datetime = start_time.strftime("%Y%m%d%H")
|
|
124
130
|
end_datetime = end_time.strftime("%Y%m%d%H")
|
|
@@ -132,7 +138,7 @@ def make_snow17_config(
|
|
|
132
138
|
with open(cat_config_dir / f"{row['divide_id']}.input", "w") as file:
|
|
133
139
|
file.write(
|
|
134
140
|
config_template.format(
|
|
135
|
-
divide_id=row[
|
|
141
|
+
divide_id=row["divide_id"],
|
|
136
142
|
start_datetime=start_datetime,
|
|
137
143
|
end_datetime=end_datetime,
|
|
138
144
|
)
|
|
@@ -145,19 +151,45 @@ def make_snow17_config(
|
|
|
145
151
|
with open(cat_config_dir / f"params-{row['divide_id']}.txt", "w") as file:
|
|
146
152
|
file.write(
|
|
147
153
|
params_template.format(
|
|
148
|
-
|
|
154
|
+
divide_id=row["divide_id"],
|
|
155
|
+
areasqkm=row["areasqkm"],
|
|
156
|
+
latitude=row["latitude"],
|
|
149
157
|
elevation=row["mean.elevation"] / 100, # convert cm in hf to m
|
|
158
|
+
scf=row["scf"],
|
|
159
|
+
mfmax=row["mfmax"],
|
|
160
|
+
mfmin=row["mfmin"],
|
|
161
|
+
uadj=row["uadj"],
|
|
162
|
+
si=row["si"],
|
|
163
|
+
pxtemp=row["pxtemp"],
|
|
164
|
+
nmf=row["nmf"],
|
|
165
|
+
tipm=row["tipm"],
|
|
166
|
+
mbase=row["mbase"],
|
|
167
|
+
plwhc=row["plwhc"],
|
|
168
|
+
daygm=row["daygm"],
|
|
169
|
+
adc1=row["adc1"],
|
|
170
|
+
adc2=row["adc2"],
|
|
171
|
+
adc3=row["adc3"],
|
|
172
|
+
adc4=row["adc4"],
|
|
173
|
+
adc5=row["adc5"],
|
|
174
|
+
adc6=row["adc6"],
|
|
175
|
+
adc7=row["adc7"],
|
|
176
|
+
adc8=row["adc8"],
|
|
177
|
+
adc9=row["adc9"],
|
|
178
|
+
adc10=row["adc10"],
|
|
179
|
+
adc11=row["adc11"],
|
|
150
180
|
)
|
|
151
181
|
)
|
|
152
182
|
|
|
183
|
+
|
|
153
184
|
def make_sacsma_config(
|
|
154
185
|
base_dir: Path, divide_conf_df: pandas.DataFrame, start_time: datetime, end_time: datetime
|
|
155
186
|
) -> None:
|
|
187
|
+
sacsma_atts = duckdb.sql(f"""
|
|
188
|
+
SELECT * FROM '{FilePaths.sacsma_attributes}'
|
|
189
|
+
WHERE divide_id IN {tuple(divide_conf_df["divide_id"])}
|
|
190
|
+
""").df()
|
|
156
191
|
|
|
157
|
-
|
|
158
|
-
sacsma_atts = pandas.read_parquet(FilePaths.sacsma_attributes)
|
|
159
|
-
atts_df = sacsma_atts.loc[sacsma_atts["divide_id"].isin(divide_conf_df["divide_id"])]
|
|
160
|
-
merged = atts_df.merge(divide_conf_df[["divide_id", "areasqkm"]], on="divide_id")
|
|
192
|
+
merged = sacsma_atts.merge(divide_conf_df[["divide_id", "areasqkm"]], on="divide_id")
|
|
161
193
|
|
|
162
194
|
start_datetime = start_time.strftime("%Y%m%d%H")
|
|
163
195
|
end_datetime = end_time.strftime("%Y%m%d%H")
|
|
@@ -171,7 +203,7 @@ def make_sacsma_config(
|
|
|
171
203
|
with open(cat_config_dir / f"{row['divide_id']}.input", "w") as file:
|
|
172
204
|
file.write(
|
|
173
205
|
config_template.format(
|
|
174
|
-
divide_id=row[
|
|
206
|
+
divide_id=row["divide_id"],
|
|
175
207
|
start_datetime=start_datetime,
|
|
176
208
|
end_datetime=end_datetime,
|
|
177
209
|
)
|
|
@@ -184,27 +216,28 @@ def make_sacsma_config(
|
|
|
184
216
|
with open(cat_config_dir / f"params-{row['divide_id']}.txt", "w") as file:
|
|
185
217
|
file.write(
|
|
186
218
|
params_template.format(
|
|
187
|
-
divide_id=row[
|
|
188
|
-
areasqkm=row[
|
|
189
|
-
uztwm=row[
|
|
190
|
-
uzfwm=row[
|
|
191
|
-
lztwm=row[
|
|
192
|
-
lzfpm=row[
|
|
193
|
-
lzfsm=row[
|
|
194
|
-
adimp=row[
|
|
195
|
-
uzk=row[
|
|
196
|
-
lzpk=row[
|
|
197
|
-
lzsk=row[
|
|
198
|
-
zperc=row[
|
|
199
|
-
rexp=row[
|
|
200
|
-
pctim=row[
|
|
201
|
-
pfree=row[
|
|
202
|
-
riva=row[
|
|
203
|
-
side=row[
|
|
204
|
-
rserv=row[
|
|
219
|
+
divide_id=row["divide_id"],
|
|
220
|
+
areasqkm=row["areasqkm"],
|
|
221
|
+
uztwm=row["uztwm"],
|
|
222
|
+
uzfwm=row["uzfwm"],
|
|
223
|
+
lztwm=row["lztwm"],
|
|
224
|
+
lzfpm=row["lzfpm"],
|
|
225
|
+
lzfsm=row["lzfsm"],
|
|
226
|
+
adimp=row["adimp"],
|
|
227
|
+
uzk=row["uzk"],
|
|
228
|
+
lzpk=row["lzpk"],
|
|
229
|
+
lzsk=row["lzsk"],
|
|
230
|
+
zperc=row["zperc"],
|
|
231
|
+
rexp=row["rexp"],
|
|
232
|
+
pctim=row["pctim"],
|
|
233
|
+
pfree=row["pfree"],
|
|
234
|
+
riva=row["riva"],
|
|
235
|
+
side=row["side"],
|
|
236
|
+
rserv=row["rserv"],
|
|
205
237
|
)
|
|
206
238
|
)
|
|
207
239
|
|
|
240
|
+
|
|
208
241
|
def get_model_attributes(hydrofabric: Path, layer: str = "divides") -> pandas.DataFrame:
|
|
209
242
|
with sqlite3.connect(hydrofabric) as conn:
|
|
210
243
|
conf_df = pandas.read_sql_query(
|
|
@@ -238,13 +271,8 @@ def make_lstm_config(
|
|
|
238
271
|
shutil.rmtree(cat_config_dir)
|
|
239
272
|
cat_config_dir.mkdir(parents=True, exist_ok=True)
|
|
240
273
|
|
|
241
|
-
# convert the mean.slope from degrees
|
|
242
|
-
|
|
243
|
-
divide_conf_df["flipped_mean_slope"] = abs(divide_conf_df["mean.slope"] - 90)
|
|
244
|
-
# Convert degrees to meters per kmmeter
|
|
245
|
-
divide_conf_df["mean_slope_mpkm"] = (
|
|
246
|
-
np.tan(np.radians(divide_conf_df["flipped_mean_slope"])) * 1000
|
|
247
|
-
)
|
|
274
|
+
# convert the mean.slope from degrees cm/m to m/km
|
|
275
|
+
divide_conf_df["mean_slope_mpkm"] = np.tan(np.radians(divide_conf_df["mean.slope"])) * 10
|
|
248
276
|
|
|
249
277
|
with open(template_path, "r") as file:
|
|
250
278
|
template = file.read()
|
|
@@ -270,30 +298,35 @@ def make_dhbv2_config(
|
|
|
270
298
|
start_time: datetime,
|
|
271
299
|
end_time: datetime,
|
|
272
300
|
template_path: Path = FilePaths.template_dhbv2_config,
|
|
301
|
+
output_suffix: str = "",
|
|
302
|
+
clear_dir: bool = True,
|
|
273
303
|
):
|
|
274
304
|
divide_conf_df = get_model_attributes(hydrofabric)
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
305
|
+
dhbv_atts = duckdb.sql(f"""
|
|
306
|
+
SELECT * FROM '{FilePaths.dhbv_attributes}'
|
|
307
|
+
WHERE divide_id IN {tuple(divide_conf_df["divide_id"])}
|
|
308
|
+
""").df()
|
|
309
|
+
if template_path == FilePaths.template_dhbv2_daily_config:
|
|
310
|
+
cat_config_dir = output_dir / "cat_config" / "dhbv2_daily"
|
|
311
|
+
else:
|
|
312
|
+
cat_config_dir = output_dir / "cat_config" / "dhbv2"
|
|
313
|
+
if cat_config_dir.exists() and clear_dir:
|
|
281
314
|
shutil.rmtree(cat_config_dir)
|
|
282
315
|
cat_config_dir.mkdir(parents=True, exist_ok=True)
|
|
283
316
|
|
|
284
317
|
template = template_path.read_text()
|
|
285
|
-
merged =
|
|
318
|
+
merged = dhbv_atts.merge(
|
|
286
319
|
divide_conf_df[["divide_id", "areasqkm", "lengthkm", "latitude"]], on="divide_id"
|
|
287
320
|
)
|
|
288
321
|
|
|
289
322
|
for _, row in merged.iterrows():
|
|
290
|
-
(cat_config_dir / f"{row['divide_id']}.yml").write_text(
|
|
323
|
+
(cat_config_dir / f"{row['divide_id']}{output_suffix}.yml").write_text(
|
|
291
324
|
template.format(
|
|
292
325
|
**row,
|
|
293
326
|
start_time=start_time,
|
|
294
327
|
end_time=end_time,
|
|
295
328
|
start_date=start_time.strftime("%Y/%m/%d"),
|
|
296
|
-
start_time_str=start_time.strftime("%Y/%m/%d %H")
|
|
329
|
+
start_time_str=start_time.strftime("%Y/%m/%d %H"),
|
|
297
330
|
)
|
|
298
331
|
)
|
|
299
332
|
|
|
@@ -316,7 +349,8 @@ def configure_troute(
|
|
|
316
349
|
with open(FilePaths.template_troute_config, "r") as file:
|
|
317
350
|
troute_template = file.read()
|
|
318
351
|
time_step_size = 300
|
|
319
|
-
|
|
352
|
+
output_name = Path(cat_id).name
|
|
353
|
+
gpkg_file_path = config_dir / f"{output_name}_subset.gpkg"
|
|
320
354
|
nts = (end_time - start_time).total_seconds() / time_step_size
|
|
321
355
|
with sqlite3.connect(gpkg_file_path) as conn:
|
|
322
356
|
ncats_df = pandas.read_sql_query("SELECT COUNT(id) FROM 'divides';", conn)
|
|
@@ -344,7 +378,7 @@ def configure_troute(
|
|
|
344
378
|
time_step_size=time_step_size,
|
|
345
379
|
# troute seems to be ok with setting this to your cpu_count
|
|
346
380
|
cpu_pool=multiprocessing.cpu_count(),
|
|
347
|
-
geo_file_path=f"./config/{
|
|
381
|
+
geo_file_path=f"./config/{output_name}_subset.gpkg",
|
|
348
382
|
start_datetime=start_time.strftime("%Y-%m-%d %H:%M:%S"),
|
|
349
383
|
nts=nts,
|
|
350
384
|
max_loop_size=max_loop_size,
|
|
@@ -462,9 +496,8 @@ def make_summa_attributes(hru_ids, hydrofabric):
|
|
|
462
496
|
# Convert elevation from cm to m
|
|
463
497
|
elevation = df["mean.elevation"].values / 100.0
|
|
464
498
|
|
|
465
|
-
# Convert mean.slope (degrees,
|
|
466
|
-
|
|
467
|
-
tan_slope = np.tan(np.radians(flipped))
|
|
499
|
+
# Convert mean.slope (degrees, cm/m) to tan_slope (m/m)
|
|
500
|
+
tan_slope = np.tan(np.radians((df["mean.slope"].values))) / 100.0
|
|
468
501
|
|
|
469
502
|
ds = xr.Dataset(
|
|
470
503
|
{
|
|
@@ -677,8 +710,14 @@ def create_summa_realization(cat_id: str, start_time: datetime, end_time: dateti
|
|
|
677
710
|
make_summa_config(hru_ids, paths.config_dir)
|
|
678
711
|
paths.setup_run_folders(["outputs/summa"])
|
|
679
712
|
|
|
680
|
-
|
|
681
|
-
|
|
713
|
+
|
|
714
|
+
def create_snow17_realization(
|
|
715
|
+
cat_id: str,
|
|
716
|
+
start_time: datetime,
|
|
717
|
+
end_time: datetime,
|
|
718
|
+
use_nwm_gw: bool = False,
|
|
719
|
+
gage_id: Optional[str] = None,
|
|
720
|
+
):
|
|
682
721
|
paths = FilePaths(cat_id)
|
|
683
722
|
|
|
684
723
|
conf_df = get_model_attributes(paths.geopackage_path)
|
|
@@ -700,9 +739,10 @@ def create_snow17_realization(cat_id: str, start_time: datetime, end_time: datet
|
|
|
700
739
|
)
|
|
701
740
|
paths.setup_run_folders()
|
|
702
741
|
|
|
703
|
-
def create_sacsma_realization(cat_id: str, start_time: datetime, end_time: datetime,
|
|
704
|
-
gage_id: Optional[str] = None):
|
|
705
742
|
|
|
743
|
+
def create_sacsma_realization(
|
|
744
|
+
cat_id: str, start_time: datetime, end_time: datetime, gage_id: Optional[str] = None
|
|
745
|
+
):
|
|
706
746
|
paths = FilePaths(cat_id)
|
|
707
747
|
|
|
708
748
|
conf_df = get_model_attributes(paths.geopackage_path)
|
|
@@ -718,6 +758,7 @@ def create_sacsma_realization(cat_id: str, start_time: datetime, end_time: datet
|
|
|
718
758
|
)
|
|
719
759
|
paths.setup_run_folders()
|
|
720
760
|
|
|
761
|
+
|
|
721
762
|
def create_realization(
|
|
722
763
|
cat_id: str,
|
|
723
764
|
start_time: datetime,
|
{ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_processing/dask_utils.py
RENAMED
|
@@ -1,10 +1,41 @@
|
|
|
1
1
|
import logging
|
|
2
|
+
import os
|
|
2
3
|
|
|
3
4
|
from dask.distributed import Client
|
|
4
5
|
|
|
5
6
|
logger = logging.getLogger(__name__)
|
|
6
7
|
|
|
7
8
|
|
|
9
|
+
def _env_n_workers():
|
|
10
|
+
# Set workers from an environment variable, if it is a valid integer.
|
|
11
|
+
value = os.environ.get("NGIAB_DASK_WORKERS")
|
|
12
|
+
if value:
|
|
13
|
+
try:
|
|
14
|
+
return int(value)
|
|
15
|
+
except ValueError:
|
|
16
|
+
logger.warning("Invalid NGIAB_DASK_WORKERS=%r, ignoring", value)
|
|
17
|
+
return None
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# Variable to store the number of workers
|
|
21
|
+
_n_workers = _env_n_workers()
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# set n_workers from CLI or other code
|
|
25
|
+
def set_n_workers(n_workers):
|
|
26
|
+
"""Set the number of workers used whenever this package creates a Dask cluster."""
|
|
27
|
+
global _n_workers
|
|
28
|
+
_n_workers = n_workers
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# replace of Client()
|
|
32
|
+
def _new_client():
|
|
33
|
+
# If not set from the environment, the number of workers will be determined by Dask's defaults.
|
|
34
|
+
if _n_workers is not None:
|
|
35
|
+
logger.info("Starting Dask cluster with %d workers", _n_workers)
|
|
36
|
+
return Client(n_workers=_n_workers)
|
|
37
|
+
|
|
38
|
+
|
|
8
39
|
def shutdown_cluster():
|
|
9
40
|
try:
|
|
10
41
|
client = Client.current()
|
|
@@ -55,7 +86,7 @@ def use_cluster(func):
|
|
|
55
86
|
try:
|
|
56
87
|
client = Client.current()
|
|
57
88
|
except ValueError:
|
|
58
|
-
client =
|
|
89
|
+
client = _new_client()
|
|
59
90
|
result = func(*args, **kwargs)
|
|
60
91
|
return result
|
|
61
92
|
|
|
@@ -83,7 +114,7 @@ def temp_cluster(func):
|
|
|
83
114
|
client = Client.current()
|
|
84
115
|
except ValueError:
|
|
85
116
|
cluster_was_running = False
|
|
86
|
-
client =
|
|
117
|
+
client = _new_client()
|
|
87
118
|
result = func(*args, **kwargs)
|
|
88
119
|
if not cluster_was_running:
|
|
89
120
|
client.shutdown()
|
{ngiab_data_preprocess-4.9.2 → ngiab_data_preprocess-4.9.4}/modules/data_processing/file_paths.py
RENAMED
|
@@ -9,6 +9,8 @@ class FilePaths:
|
|
|
9
9
|
workflow.
|
|
10
10
|
"""
|
|
11
11
|
|
|
12
|
+
hf_bucket = "https://communityhydrofabric.s3.us-east-1.amazonaws.com/"
|
|
13
|
+
resource_key = "hydrofabrics/community/resources/"
|
|
12
14
|
config_file = Path("~/.ngiab/preprocessor").expanduser()
|
|
13
15
|
hydrofabric_dir = Path("~/.ngiab/hydrofabric/v2.2").expanduser()
|
|
14
16
|
hydrofabric_download_log = Path("~/.ngiab/hydrofabric/v2.2/download_log.json").expanduser()
|
|
@@ -19,9 +21,9 @@ class FilePaths:
|
|
|
19
21
|
template_sql = data_sources / "template.sql"
|
|
20
22
|
triggers_sql = data_sources / "triggers.sql"
|
|
21
23
|
conus_hydrofabric = hydrofabric_dir / "conus_nextgen.gpkg"
|
|
22
|
-
dhbv_attributes =
|
|
23
|
-
snow17_attributes =
|
|
24
|
-
sacsma_attributes =
|
|
24
|
+
dhbv_attributes = hf_bucket + resource_key + "dhbv_attrs_sorted.parquet"
|
|
25
|
+
snow17_attributes = hf_bucket + resource_key + "snow17_attributes_sorted.parquet"
|
|
26
|
+
sacsma_attributes = hf_bucket + resource_key + "sacsma_attributes_sorted.parquet"
|
|
25
27
|
hydrofabric_graph = hydrofabric_dir / "conus_igraph_network.gpickle"
|
|
26
28
|
dev_file = Path(__file__).parent.parent.parent / ".dev"
|
|
27
29
|
template_troute_config = data_sources / "ngen-routing-template.yaml"
|
|
@@ -64,11 +66,18 @@ class FilePaths:
|
|
|
64
66
|
if (not folder_name and not output_dir) or (folder_name and output_dir):
|
|
65
67
|
raise ValueError("please pass either folder_name or output_dir")
|
|
66
68
|
if folder_name:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
folder_path = Path(folder_name).expanduser()
|
|
70
|
+
|
|
71
|
+
if folder_path.is_absolute() or folder_path.parent != Path("."):
|
|
72
|
+
self.output_dir = folder_path.resolve()
|
|
73
|
+
self.folder_name = folder_path.name
|
|
74
|
+
else:
|
|
75
|
+
self.folder_name = folder_name
|
|
76
|
+
self.output_dir = self.root_output_dir() / folder_name
|
|
77
|
+
|
|
69
78
|
if output_dir:
|
|
70
|
-
self.output_dir = Path(output_dir)
|
|
71
|
-
self.folder_name = self.output_dir.
|
|
79
|
+
self.output_dir = Path(output_dir).expanduser().resolve()
|
|
80
|
+
self.folder_name = self.output_dir.name
|
|
72
81
|
|
|
73
82
|
@classmethod
|
|
74
83
|
def get_working_dir(cls) -> Path | None:
|