diff --git a/lib/xmet/bufr.py b/lib/xmet/bufr.py index d26ef60..25099fb 100644 --- a/lib/xmet/bufr.py +++ b/lib/xmet/bufr.py @@ -115,6 +115,9 @@ class BUFRSounding(Sounding): sounding.timestamp_observed = timestamp sounding.timestamp_released = timestamp - datetime.timedelta(minutes=45) + surface_pressure = None + surface_height = None + for item in response: params = item.getParameters() @@ -124,6 +127,9 @@ class BUFRSounding(Sounding): wind_dir = item.getNumber('wsMan') wind_speed = item.getNumber('wdMan') + if surface_pressure is None and height == -9999.0: + surface_pressure = pressure + sounding.record_wind(pressure, height, wind_dir, wind_speed) if set(params) & BUFRSounding.BUFR_PARAMS_SIGT: @@ -142,6 +148,13 @@ class BUFRSounding(Sounding): sounding.record_wind(pressure, height, wind_speed, wind_dir) + if set(params) & set(['staElev']): + if surface_pressure is not None and surface_height is None: + surface_height = item.getNumber('staElev') + + if surface_pressure is not None and surface_height is not None: + sounding.sample_by_pressure(surface_pressure).height = surface_height + for pressure in sorted(sounding.samples_by_pressure.keys(), reverse=True): sounding.samples.append(sounding.samples_by_pressure[pressure])