modified: app.py
modified: static/css/style.css
This commit is contained in:
26
app.py
26
app.py
@@ -338,8 +338,10 @@ def _parse_warning_datetime(value):
|
||||
# schnee snow
|
||||
# blitz dry thunderstorm (WW 17, 91-92)
|
||||
# sturm thunderstorm with rain (WW 95, 97-98)
|
||||
# hagel hail (WW 27, 89-90, 93-94, 96, 99)
|
||||
# hagel hail (WW 27, 89-90, 93-94)
|
||||
# schneebedeckt hail + snow (hagel WW + temp ≤ 2°C)
|
||||
# sturmundhagel thunderstorm + rain + hail (WW 96, 99)
|
||||
# schneebedecktsonne snow + sunshine (temp ≤ 2°C, cloud < 60 %)
|
||||
# nebel dense fog (visibility < 1000 m)
|
||||
# nebel_wolkig foggy + overcast (1000-5000 m, cloud > 60 %)
|
||||
# wolkig_nebel_sonne patchy fog / haze (1000-5000 m, less cloud)
|
||||
@@ -348,9 +350,10 @@ def _parse_warning_datetime(value):
|
||||
# nacht(2) moon+cloud+rain
|
||||
# nacht(3) moon+cloud+snow
|
||||
|
||||
_WW_HAIL = {27, 89, 90, 93, 94, 96, 99} # hail shower codes
|
||||
_WW_THUNDER_RAIN = {91, 92, 95, 97, 98} # thunderstorm + precipitation
|
||||
_WW_THUNDER_DRY = {17} # dry thunderstorm
|
||||
_WW_HAIL = {27, 89, 90, 93, 94} # hail showers (no thunder)
|
||||
_WW_THUNDER_HAIL = {96, 99} # thunderstorm + hail → sturmundhagel
|
||||
_WW_THUNDER_RAIN = {91, 92, 95, 97, 98} # thunderstorm + precipitation
|
||||
_WW_THUNDER_DRY = {17} # dry thunderstorm
|
||||
|
||||
def weather_icon(cloud_pct, precip_mm, rain_prob, temp_c, is_night=False, visibility_m=None, weather_code=None):
|
||||
"""Return the icon key for static/icons/{key}.png."""
|
||||
@@ -365,6 +368,8 @@ def weather_icon(cloud_pct, precip_mm, rain_prob, temp_c, is_night=False, visibi
|
||||
# ── WW-code based icons (thunderstorm / hail) ─────────────────────
|
||||
if weather_code is not None:
|
||||
ww = int(weather_code)
|
||||
if ww in _WW_THUNDER_HAIL:
|
||||
return "sturmundhagel"
|
||||
if ww in _WW_HAIL:
|
||||
return "schneebedeckt" if (temp_c is not None and temp_c <= 2) else "hagel"
|
||||
if ww in _WW_THUNDER_RAIN:
|
||||
@@ -376,7 +381,9 @@ def weather_icon(cloud_pct, precip_mm, rain_prob, temp_c, is_night=False, visibi
|
||||
if temp_c is not None and temp_c <= 2 and (
|
||||
(precip_mm and precip_mm > 0.1) or (rain_prob and rain_prob >= 40)
|
||||
):
|
||||
return "nacht(3)" if is_night else "schnee"
|
||||
if is_night:
|
||||
return "nacht(3)"
|
||||
return "schneebedecktsonne" if (cloud_pct is not None and cloud_pct < 60) else "schnee"
|
||||
|
||||
# ── Night icons ───────────────────────────────────────────────────
|
||||
if is_night:
|
||||
@@ -407,12 +414,15 @@ def pick_daily_icon(hours):
|
||||
# Thunderstorm / hail: any hour with matching WW code takes priority
|
||||
ww_codes = [h.get("weather_code") for h in hours if h.get("weather_code") is not None]
|
||||
if ww_codes:
|
||||
has_hail = any(w in _WW_HAIL for w in ww_codes)
|
||||
has_t_rain = any(w in _WW_THUNDER_RAIN for w in ww_codes)
|
||||
has_t_dry = any(w in _WW_THUNDER_DRY for w in ww_codes)
|
||||
has_t_hail = any(w in _WW_THUNDER_HAIL for w in ww_codes)
|
||||
has_hail = any(w in _WW_HAIL for w in ww_codes)
|
||||
has_t_rain = any(w in _WW_THUNDER_RAIN for w in ww_codes)
|
||||
has_t_dry = any(w in _WW_THUNDER_DRY for w in ww_codes)
|
||||
avg_temp = sum(h["temp_c"] for h in hours if h.get("temp_c") is not None)
|
||||
n_temp = sum(1 for h in hours if h.get("temp_c") is not None)
|
||||
mean_temp = avg_temp / n_temp if n_temp else 10
|
||||
if has_t_hail:
|
||||
return "sturmundhagel"
|
||||
if has_hail:
|
||||
return "schneebedeckt" if mean_temp <= 2 else "hagel"
|
||||
if has_t_rain:
|
||||
|
||||
Reference in New Issue
Block a user