From 1c4287380e8333e59483da65786151715c4d362f Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Mon, 18 May 2026 18:30:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20KNMI=20=E7=BB=B4=E5=BA=A6?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E4=B8=BA=E5=AD=97=E7=AC=A6=E4=B8=B2=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E7=9A=84=E5=85=BC=E5=AE=B9=E6=80=A7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/data_collection/knmi_sources.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/data_collection/knmi_sources.py b/src/data_collection/knmi_sources.py index d942b8d7..766e9efc 100644 --- a/src/data_collection/knmi_sources.py +++ b/src/data_collection/knmi_sources.py @@ -147,12 +147,11 @@ class KnmiSourceMixin: data = ta[:] # Handle both old (time,station) and new (station,time) layouts - dim_names = [str(d.name).lower() for d in ta.dimensions] - if data.ndim == 2: - if dim_names and dim_names[0] == "station": - latest_temp = float(data[idx, -1]) - else: - latest_temp = float(data[-1, idx]) + n_stations = len(station_ids) + if data.ndim == 2 and data.shape[0] == n_stations: + latest_temp = float(data[idx, -1]) + elif data.ndim == 2: + latest_temp = float(data[-1, idx]) else: latest_temp = float(data[-1]) @@ -160,10 +159,9 @@ class KnmiSourceMixin: if var is None: return None vdata = var[:] + if vdata.ndim == 2 and vdata.shape[0] == n_stations: + return float(vdata[idx, -1]) if vdata.ndim == 2: - vdim_names = [str(d.name).lower() for d in var.dimensions] - if vdim_names and vdim_names[0] == "station": - return float(vdata[idx, -1]) return float(vdata[-1, idx]) return float(vdata[-1])