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

Temp: overview

[2]:
import pdbufr

The input BUFR data contains Temp (radiosonde) observations. In this notebook we will read this file with the temp reader, which uses pre-defined parameters instead of the ecCodes BUFR keys. Parameter is a high-level concept in pdbufr enabling data extraction without knowing the actual BUFR encoding and allowing more tailor-made access to specific data types.

The default settings

By default the “stnid”, “lat”, “lon”, “elevation”, “time” (see station parameters for details) and the upper level parameters are extracted. We only extract the first station from the BUFR file by specifying a filter. The resulting dataframe contains one row per pressure level.

[3]:
df = pdbufr.read_bufr("temp_small.bufr", reader="temp", filters={"count": 1})
df[:10]
[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
3 71907 58.47 -78.08 26 2008-12-08 12:00:00 99100.0 1160.0 261.7 258.3 NaN NaN
4 71907 58.47 -78.08 26 2008-12-08 12:00:00 92500.0 6240.0 258.1 256.2 5.0 275.0
5 71907 58.47 -78.08 26 2008-12-08 12:00:00 85000.0 12470.0 253.1 251.0 9.0 250.0
6 71907 58.47 -78.08 26 2008-12-08 12:00:00 75100.0 21340.0 245.3 244.2 NaN NaN
7 71907 58.47 -78.08 26 2008-12-08 12:00:00 72400.0 23900.0 242.9 239.7 NaN NaN
8 71907 58.47 -78.08 26 2008-12-08 12:00:00 71700.0 24580.0 242.3 239.3 NaN NaN
9 71907 58.47 -78.08 26 2008-12-08 12:00:00 70000.0 26240.0 241.7 238.3 12.0 235.0

Using parameter groups

By using the columns option we can control the parameters to extract. Using the pre-defined values of “station”, “location” or “geometry” we will only read station related information yielding one row per station. See details here.

[4]:
pdbufr.read_bufr("temp_small.bufr", reader="temp", columns="station")
[4]:
stnid lat lon elevation time
0 71907 58.47 -78.08 26 2008-12-08 12:00:00
1 71823 53.75 -73.67 302 2008-12-08 12:00:00
2 89009 -90.00 0.00 2835 2008-12-08 12:00:00
3 91348 6.97 158.22 38 2008-12-08 12:00:00
4 91408 7.33 134.48 30 2008-12-08 12:00:00
5 71836 51.27 -80.65 11 2008-12-08 12:00:00
6 83612 -20.47 -54.67 567 2008-12-08 12:00:00
[5]:
pdbufr.read_bufr("temp_small.bufr", reader="temp", columns="location")
[5]:
lat lon
0 58.47 -78.08
1 53.75 -73.67
2 -90.00 0.00
3 6.97 158.22
4 7.33 134.48
5 51.27 -80.65
6 -20.47 -54.67
[6]:
pdbufr.read_bufr("temp_small.bufr", reader="temp", columns="geometry")
[6]:
lat lon elevation
0 58.47 -78.08 26
1 53.75 -73.67 302
2 -90.00 0.00 2835
3 6.97 158.22 38
4 7.33 134.48 30
5 51.27 -80.65 11
6 -20.47 -54.67 567

We can can combine these groups with “upper”, which represents the pressure level parameters. Please note thath at the moment it is not possible to use individual parameters in columns.

[7]:
df = pdbufr.read_bufr("temp_small.bufr", reader="temp", columns=["location","upper"], filters={"count": 1})
df[:5]
[7]:
lat lon pressure z t td wind_speed wind_dir
0 58.47 -78.08 100300.0 250.0 258.3 255.7 NaN NaN
1 58.47 -78.08 100000.0 430.0 259.7 258.3 0.0 0.0
2 58.47 -78.08 99800.0 630.0 261.1 259.6 NaN NaN
3 58.47 -78.08 99100.0 1160.0 261.7 258.3 NaN NaN
4 58.47 -78.08 92500.0 6240.0 258.1 256.2 5.0 275.0

Adding units columns

With units_columns=True we can add units to the resulting DataFrame.

[8]:
df = pdbufr.read_bufr("temp_small.bufr", reader="temp", filters={"count": 1}, units_columns=True)
df[:5]
[8]:
stnid lat lon elevation time pressure pressure_units z z_units t t_units td td_units wind_speed wind_speed_units wind_dir wind_dir_units
0 71907 58.47 -78.08 26 2008-12-08 12:00:00 100300.0 Pa 250.0 m2 s-2 258.3 K 255.7 K NaN m/s NaN deg
1 71907 58.47 -78.08 26 2008-12-08 12:00:00 100000.0 Pa 430.0 m2 s-2 259.7 K 258.3 K 0.0 m/s 0.0 deg
2 71907 58.47 -78.08 26 2008-12-08 12:00:00 99800.0 Pa 630.0 m2 s-2 261.1 K 259.6 K NaN m/s NaN deg
3 71907 58.47 -78.08 26 2008-12-08 12:00:00 99100.0 Pa 1160.0 m2 s-2 261.7 K 258.3 K NaN m/s NaN deg
4 71907 58.47 -78.08 26 2008-12-08 12:00:00 92500.0 Pa 6240.0 m2 s-2 258.1 K 256.2 K 5.0 m/s 275.0 deg
[ ]: