From e41ac206889f126d025a87cc3c688ea40fd47689 Mon Sep 17 00:00:00 2001 From: Johannes Schmidt <89488492+johannesparty@users.noreply.github.com> Date: Mon, 28 Sep 2026 10:35:21 -0700 Subject: [PATCH] test(us): feed measured pedon elevation into the bulk harness Pass the pedon's measured elevation (present for ~76% of cases) into rank_soils so the US site score (slope + elevation) is actually exercised, instead of hard-coding pElev=None. Missing cases still fall back to rank_soils' internal EPQS lookup (which resolves only ~6% of the time here). Adds a TODO to consider filling elevation for the missing ~24% later. No algorithm change; affects the bulk harness only. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../tests/us/generate_bulk_test_results.py | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/soil_id/tests/us/generate_bulk_test_results.py b/soil_id/tests/us/generate_bulk_test_results.py index fb670cf9..3617b769 100644 --- a/soil_id/tests/us/generate_bulk_test_results.py +++ b/soil_id/tests/us/generate_bulk_test_results.py @@ -49,6 +49,25 @@ "lon": lon, } + # Pass the pedon's measured elevation when present (~76% of cases) so the US + # site score (slope + elevation; the Gower site score only activates with + # >=2 non-null site features, and bedrock/cracks aren't in this dataset) can + # use it. When elevation is absent we pass None and rank_soils falls back to + # its internal EPQS (National Map) lookup -- which for this dataset resolves + # only ~6% of the time (the service times out on the rest), so those pedons + # usually get no site score. + # + # TODO (future -- not yet): consider filling in elevation for the ~24% of + # pedons that are missing it (e.g. a reliable DEM lookup) so the site score + # is exercised across the whole set rather than only ~76%. + pElev = None + try: + _elev = float(pedon["elev"].values[0]) + if _elev == _elev: # exclude NaN + pElev = _elev + except (TypeError, ValueError): + pElev = None + start_time = time.perf_counter() try: list_result = list_soils(lat=lat, lon=lon) @@ -64,7 +83,7 @@ rfvDepth=pedon["fragvoltot"].values.tolist(), lab_Color=pedon[["L", "a", "b"]].values.tolist(), pSlope=pedon["slope"].values[0], - pElev=None, + pElev=pElev, bedrock=None, cracks=None, )