feat(weather): population-weighted multi-city index + degree-hours / apparent-temperature / dew-point features#345
Merged
Conversation
…parent-temperature/dew-point features Add the cheapest, most reliable load-forecasting accuracy levers — the feature-matrix gains that live in x_t, not the model f(.) — as opt-in, fail-safe, deterministic weather features. All default off, so the pipeline stays byte-identical to the single-point baseline. New module weather/derived.py (pure functions): - heating/cooling degree-hours (hdh/cdh) — split the U-shaped temperature response into its two arms (ruba23a) - apparent temperature (Steadman) and dew point (Magnus) — fold in the humidity driver dry-bulb temperature misses (maia20a) - population_weighted_average — combine per-city frames into one demand- weighted national index (zimm25a) - add_derived_weather_features — deterministic orchestrator, raises on a missing source column rather than imputing New module weather/locations.py: a fixed, deterministic registry of 13 German load centres weighted by population and spread across all regions so the national index is not dominated by one climate zone. get_weather_features gains opt-in locations/location_weights (multi-city population weighting) and derived_features/hdh_base/cdh_base/wind_speed_unit parameters; ConfigMulti gains use_population_weighted_weather, include_degree_hours, include_apparent_temperature, degree_hours_base_*; and BaseTask.build_exogenous_features wires them through (getattr-guarded for configs predating the fields). Implements the "what to adopt next" priorities #1-#2 from the lecture's "Additional exogenous inputs beyond weather and holidays" and the global population-weighted weather requested for the sf2 roadmap. Stays within the sf2-safe contract: keyless, deterministic, fail-safe, no prohibited deps. Tests: 46 new (pure functions, fail-safe, determinism, monkeypatched wired path). Docs reference regenerated. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
Adds the cheapest, most reliable load-forecasting accuracy levers as opt-in, fail-safe, deterministic weather features. All flags default off, so the pipeline stays byte-identical to the single-point baseline.
New
weather/derived.py(pure functions)hdh/cdh) — split the U-shaped temperature–load response into its two arms (ruba23a).maia20a).population_weighted_average— combine per-city frames into one demand-weighted national index (zimm25a).add_derived_weather_features— deterministic orchestrator; raises on a missing source column rather than imputing.New
weather/locations.pyA fixed, deterministic registry of 13 German load centres, weighted by population and deliberately spread across all regions (N/S/E/W) so the national index is not dominated by one climate zone.
Wiring (opt-in, non-breaking)
get_weather_featuresgainslocations/location_weights(multi-city population weighting) andderived_features/hdh_base/cdh_base/wind_speed_unit.ConfigMultigainsuse_population_weighted_weather,include_degree_hours,include_apparent_temperature,degree_hours_base_heating/cooling.BaseTask.build_exogenous_featureswires them through (getattr-guarded for configs predating the fields).Why
Implements the lecture's "what to adopt next" priorities #1–#2 (degree-hours + apparent temperature + dew point, then population-weighted multi-city temperature) from "Additional exogenous inputs beyond weather and holidays", and the global, population-weighted weather requested on the sf2 roadmap (current weather is a single Open-Meteo point at Dortmund).
Safety (sf2-safe contract)
Keyless (Open-Meteo), deterministic (fixed city list + fixed published weights, no RNG/wall-clock, stable column order), fail-safe (a missing source column / out-of-range humidity / mismatched index raises
ValueError, never silent repair). No prohibited dependencies — numpy/pandas only.Tests & QC
get_weather_featurespath via a monkeypatched Open-Meteo fetch (fully offline).weather/derived.py98%.docs/reference/regenerated (new symbols registered in_quarto.yml);docs-reference-syncgate satisfied.🤖 Generated with Claude Code