Repository navigation
Provide the pan coefficient formula as a preprocessing tool - #340
Merged
Merged
Conversation
Move the S29 expression to rubem/hydrological_processes/_pan_coefficient.py with the natural logarithm injected by the caller, so PCRaster fields and numpy arrays evaluate the same terms in the same order, and make Evapotranspiration.get_pan_coef_et_open_water_area delegate to it.
rubem preprocess kp builds the Class A pan coefficient series from wind speed and relative humidity GeoTIFF series and a fetch distance (scalar or raster) with the shared S29 implementation, through the raster I/O contracts of the other series tools: members named like the other series, no-data propagated from every input, atomic writes and the manifest last. The series is evaluated before anything is written: a member with a non-positive or non-finite coefficient refuses the run, cells above the configured kp maximum and cells missing in an input are warned about, and a member that would overwrite an input is refused. Tests cover the formula against the supplement, the operation, the error paths and the command.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #340 +/- ##
==========================================
+ Coverage 92.75% 92.93% +0.18%
==========================================
Files 61 63 +2
Lines 4028 4163 +135
Branches 510 532 +22
==========================================
+ Hits 3736 3869 +133
Misses 235 235
- Partials 57 59 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
camilabillerbeck
previously approved these changes
Sep 18, 2026
…ent-preprocessing
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
kp = 0.482 + 0.024 ln(B) - 0.000376 U2 + 0.0045 UR) inrubem/hydrological_processes/_pan_coefficient.py, with the natural logarithm injected by the caller so the model (pcraster.ln) and the tool (numpy.log) evaluate the same terms in the same order.Evapotranspiration.get_pan_coef_et_open_water_areais kept and delegates to it; a test pins its previous numbers (for exampleB = 25,U2 = 2,UR = 70gives 0.8735010197968368).rubem preprocess kp(rubem/preprocessing/pan_coefficient_series.py): two GeoTIFF series (wind speed at 2 m in m/s, relative humidity in %), paired in natural order, plus a fetch distance in metres as a scalar (--fetch, warned outside the 20 to 30 m of the supplement) or as a raster (--fetch-raster); one member per pair, named like the other series tools name theirs (kp000000.001orkp00000001.tif), no-data propagated from every input, geometry checked against the first wind raster, atomic writes andmanifest.csvwritten last. The model refuses akpraster that is not positive, so the series is evaluated and checked before anything is written: a member with a non-positive or non-finite cell refuses the whole run naming every offending member; cells above the configuredkpmaximum (which the model only reports) are warned about, as are cells missing in an input. A member that would overwrite one of its own inputs is refused.CliRunner.preprocessing.rst(formula, units, options, naming, thekp > 0rule) and a pointer from thekpinput description in the user guide and in the file formats page. Changelog entry under Added.Related Issue
Motivation and context
kpis an input series by design, but the authors want it available for users who have the climate data (finding 16 of the scientific review). Keeping a single implementation avoids the model and the tool drifting apart.How has this been tested
python -m pytest -q -p no:cacheprovider --ignore=tests/integration/doc -n 4: 1035 passed, 1 skipped, onmainat 176f204 (Linux, Python 3.13, PCRaster 4.4.2).uvx ruff@0.16.4 format --check .anduvx ruff@0.16.4 check .: clean.sphinx-build -W -b html doc/source: no warnings.For the maintainer: the formula exceeds 1 for a relative humidity close to 100 % while the configured
kprange is[0, 1](reported, not blocking, by the model); the tool follows the model and warns. The "or a station table" input of the issue was not implemented:rubem preprocess krigealready turns station tables into raster series that this command can read.Screenshots