Skip to content

fix(cdec): daily flags from recorded durations; null snow values outside 0–15 m - #94

Merged
egagli merged 2 commits into
mainfrom
claude/busy-brown-ralg4x
Nov 5, 2026
Merged

egagli merged 2 commits into
mainfrom
claude/busy-brown-ralg4x

Conversation

@egagli

@egagli egagli commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Two CDEC client fixes found while auditing the global_snow_networks archive (egagli/global_snow_networks#65).

get_stations: daily flags from daily sensors

has_daily_swe and has_daily_snwd were set from sensor presence. But CDEC's station search lists every site with sensor 3, 18 or 82 at any duration. Of ~564 snow stations, only 145 have a daily snow sensor. About 345 are monthly snow courses, some of them on neither the course nor the pillow list (EMV, Emigrant Valley: monthly 1980–82 only). Another 74 record hourly or event data only.

The station search takes a duration filter (dur=D/H/E/M). get_stations now runs it once per sensor (12 requests, ~10 s) and returns sensor_durations ({3: ["D", "H"], 18: ["M"], …}). The daily flags follow the D duration only. If a duration search fails, the flags fall back to sensor presence with a warning, so a daily station is over-advertised rather than hidden.

Live (2026-11-05): 145 daily (142 SWE, 118 depth). That matches the 143 CDEC stations the archive has data for, plus MCW and TST.

Snow values outside 0–15 m are None

The client had no plausibility bound (DESIGN.md §3.6). The hourly and event series of CDEC's wireless sensor networks carry values like −799,899 cm (G01), 21,049 cm (DPK) and 5,894 cm (HEM), plus small negative depths. Sensors 3, 18 and 82 are now None outside 0–1500 cm after conversion, at every duration. Other sensors are untouched; −4 °F is still −20 °C.

Tests

  • pytest -m "not live": 1,294 pass. New tests cover the duration flags, the search-failure fallback, and the bound.
  • Live test_cdec_client.py -k get_stations: 6 pass.

Release

global_snow_networks uses sensor_durations once its lock moves to the release carrying this (egagli/global_snow_networks#66). If this is the next release, that's v0.3.7.


Generated by Claude Code

…urations

get_stations set has_daily_swe/has_daily_snwd from sensor presence, but
CDEC's station search lists every station with sensor 3, 18 or 82 at any
duration: of ~560 snow stations only 145 have a daily snow sensor, ~340
are monthly snow courses and 74 record hourly or event data only.
global_snow_networks advertised them all as daily, refetched them every
night for nothing, and counted 207 as daily with no data until #65 there.

The station search takes a duration filter (dur=D/H/E/M); get_stations
now runs it per sensor (12 requests, ~10 s) and returns
sensor_durations ({3: ["D", "H"], ...}), and the daily flags follow the
D duration only. A failed duration search falls back to sensor presence
with a warning (over-advertising, never hiding a daily station).

Live, 2026-11-05: 145 stations daily (142 SWE, 118 depth), matching the
143 CDEC stations the archive holds data for plus MCW and TST.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015LSmHDJN224tLPVAUrvQTE
The CDEC client applied no plausibility bound (DESIGN.md §3.6). Daily
pillow data rarely needs one, but the hourly and event series of CDEC's
wireless snow-depth sensor networks carry values like -799,899 cm (G01),
21,049 cm (DPK) and 5,894 cm (HEM), and small negative depths. Sensors
3, 18 and 82 are now None outside 0-1500 cm after conversion, at every
duration; other sensors (temperatures) are untouched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015LSmHDJN224tLPVAUrvQTE
@egagli
egagli merged commit 70fd4de into main Nov 5, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants