Try this notebook in Binder.

[1]:
!test -f temp_small.bufr || wget https://get.ecmwf.int/repository/test-data/pdbufr/test-data/temp_small.bufr
!test -f temp_hires.bufr || wget https://get.ecmwf.int/repository/test-data/pdbufr/test-data/temp_hires.bufr

Temp: geopotential

[2]:
import pdbufr

Temp BUFR messages can typically contain either geopotential (older format) or geopotential height (newer format) data. In this example we have 2 BUFR files: “temp_small.bufr” containing geopotential and “temp_hires.bufr” containing geopotential height data.

We can control the extraction of these parameters via the geopotential keyword of the temp reader.

geopotential=z

The default option is geopotential="z", which means that only the geopotential will be added to the results. When it is not available it will be computed from geopotential height (when possible).

[3]:
# geopotential is available in this file
df = df = pdbufr.read_bufr("temp_small.bufr", reader="temp", filters={"count": 1})
df[:3]
[3]:
stnid lat lon elevation time pressure z t td wind_speed wind_dir
0 71907 58.47 -78.08 26 2008-12-08 12:00:00 100300.0 250.0 258.3 255.7 NaN NaN
1 71907 58.47 -78.08 26 2008-12-08 12:00:00 100000.0 430.0 259.7 258.3 0.0 0.0
2 71907 58.47 -78.08 26 2008-12-08 12:00:00 99800.0 630.0 261.1 259.6 NaN NaN
[4]:
# geopotential is not available in this file, will be computed from geopotential height
df = df = pdbufr.read_bufr("temp_hires.bufr", reader="temp", filters={"count": 1})
df[:3]
[4]:
stnid lat lon elevation time pressure z t td wind_speed wind_dir
0 10954 47.8341 10.8667 760.0 2025-02-23 10:45:04 100000 2467.353140 NaN NaN NaN NaN
1 10954 47.8341 10.8667 760.0 2025-02-23 10:45:04 94051 7454.034665 280.65 278.13 1.5 10.0
2 10954 47.8341 10.8667 760.0 2025-02-23 10:45:04 93999 NaN 280.50 278.11 1.0 19.0

geopotential=zh

When geopotential="zh", only the geopotential height will be added to the results. When it is not available it will be computed from geopotential (when possible).

[5]:
# geopotential height is not available in this file, will be computed from geopotential
df = df = pdbufr.read_bufr("temp_small.bufr", reader="temp", geopotential="zh", filters={"count": 1})
df[:3]
[5]:
stnid lat lon elevation time pressure zh t td wind_speed wind_dir
0 71907 58.47 -78.08 26 2008-12-08 12:00:00 100300.0 25.492905 258.3 255.7 NaN NaN
1 71907 58.47 -78.08 26 2008-12-08 12:00:00 100000.0 43.847797 259.7 258.3 0.0 0.0
2 71907 58.47 -78.08 26 2008-12-08 12:00:00 99800.0 64.242121 261.1 259.6 NaN NaN
[6]:
# geopotential height is available in this file
df = df = pdbufr.read_bufr("temp_hires.bufr", reader="temp", geopotential="zh", filters={"count": 1})
df[:3]
[6]:
stnid lat lon elevation time pressure zh t td wind_speed wind_dir
0 10954 47.8341 10.8667 760.0 2025-02-23 10:45:04 100000 251.6 NaN NaN NaN NaN
1 10954 47.8341 10.8667 760.0 2025-02-23 10:45:04 94051 760.1 280.65 278.13 1.5 10.0
2 10954 47.8341 10.8667 760.0 2025-02-23 10:45:04 93999 NaN 280.50 278.11 1.0 19.0

geopotential=both

When geopotential="both", both the geopotential and geopotential height will be added to the results. When one of it is not available it will be computed (when possible).

[7]:
df = df = pdbufr.read_bufr("temp_small.bufr", reader="temp", geopotential="both", filters={"count": 1})
df[:3]
[7]:
stnid lat lon elevation time pressure z zh t td wind_speed wind_dir
0 71907 58.47 -78.08 26 2008-12-08 12:00:00 100300.0 250.0 25.492905 258.3 255.7 NaN NaN
1 71907 58.47 -78.08 26 2008-12-08 12:00:00 100000.0 430.0 43.847797 259.7 258.3 0.0 0.0
2 71907 58.47 -78.08 26 2008-12-08 12:00:00 99800.0 630.0 64.242121 261.1 259.6 NaN NaN
[8]:
df = df = pdbufr.read_bufr("temp_hires.bufr", reader="temp", geopotential="both", filters={"count": 1})
df[:3]
[8]:
stnid lat lon elevation time pressure z zh t td wind_speed wind_dir
0 10954 47.8341 10.8667 760.0 2025-02-23 10:45:04 100000 2467.353140 251.6 NaN NaN NaN NaN
1 10954 47.8341 10.8667 760.0 2025-02-23 10:45:04 94051 7454.034665 760.1 280.65 278.13 1.5 10.0
2 10954 47.8341 10.8667 760.0 2025-02-23 10:45:04 93999 NaN NaN 280.50 278.11 1.0 19.0

geopotential=raw

When geopotential="raw", both the geopotential and geopotential height will be added to the results, but no computation will be done. So there will be missing values in the output when the data is not available.

[9]:
# only geopotential is available in this file
df = df = pdbufr.read_bufr("temp_small.bufr", reader="temp", geopotential="raw", filters={"count": 1})
df[:3]
[9]:
stnid lat lon elevation time pressure z zh t td wind_speed wind_dir
0 71907 58.47 -78.08 26 2008-12-08 12:00:00 100300.0 250.0 None 258.3 255.7 NaN NaN
1 71907 58.47 -78.08 26 2008-12-08 12:00:00 100000.0 430.0 None 259.7 258.3 0.0 0.0
2 71907 58.47 -78.08 26 2008-12-08 12:00:00 99800.0 630.0 None 261.1 259.6 NaN NaN
[10]:
# only geopotential height is available in this file
df = df = pdbufr.read_bufr("temp_hires.bufr", reader="temp", geopotential="raw", filters={"count": 1})
df[:3]
[10]:
stnid lat lon elevation time pressure z zh t td wind_speed wind_dir
0 10954 47.8341 10.8667 760.0 2025-02-23 10:45:04 100000 None 251.6 NaN NaN NaN NaN
1 10954 47.8341 10.8667 760.0 2025-02-23 10:45:04 94051 None 760.1 280.65 278.13 1.5 10.0
2 10954 47.8341 10.8667 760.0 2025-02-23 10:45:04 93999 None NaN 280.50 278.11 1.0 19.0
[ ]: