fix(core): clean predictor debt

This commit is contained in:
dasemu committed 2026-03-13 10:51:29 +01:00
1 parent e952cea417
commit e6add1b727
10 files changed
+268 -58

No files matched your search

+28
View File
@@ -25,6 +25,11 @@ _HEAVY_FRESH_SNOW_THRESHOLD_CM = 20.0
# Wind gust (km/h) considered "moderate" when combined with heavy snow
_MODERATE_WIND_THRESHOLD_KMH = 40.0
# Warm rain quickly degrades skiable terrain even when opening remains possible.
_WARM_RAIN_TEMP_THRESHOLD_C = 10.0
_WARM_RAIN_PRECIP_THRESHOLD_MM = 1.0
_WARM_RAIN_KM_FACTOR = 0.6
def _load_station_configs() -> dict[str, Any]:
"""Load all station configurations from stations.yaml.
@@ -225,6 +230,29 @@ class RulesEngine:
snowfall_24h,
)
# ---- Rule 6: Warm rain reduces skiable terrain -------------------
max_temperature = weather_data.get("temperature_2m_max")
precipitation = weather_data.get("precipitation_sum")
if (
max_temperature is not None
and max_temperature > _WARM_RAIN_TEMP_THRESHOLD_C
and precipitation is not None
and precipitation >= _WARM_RAIN_PRECIP_THRESHOLD_MM
and not force_closed
):
km_factor = min(km_factor, _WARM_RAIN_KM_FACTOR)
reasons.append(
f"Lluvia ({precipitation:.1f} mm) con temperatura alta "
f"({max_temperature:.1f} C); se reduce el km esquiable estimado."
)
logger.info(
"[%s] Rule 6 fired: warm rain %.1f C / %.1f mm -> km_factor %.2f",
station_name,
max_temperature,
precipitation,
km_factor,
)
# ---- Derive confidence -------------------------------------------
if force_closed or force_open:
confidence = 1.0