ngiab-data-preprocess 4.9.3__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.
Files changed (110) hide show
  1. ngiab_data_preprocess-4.9.4/.dockerignore +6 -0
  2. ngiab_data_preprocess-4.9.4/.github/workflows/ci.yml +86 -0
  3. ngiab_data_preprocess-4.9.4/.github/workflows/docker.yml +40 -0
  4. ngiab_data_preprocess-4.9.4/CONTRIBUTING.md +39 -0
  5. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/PKG-INFO +8 -3
  6. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/README.md +6 -1
  7. ngiab_data_preprocess-4.9.4/aws_tools/aws.dockerfile +28 -0
  8. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_processing/create_realization.py +53 -24
  9. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_processing/dask_utils.py +33 -2
  10. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_processing/file_paths.py +16 -7
  11. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_processing/forcings.py +68 -12
  12. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_processing/gpkg_utils.py +4 -4
  13. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_processing/graph_utils.py +29 -9
  14. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_processing/subset.py +6 -2
  15. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/SUMMA/outputControl.txt +7 -7
  16. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/catchment/noah-owp-modular-init.namelist.input +2 -2
  17. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/source_validation.py +0 -70
  18. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/ngiab_data_cli/__main__.py +19 -9
  19. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/ngiab_data_cli/arguments.py +34 -6
  20. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/ngiab_data_cli/forcing_cli.py +17 -2
  21. ngiab_data_preprocess-4.9.4/modules/ngiab_data_cli/subset_cli.py +62 -0
  22. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/ngiab_data_preprocess.egg-info/PKG-INFO +8 -3
  23. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/ngiab_data_preprocess.egg-info/SOURCES.txt +33 -1
  24. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/ngiab_data_preprocess.egg-info/entry_points.txt +1 -0
  25. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/ngiab_data_preprocess.egg-info/requires.txt +1 -1
  26. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/pyproject.toml +6 -2
  27. ngiab_data_preprocess-4.9.4/stack.drawio.svg +4 -0
  28. ngiab_data_preprocess-4.9.4/tests/golden/config/cat-1555522-summa.json +14 -0
  29. ngiab_data_preprocess-4.9.4/tests/golden/config/cat-1555522.json +12 -0
  30. ngiab_data_preprocess-4.9.4/tests/golden/config/gage-10109001-summa.json +101 -0
  31. ngiab_data_preprocess-4.9.4/tests/golden/config/gage-10109001.json +795 -0
  32. ngiab_data_preprocess-4.9.4/tests/golden/geopackage/cat-1555522_subset.gpkg +0 -0
  33. ngiab_data_preprocess-4.9.4/tests/golden/geopackage/gage-10109001_subset.gpkg +0 -0
  34. ngiab_data_preprocess-4.9.4/tests/golden/netcdf/cat-1555522-attributes.json +124 -0
  35. ngiab_data_preprocess-4.9.4/tests/golden/netcdf/cat-1555522-coldState.json +272 -0
  36. ngiab_data_preprocess-4.9.4/tests/golden/netcdf/cat-1555522-trialParams.json +28 -0
  37. ngiab_data_preprocess-4.9.4/tests/golden/netcdf/gage-10109001-attributes.json +1342 -0
  38. ngiab_data_preprocess-4.9.4/tests/golden/netcdf/gage-10109001-coldState.json +3056 -0
  39. ngiab_data_preprocess-4.9.4/tests/golden/netcdf/gage-10109001-trialParams.json +202 -0
  40. ngiab_data_preprocess-4.9.4/tests/golden/realization/cfe-nom.json +97 -0
  41. ngiab_data_preprocess-4.9.4/tests/golden/realization/dhbv2-daily.json +54 -0
  42. ngiab_data_preprocess-4.9.4/tests/golden/realization/dhbv2.json +54 -0
  43. ngiab_data_preprocess-4.9.4/tests/golden/realization/lstm-py.json +45 -0
  44. ngiab_data_preprocess-4.9.4/tests/golden/realization/lstm-rs.json +46 -0
  45. ngiab_data_preprocess-4.9.4/tests/golden/realization/sacsma-nom.json +74 -0
  46. ngiab_data_preprocess-4.9.4/tests/golden/realization/snow17-nom-cfe.json +114 -0
  47. ngiab_data_preprocess-4.9.4/tests/golden/realization/summa.json +55 -0
  48. ngiab_data_preprocess-4.9.4/tests/test_cell_weights.py +24 -0
  49. ngiab_data_preprocess-4.9.4/tests/test_config_generation.py +286 -0
  50. ngiab_data_preprocess-4.9.4/tests/test_forcings_regression.py +308 -0
  51. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/tests/test_nan_impute.py +43 -0
  52. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/tests/test_ngiab_data_cli_regression.py +2 -0
  53. ngiab_data_preprocess-4.9.4/tests/test_realization_templates.py +106 -0
  54. ngiab_data_preprocess-4.9.4/tests/test_summa_config_generation.py +521 -0
  55. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/.github/pull_request_template.md +0 -0
  56. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/.github/workflows/build_only.yml +0 -0
  57. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/.github/workflows/publish.yml +0 -0
  58. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/.gitignore +0 -0
  59. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/CITATION.cff +0 -0
  60. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/LICENSE +0 -0
  61. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/ciroh-bgsafe.png +0 -0
  62. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_processing/dataset_utils.py +0 -0
  63. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_processing/datasets.py +0 -0
  64. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_processing/s3fs_utils.py +0 -0
  65. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/SUMMA/README.md +0 -0
  66. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/SUMMA/TBL_GENPARM.TBL +0 -0
  67. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/SUMMA/TBL_MPTABLE.TBL +0 -0
  68. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/SUMMA/TBL_SOILPARM.TBL +0 -0
  69. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/SUMMA/TBL_VEGPARM.TBL +0 -0
  70. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/SUMMA/basinParamInfo.txt +0 -0
  71. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/SUMMA/fileManager.txt +0 -0
  72. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/SUMMA/forcingFileList.txt +0 -0
  73. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/SUMMA/localParamInfo.txt +0 -0
  74. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/SUMMA/modelDecisions.txt +0 -0
  75. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/catchment/cfe.ini +0 -0
  76. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/catchment/dhbv2-daily.yaml +0 -0
  77. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/catchment/dhbv2.yaml +0 -0
  78. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/catchment/lstm.yml +0 -0
  79. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/catchment/sac-init.namelist.input +0 -0
  80. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/catchment/sac-params.txt +0 -0
  81. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/catchment/snow17-init.namelist.input +0 -0
  82. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/catchment/snow17-params.txt +0 -0
  83. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/catchment/summa.input +0 -0
  84. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/realization/cfe-nom.json +0 -0
  85. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/realization/dhbv2-daily.json +0 -0
  86. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/realization/dhbv2.json +0 -0
  87. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/realization/lstm-py.json +0 -0
  88. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/realization/lstm-rs.json +0 -0
  89. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/realization/sacsma-nom.json +0 -0
  90. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/realization/snow17-nom-cfe.json +0 -0
  91. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/config/realization/summa.json +0 -0
  92. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/ngen-routing-template.yaml +0 -0
  93. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/template.sql +0 -0
  94. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/data_sources/triggers.sql +0 -0
  95. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/map_app/__init__.py +0 -0
  96. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/map_app/__main__.py +0 -0
  97. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/map_app/static/css/console.css +0 -0
  98. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/map_app/static/css/main.css +0 -0
  99. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/map_app/static/css/toggle.css +0 -0
  100. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/map_app/static/js/console.js +0 -0
  101. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/map_app/static/js/data_processing.js +0 -0
  102. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/map_app/static/js/main.js +0 -0
  103. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/map_app/static/resources/loading.gif +0 -0
  104. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/map_app/static/resources/screenshot.jpg +0 -0
  105. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/map_app/templates/index.html +0 -0
  106. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/map_app/views.py +0 -0
  107. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/ngiab_data_cli/custom_logging.py +0 -0
  108. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/ngiab_data_preprocess.egg-info/dependency_links.txt +0 -0
  109. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/modules/ngiab_data_preprocess.egg-info/top_level.txt +0 -0
  110. {ngiab_data_preprocess-4.9.3 → ngiab_data_preprocess-4.9.4}/setup.cfg +0 -0
