mirror of
https://github.com/Dasemu/skipredictor.git
synced 2026-11-26 15:26:15 +00:00
merge: clean predictor debt
# Conflicts: # predictor/rules.py
This commit is contained in:
commit
a70eff3e45
10 files changed
+266
-64
No files matched your search
+26
-6
@@ -19,11 +19,10 @@ logger = logging.getLogger(__name__)
|
||||
# Path relative to repository root
|
||||
_CONFIG_PATH = Path(__file__).parent.parent / "config" / "stations.yaml"
|
||||
|
||||
# Fresh snowfall (cm in 24 h) considered "heavy"
|
||||
_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]:
|
||||
@@ -137,7 +136,6 @@ class RulesEngine:
|
||||
)
|
||||
|
||||
force_closed = False
|
||||
force_open = False
|
||||
reasons: list[str] = []
|
||||
km_factor = 1.0
|
||||
|
||||
@@ -178,6 +176,28 @@ class RulesEngine:
|
||||
min_snow,
|
||||
)
|
||||
|
||||
# ---- Rule 3: 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 -------------------------------------------
|
||||
# Confidence is 1.0 only if a deterministic closure rule fired.
|
||||
# Otherwise, confidence is 0.0, delegating all responsibility to ML.
|
||||
|
||||
Reference in new issue
Block a user