diff --git a/src/data_collection/weather_sources.py b/src/data_collection/weather_sources.py index 5b6906fc..28d64a32 100644 --- a/src/data_collection/weather_sources.py +++ b/src/data_collection/weather_sources.py @@ -364,7 +364,6 @@ class WeatherDataCollector: # 处理多模型数据 (如果请求了 models 参数,返回结构会变化) daily_data = data.get("daily", {}) if "temperature_2m_max_ecmwf_ifs" in daily_data: - # 获取首日的各模型峰值比较 ecmwf_max = daily_data.get("temperature_2m_max_ecmwf_ifs", []) hrrr_max = daily_data.get("temperature_2m_max_hrrr_conus", []) @@ -373,9 +372,16 @@ class WeatherDataCollector: "ecmwf": ecmwf_max[0] if ecmwf_max else None, "hrrr": hrrr_max[0] if hrrr_max else None } - # 设置主显示值为 HRRR (当地高精) + # 核心修正:映射回标准键名 if hrrr_max: daily_data["temperature_2m_max"] = hrrr_max + elif ecmwf_max: + daily_data["temperature_2m_max"] = ecmwf_max + + # 映射逐小时数据 + hourly_data = data.get("hourly", {}) + if "temperature_2m_hrrr_conus" in hourly_data: + hourly_data["temperature_2m"] = hourly_data["temperature_2m_hrrr_conus"] # 计算精确的当地时间 now_utc = datetime.utcnow() @@ -391,7 +397,7 @@ class WeatherDataCollector: "temp": current.get("temperature"), "local_time": local_time_str, }, - "hourly": data.get("hourly", {}), + "hourly": hourly_data, "daily": daily_data, "unit": "fahrenheit" if use_fahrenheit else "celsius", }