Add soil module (SoilGrids 2.0) with NEH 630 Ch7 hydrologic soil group#12
Merged
Conversation
…p derivation floodpath.soil supplies the SOIL half of the SCS-CN runoff parameterisation. Pair with floodpath.landuse to derive a Curve Number raster. - floodpath/soil/soilgrids.py: get_soilgrids_texture(lat, lon, buffer_deg, depths) — fetches sand/silt/clay (% by mass) at user-selectable depth slices from the public ISRIC bucket via /vsicurl/ + WarpedVRT (native Goode Homolosine -> WGS84). Default depths=(0-5cm, 5-15cm, 15-30cm), depth-weighted to a 0-30 cm topsoil composition (closest available proxy for NEH 630 Ch7 Table 7-1's 0-50 cm reference depth). Fetches parallelised across (variable, depth) pairs — ~73 s for 9 reads vs ~525 s sequential. SoilGrids nodata (-32768) masked to NaN. - floodpath/soil/utils.py: usda_texture_class(sand, silt, clay) — full USDA Soil Survey Manual 1993 / Soil Taxonomy 1999 texture triangle with all 12 canonical classes (sand, loamy sand, sandy loam, loam, silt loam, silt, sandy clay loam, clay loam, silty clay loam, sandy clay, silty clay, clay). Vectorised over numpy arrays. - floodpath/soil/hsg.py: texture_to_hsg(TextureGrid) -> HSGGrid via the USDA_TEXTURE_TO_HSG mapping (NEH 630 Ch7 §630.0701 textural shortcut). Custom mappings supported for site-calibrated work. - TextureGrid carries closure_residual() for sand+silt+clay~=100 sanity checks; HSGGrid carries class_counts(), fraction(), dominant_class(), as_letter_grid() helpers and a uint8 1-4 encoding (0=nodata). - Tests: 60 total — 12 USDA centroid round-trips, 11 hsg unit cases, 3 model property tests, plus a committed Robit Bata fixture (8.4 KB, 33x33 multiband float32 GeoTIFF) with pinned per-cell stats and a 100% HSG-D outcome (Vertisol-rich Ethiopian highlands). One live ISRIC fetch regression test guards the fixture; an integration test in Djibouti exercises the full /vsicurl/+WarpedVRT+parallel-fetch path.
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.
Summary
Module surface
Performance
SoilGrids reads were the bottleneck — 9 sequential `/vsicurl/` fetches for 3 vars × 3 depths took ~525 s. Parallelised via `ThreadPoolExecutor` (max 9 workers): ~73 s for the same workload (~7× speedup). ISRIC tolerates ~10 concurrent connections per client.
Test plan
Notes