修复非 AMOS 城市温度显示为整数:改用机场站点温度替代 METAR
city_weather.current.temp 来自 METAR(整数),改为从 mgm_nearby[0].temp 取机场高频数据源的站点温度(小数精度)。JMA/FMI/KNMI/MGM 源均保留一位小数。 Constraint: 首尔/釜山走 runway_temps 已有精度,不受影响 Tested: pytest 176 passed, ruff check 通过
This commit is contained in:
@@ -737,16 +737,17 @@ def _build_airport_status_message(
|
|||||||
runway_data = (amos.get("runway_obs") or {}) if amos else {}
|
runway_data = (amos.get("runway_obs") or {}) if amos else {}
|
||||||
runway_pairs = runway_data.get("runway_pairs") or []
|
runway_pairs = runway_data.get("runway_pairs") or []
|
||||||
runway_temps = runway_data.get("temperatures") or []
|
runway_temps = runway_data.get("temperatures") or []
|
||||||
current = city_weather.get("current") or {}
|
# Non-AMOS cities: get temp from airport station (stored in mgm_nearby), not METAR
|
||||||
temp = current.get("temp")
|
mgm_nearby = city_weather.get("mgm_nearby") or []
|
||||||
|
station_temp = mgm_nearby[0].get("temp") if mgm_nearby else None
|
||||||
|
|
||||||
lines = [label, ""]
|
lines = [label, ""]
|
||||||
if runway_pairs and runway_temps and len(runway_pairs) == len(runway_temps):
|
if runway_pairs and runway_temps and len(runway_pairs) == len(runway_temps):
|
||||||
for (r1, r2), (t, _d) in zip(runway_pairs, runway_temps):
|
for (r1, r2), (t, _d) in zip(runway_pairs, runway_temps):
|
||||||
lines.append(f"{r1}/{r2} {t:.1f}°C")
|
lines.append(f"{r1}/{r2} {t:.1f}°C")
|
||||||
elif temp is not None:
|
elif station_temp is not None:
|
||||||
time_suffix = f" ({local_time})" if local_time else ""
|
time_suffix = f" ({local_time})" if local_time else ""
|
||||||
lines.append(f"{temp:.1f}°C{time_suffix}")
|
lines.append(f"{station_temp:.1f}°C{time_suffix}")
|
||||||
if deb_pred is not None:
|
if deb_pred is not None:
|
||||||
lines.append(f"DEB 最高 {deb_pred:.1f}°C")
|
lines.append(f"DEB 最高 {deb_pred:.1f}°C")
|
||||||
return "\n".join(lines)
|
return "\n".join(lines)
|
||||||
|
|||||||
Reference in New Issue
Block a user