From b8903a69f8951f3bd10ec73a88f8833e0642fbe5 Mon Sep 17 00:00:00 2001 From: XANTRONIX Industrial Date: Sun, 13 Apr 2025 20:53:18 -0400 Subject: [PATCH] Handle missing wind data; ensure samples by height are included --- lib/xmet/bufr.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/xmet/bufr.py b/lib/xmet/bufr.py index c5f33a3..cf15db5 100644 --- a/lib/xmet/bufr.py +++ b/lib/xmet/bufr.py @@ -92,8 +92,15 @@ class BUFRSounding(Sounding): else: sample = sounding.sample_by_pressure(pressure) - sample.wind_speed = item.getNumber('wsMan') - sample.wind_dir = item.getNumber('wdMan') + if height != -9999.0: + sample.height = height + + wind_dir = item.getNumber('wsMan') + wind_speed = item.getNumber('wdMan') + + if wind_dir != -9999.0 and wind_speed != -9999.0: + sample.wind_speed = wind_dir + sample.wind_dir = wind_speed if set(params) & BUFRSounding.BUFR_PARAMS_SIGT: pressure = item.getNumber('prSigT') / 100.0 @@ -111,10 +118,16 @@ class BUFRSounding(Sounding): else: sample = sounding.sample_by_pressure(pressure) + if height != -9999.0: + sample.height = height + sample.wind_speed = item.getNumber('wsSigW') sample.wind_dir = item.getNumber('wdSigW') for pressure in sorted(sounding.samples_by_pressure.keys(), reverse=True): sounding.samples.append(sounding.samples_by_pressure[pressure]) + for height in sorted(sounding.samples_by_height.keys()): + sounding.samples.append(sounding.samples_by_height[height]) + return sounding