Tel Aviv 机场观测切换至 IMS Lod Airport 实时数据源

新增 IMS (Israel Meteorological Service) 数据抓取模块,以 Lod Airport
(station 225) 官方观测替代 NOAA METAR LLBG 作为 airport_primary。
IMS 数据接入 _airport_primary_from_raw 优先级链,高于 plain METAR
但保留 METAR 集群回退路径。

Constraint: IMS API (ims.gov.il/en/hourly_observations) 仅每小时更新
Confidence: high
Scope-risk: 仅影响 Tel Aviv 城市,其余 51 城数据流不变
Tested: 端到端验证 IMS 取数 → airport_primary → provider 路由链
This commit is contained in:
2569718930@qq.com
2026-05-22 19:16:34 +08:00
parent 79b33599ac
commit 60ac4bae31
4 changed files with 208 additions and 2 deletions
+23 -2
View File
@@ -19,10 +19,11 @@ from src.data_collection.knmi_sources import KnmiSourceMixin
from src.data_collection.hko_obs_sources import HkoObsSourceMixin
from src.data_collection.madis_sources import MadisSourceMixin
from src.data_collection.singapore_mss_sources import SingaporeMssSourceMixin
from src.data_collection.ims_sources import ImsSourceMixin
from src.database.db_manager import DBManager
class WeatherDataCollector(OpenMeteoCacheMixin, SettlementSourceMixin, MetarSourceMixin, MgmSourceMixin, JmaAmedasSourceMixin, NwsOpenMeteoSourceMixin, AmosStationSourceMixin, AmscAwosSourceMixin, FmiSourceMixin, KnmiSourceMixin, HkoObsSourceMixin, MadisSourceMixin, SingaporeMssSourceMixin):
class WeatherDataCollector(OpenMeteoCacheMixin, SettlementSourceMixin, MetarSourceMixin, MgmSourceMixin, JmaAmedasSourceMixin, NwsOpenMeteoSourceMixin, AmosStationSourceMixin, AmscAwosSourceMixin, FmiSourceMixin, KnmiSourceMixin, HkoObsSourceMixin, MadisSourceMixin, SingaporeMssSourceMixin, ImsSourceMixin):
"""
Multi-source weather data collector
@@ -858,7 +859,7 @@ class WeatherDataCollector(OpenMeteoCacheMixin, SettlementSourceMixin, MetarSour
if (
city_lower not in self.CITY_METAR_CLUSTERS
or "mgm_nearby" in results
or settlement_source in {"hko", "cwa"}
or settlement_source in {"hko", "cwa", "ims"}
):
return
cluster_icaos = self.CITY_METAR_CLUSTERS[city_lower]
@@ -886,6 +887,24 @@ class WeatherDataCollector(OpenMeteoCacheMixin, SettlementSourceMixin, MetarSour
except Exception:
logger.exception("airport_obs_log append failed for metar cluster city={}", city_lower)
def _attach_israel_ims_data(self, results: Dict, city_lower: str) -> None:
if city_lower != "tel aviv":
return
ims_data = self.fetch_from_ims(self.IMS_LOD_AIRPORT_STATION)
if ims_data:
results["ims"] = ims_data
try:
ims_current = ims_data.get("current") or {}
DBManager().append_airport_obs(
icao="LLBG",
city=city_lower,
temp_c=ims_current.get("temp"),
wind_kt=ims_current.get("wind_speed_kt"),
obs_time=ims_data.get("obs_time") or datetime.now().isoformat(),
)
except Exception:
logger.exception("airport_obs_log append failed for ims city={}", city_lower)
def _attach_china_official_nearby(
self, results: Dict, city_lower: str, use_fahrenheit: bool
) -> None:
@@ -1364,6 +1383,7 @@ class WeatherDataCollector(OpenMeteoCacheMixin, SettlementSourceMixin, MetarSour
self._attach_china_amsc_awos_data(results, city_lower, use_fahrenheit)
self._attach_madis_hfmetar_data(results, city_lower)
self._attach_singapore_mss_data(results, city_lower)
self._attach_israel_ims_data(results, city_lower)
if include_nearby:
self._attach_china_official_nearby(results, city_lower, use_fahrenheit)
self._attach_japan_official_nearby(results, city_lower, use_fahrenheit)
@@ -1412,6 +1432,7 @@ class WeatherDataCollector(OpenMeteoCacheMixin, SettlementSourceMixin, MetarSour
self._attach_china_amsc_awos_data(results, city_lower, use_fahrenheit)
self._attach_madis_hfmetar_data(results, city_lower)
self._attach_singapore_mss_data(results, city_lower)
self._attach_israel_ims_data(results, city_lower)
if include_nearby:
self._attach_china_official_nearby(results, city_lower, use_fahrenheit)
self._attach_japan_official_nearby(results, city_lower, use_fahrenheit)