@@ -0,0 +1,6 @@
1
+ .venv
2
+ .github
3
+ *.png
4
+ *.svg
5
+ *.md
6
+ *.cff
@@ -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
+ ![software stack](./stack.drawio.svg)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ngiab_data_preprocess
3
- Version: 4.9.3
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: pyarrow
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,11 +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 (
22
- download_dhbv_attributes,
23
- download_sacsma_attributes,
24
- download_snow17_attributes,
25
- )
26
22
  from pyproj import Transformer
27
23
  from tqdm.rich import tqdm
28
24
 
@@ -120,11 +116,12 @@ def make_noahowp_config(
120
116
  def make_snow17_config(
121
117
  base_dir: Path, divide_conf_df: pandas.DataFrame, start_time: datetime, end_time: datetime
122
118
  ) -> None:
123
- download_snow17_attributes()
124
- snow17_atts = pandas.read_parquet(FilePaths.snow17_attributes)
125
- atts_df = snow17_atts.loc[snow17_atts["divide_id"].isin(divide_conf_df["divide_id"])]
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()
126
123
 
127
- merged = atts_df.merge(
124
+ merged = snow17_atts.merge(
128
125
  divide_conf_df[["divide_id", "areasqkm", "lengthkm", "latitude", "mean.elevation"]],
129
126
  on="divide_id",
130
127
  )
@@ -154,8 +151,32 @@ def make_snow17_config(
154
151
  with open(cat_config_dir / f"params-{row['divide_id']}.txt", "w") as file:
155
152
  file.write(
156
153
  params_template.format(
157
- **row,
154
+ divide_id=row["divide_id"],
155
+ areasqkm=row["areasqkm"],
156
+ latitude=row["latitude"],
158
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"],
159
180
  )
160
181
  )
161
182
 
@@ -163,10 +184,12 @@ def make_snow17_config(
163
184
  def make_sacsma_config(
164
185
  base_dir: Path, divide_conf_df: pandas.DataFrame, start_time: datetime, end_time: datetime
165
186
  ) -> None:
166
- download_sacsma_attributes()
167
- sacsma_atts = pandas.read_parquet(FilePaths.sacsma_attributes)
168
- atts_df = sacsma_atts.loc[sacsma_atts["divide_id"].isin(divide_conf_df["divide_id"])]
169
- merged = atts_df.merge(divide_conf_df[["divide_id", "areasqkm"]], on="divide_id")
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()
191
+
192
+ merged = sacsma_atts.merge(divide_conf_df[["divide_id", "areasqkm"]], on="divide_id")
170
193
 
171
194
  start_datetime = start_time.strftime("%Y%m%d%H")
172
195
  end_datetime = end_time.strftime("%Y%m%d%H")
@@ -275,24 +298,29 @@ def make_dhbv2_config(
275
298
  start_time: datetime,
276
299
  end_time: datetime,
277
300
  template_path: Path = FilePaths.template_dhbv2_config,
301
+ output_suffix: str = "",
302
+ clear_dir: bool = True,
278
303
  ):
279
304
  divide_conf_df = get_model_attributes(hydrofabric)
280
- download_dhbv_attributes()
281
- dhbv_atts = pandas.read_parquet(FilePaths.dhbv_attributes)
282
- atts_df = dhbv_atts.loc[dhbv_atts["divide_id"].isin(divide_conf_df["divide_id"])]
283
-
284
- cat_config_dir = output_dir / "cat_config" / "dhbv2"
285
- if cat_config_dir.exists():
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:
286
314
  shutil.rmtree(cat_config_dir)
287
315
  cat_config_dir.mkdir(parents=True, exist_ok=True)
288
316
 
289
317
  template = template_path.read_text()
290
- merged = atts_df.merge(
318
+ merged = dhbv_atts.merge(
291
319
  divide_conf_df[["divide_id", "areasqkm", "lengthkm", "latitude"]], on="divide_id"
292
320
  )
293
321
 
294
322
  for _, row in merged.iterrows():
295
- (cat_config_dir / f"{row['divide_id']}.yml").write_text(
323
+ (cat_config_dir / f"{row['divide_id']}{output_suffix}.yml").write_text(
296
324
  template.format(
297
325
  **row,
298
326
  start_time=start_time,
@@ -321,7 +349,8 @@ def configure_troute(
321
349
  with open(FilePaths.template_troute_config, "r") as file:
322
350
  troute_template = file.read()
323
351
  time_step_size = 300
324
- gpkg_file_path = f"{config_dir}/{cat_id}_subset.gpkg"
352
+ output_name = Path(cat_id).name
353
+ gpkg_file_path = config_dir / f"{output_name}_subset.gpkg"
325
354
  nts = (end_time - start_time).total_seconds() / time_step_size
326
355
  with sqlite3.connect(gpkg_file_path) as conn:
327
356
  ncats_df = pandas.read_sql_query("SELECT COUNT(id) FROM 'divides';", conn)
@@ -349,7 +378,7 @@ def configure_troute(
349
378
  time_step_size=time_step_size,
350
379
  # troute seems to be ok with setting this to your cpu_count
351
380
  cpu_pool=multiprocessing.cpu_count(),
352
- geo_file_path=f"./config/{cat_id}_subset.gpkg",
381
+ geo_file_path=f"./config/{output_name}_subset.gpkg",
353
382
  start_datetime=start_time.strftime("%Y-%m-%d %H:%M:%S"),
354
383
  nts=nts,
355
384
  max_loop_size=max_loop_size,
@@ -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 = 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 = Client()
117
+ client = _new_client()
87
118
  result = func(*args, **kwargs)
88
119
  if not cluster_was_running:
89
120
  client.shutdown()
@@ -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 = hydrofabric_dir / "dhbv_attrs.parquet"
23
- snow17_attributes = hydrofabric_dir / "snow17_attributes.parquet"
24
- sacsma_attributes = hydrofabric_dir / "sacsma_attributes.parquet"
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
- self.folder_name = folder_name
68
- self.output_dir = self.root_output_dir() / folder_name
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.stem
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:
@@ -100,10 +100,13 @@ def get_cell_weights(raster: xr.Dataset, gdf: gpd.GeoDataFrame, wkt: str) -> pd.
100
100
  DataFrame indexed by divide_id that contains information about coverage
101
101
  for each raster cell in gridded forcing file.
102
102
  """
103
- xmin = min(raster.x)
104
- xmax = max(raster.x)
105
- ymin = min(raster.y)
106
- ymax = max(raster.y)
103
+ # NumPyRasterSource takes the raster's outer edges; x and y hold cell centres.
104
+ dx = abs(float(raster.x[1] - raster.x[0]))
105
+ dy = abs(float(raster.y[1] - raster.y[0]))
106
+ xmin = float(raster.x.min()) - dx / 2
107
+ xmax = float(raster.x.max()) + dx / 2
108
+ ymin = float(raster.y.min()) - dy / 2
109
+ ymax = float(raster.y.max()) + dy / 2
107
110
  data_vars = list(raster.data_vars)
108
111
  rastersource = NumPyRasterSource(
109
112
  raster[data_vars[0]], srs_wkt=wkt, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax
@@ -313,11 +316,29 @@ def get_units(dataset: xr.Dataset) -> dict:
313
316
  return units
314
317
 
315
318
 
319
+ # Interpolating precipitation intensity across a long gap adds rain no source reports, so
320
+ # precipitation is interpolated only across short gaps and is zero across longer ones (#236).
321
+ PRECIPITATION_VARIABLES = ("precip_rate", "APCP_surface")
322
+
323
+
324
+ def long_gaps(var: xr.DataArray, dim: str, max_gap: int) -> xr.DataArray:
325
+ """Return a boolean mask with var's dimensions, dim last: True where a value is missing in a
326
+ run of more than max_gap steps along dim, or in a run at the start or end of the series."""
327
+ var = var.transpose(..., dim)
328
+ valid = var.notnull().values
329
+ steps = np.arange(valid.shape[-1])
330
+ before = np.maximum.accumulate(np.where(valid, steps, -1), axis=-1)
331
+ after = np.minimum.accumulate(np.where(valid, steps, steps.size)[..., ::-1], axis=-1)[..., ::-1]
332
+ long = ~valid & ((before < 0) | (after == steps.size) | (after - before - 1 > max_gap))
333
+ return var.copy(data=long)
334
+
335
+
316
336
  def interpolate_nan_values(
317
337
  dataset: xr.Dataset,
318
338
  dim: str = "time",
319
339
  method: InterpOptions = "linear",
320
340
  fill_value: str = "extrapolate",
341
+ precip_max_gap: int = 6,
321
342
  ) -> bool:
322
343
  """
323
344
  Interpolates NaN values in specified (or all numeric time-dependent)
@@ -336,6 +357,12 @@ def interpolate_nan_values(
336
357
  Method for filling NaNs at the start/end of the series after interpolation.
337
358
  Set to "extrapolate" to fill with the nearest valid value when using 'nearest' or 'linear'.
338
359
  Default is "extrapolate".
360
+ precip_max_gap : int, optional
361
+ The most missing steps in a row that precipitation is interpolated across (6 hours on
362
+ hourly forcing). Precipitation in longer gaps, or missing at the start or end of the
363
+ series, is set to zero. Default is 6.
364
+
365
+ Each variable's missing steps are logged, and each gap where precipitation is set to zero.
339
366
  """
340
367
  for name, var in dataset.data_vars.items():
341
368
  # if the variable is non-numeric, skip
@@ -344,8 +371,36 @@ def interpolate_nan_values(
344
371
  # if there are no NANs, skip
345
372
  if not var.isnull().any().compute():
346
373
  continue
347
- logger.info("Interpolating NaN values in %s", name)
348
374
  var = var.compute()
375
+ times = var[dim].values
376
+ if np.issubdtype(times.dtype, np.datetime64):
377
+ times = np.datetime_as_string(times, unit="s")
378
+ others = [d for d in var.dims if d != dim]
379
+ steps = np.flatnonzero(var.isnull().any(others).values)
380
+ logger.warning(
381
+ "%s is missing at %d of %d %s steps, first at %s, last at %s",
382
+ name,
383
+ steps.size,
384
+ times.size,
385
+ dim,
386
+ times[steps[0]],
387
+ times[steps[-1]],
388
+ )
389
+ if name in PRECIPITATION_VARIABLES:
390
+ long = long_gaps(var, dim, precip_max_gap)
391
+ zeroed = long.any(others).values
392
+ edges = np.flatnonzero(np.diff(zeroed, prepend=False, append=False))
393
+ for start, stop in zip(edges[::2], edges[1::2]):
394
+ logger.warning(
395
+ "%s is set to zero from %s to %s, %d %s steps",
396
+ name,
397
+ times[start],
398
+ times[stop - 1],
399
+ stop - start,
400
+ dim,
401
+ )
402
+ dataset[name] = var.interpolate_na(dim=dim, method=method).where(~long, 0.0)
403
+ continue
349
404
  dataset[name] = var.interpolate_na(
350
405
  dim=dim,
351
406
  method=method,
@@ -355,7 +410,7 @@ def interpolate_nan_values(
355
410
 
356
411
  @no_cluster
357
412
  def compute_zonal_stats(
358
- gdf: gpd.GeoDataFrame, gridded_data: xr.Dataset, forcings_dir: Path
413
+ gdf: gpd.GeoDataFrame, gridded_data: xr.Dataset, forcings_dir: Path, precip_max_gap: int = 6
359
414
  ) -> None:
360
415
  """
361
416
  Compute zonal statistics in parallel for all timesteps over all desired
@@ -478,13 +533,13 @@ def compute_zonal_stats(
478
533
  logger.info(
479
534
  f"Forcing generation complete! Zonal stats computed in {time.time() - timer_start:2f} seconds"
480
535
  )
481
- write_outputs(forcings_dir, units)
536
+ write_outputs(forcings_dir, units, precip_max_gap)
482
537
  time.sleep(1) # wait for progress bar to update
483
538
  progress_file.unlink()
484
539
 
485
540
 
486
541
  @use_cluster
487
- def write_outputs(forcings_dir: Path, units: dict) -> None:
542
+ def write_outputs(forcings_dir: Path, units: dict, precip_max_gap: int = 6) -> None:
488
543
  """
489
544
  Write outputs to disk in the form of a NetCDF file, using dask clusters to
490
545
  facilitate parallel computing.
@@ -523,6 +578,9 @@ def write_outputs(forcings_dir: Path, units: dict) -> None:
523
578
  for var in final_ds.data_vars:
524
579
  final_ds[var] = final_ds[var].astype(np.float32)
525
580
 
581
+ # fill missing steps while time is still a coordinate, so the log names times
582
+ interpolate_nan_values(final_ds, precip_max_gap=precip_max_gap)
583
+
526
584
  # The format for the netcdf is to support a legacy format
527
585
  # which is why it's a little "unorthodox"
528
586
  # There are no coordinates, just dimensions, catchment ids are stored in a 1d data var
@@ -549,8 +607,6 @@ def write_outputs(forcings_dir: Path, units: dict) -> None:
549
607
  final_ds["Time"].attrs["epoch_start"] = (
550
608
  "01/01/1970 00:00:00" # not needed but suppresses the ngen warning
551
609
  )
552
- interpolate_nan_values(final_ds)
553
-
554
610
  logger.info("Saving to disk")
555
611
  final_ds.to_netcdf(forcings_dir / "forcings.nc", engine="netcdf4")
556
612
  # close the datasets
@@ -575,7 +631,7 @@ def setup_directories(cat_id: str) -> FilePaths:
575
631
  return forcing_paths
576
632
 
577
633
 
578
- def create_forcings(dataset: xr.Dataset, output_folder_name: str) -> None:
634
+ def create_forcings(dataset: xr.Dataset, output_folder_name: str, precip_max_gap: int = 6) -> None:
579
635
  validate_dataset_format(dataset)
580
636
  forcing_paths = setup_directories(output_folder_name)
581
637
  logger.debug(f"forcing path {output_folder_name} {forcing_paths.forcings_dir}")
@@ -585,4 +641,4 @@ def create_forcings(dataset: xr.Dataset, output_folder_name: str) -> None:
585
641
  dataset = dataset.isel(
586
642
  y=slice(None, None, -1)
587
643
  ) # Flip y-axis: source data has y ordered from top-to-bottom (as in image arrays), but geospatial operations expect y to increase from bottom-to-top (increasing latitude).
588
- compute_zonal_stats(gdf, dataset, forcing_paths.forcings_dir)
644
+ compute_zonal_stats(gdf, dataset, forcing_paths.forcings_dir, precip_max_gap)