Avoid 1e-5 added to precipitation for all timesteps - #323
Open
LINAMARIAOSORIO wants to merge 9 commits into
Open
Avoid 1e-5 added to precipitation for all timesteps#323LINAMARIAOSORIO wants to merge 9 commits into
LINAMARIAOSORIO wants to merge 9 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #323 +/- ##
==========================================
- Coverage 92.48% 92.47% -0.01%
==========================================
Files 60 60
Lines 3910 3908 -2
Branches 487 487
==========================================
- Hits 3616 3614 -2
Misses 238 238
Partials 56 56 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
Description
Interception.get_interceptionguards the interception-rate equationI_R = 1 - exp(-I_D * d_p / P_m)against a zero monthly precipitation by replacingP_mwith1e-5in the denominator. The guard was written asprec = P * (P != 0) + (P * (P == 0) + 0.00001), so the+ 0.00001applied to every value and positive precipitation reached the denominator asP + 1e-5 mm. The guard is nowpcr.ifthenelse(precipitation != 0, precipitation, pcr.scalar(1e-5)): positive precipitation is used unchanged and the epsilon only applies whereP == 0.Follow-up commits on top of the fix:
ruff formatof the changed module (the lint job runsruff format --check).tests/unit/hydrological_processes/test_module_interception.py: positive precipitation reproduces the equation evaluated in float64; a small positive precipitation (P = 1e-4 mm) that the old guard lowered by about 6 % (this test fails onmain); zero precipitation stays finite and zero.SHA256SUMSrewritten and a new entry at the top oftests/fixtures/AUDIT.mdwith the provenance, the impact table and the replaced checksums.srn0000001.tif), andorigin/mainmerged so the branch is up to date for the protected merge.Related Issue
Motivation and context
The
1e-5 mmperturbation of the denominator diverges from the documented interception rate (doc/source/overview.rst, equationinterception-r; supplementary document, equation SE3). The hydrological effect is numerical noise (at most3.05e-5 mmon the regression rasters,2.4e-4 mmonsmc), but the semantic golden comparison of the CI matrix (rtol = 1e-5) rejected the previous goldens on onesrncell, so the fixtures had to be regenerated.How has this been tested
pytest --ignore=tests/integration/doc): 997 passed, 1 skipped.test_interceptionCalc_small_positive_precipitation_keeps_denominatorfails with the module frommain(4.90e-5instead of5.23e-5) and passes with this branch.tests/fixtures/regenerate_golden.pyin a Docker container ofubuntu:24.04(glibc 2.39-0ubuntu8.8) with the environment fromci/golden-env.lockandci/golden-pip.lock. Before promoting them, the container reproduced the previous goldens byte-for-byte onmain; the 28 regenerated digests are identical to the ones theexactjob reported for this branch before the regeneration (run 33662562795) and the 17 untouched files keep their digests.lint,docsandexactCI jobs were also run locally withact(ubuntu-24.04runner image): green.ci-successgreen.Screenshots