Try this notebook in Binder.

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

Generic: aircraft data

[2]:
import datetime as dt
import pdbufr

The input BUFR data contains aircraft observations. Each message represents a single measurement of temperature, wind etc. at a given time and (3D) location.

In this notebook we read this data with the generic reader, which is the default reader.

Example 1

Extract all temperature observations.

[3]:
df = pdbufr.read_bufr("aircraft_small.bufr",
    columns=("aircraftFlightNumber", "latitude", "longitude", "pressure", "airTemperature"))
df
[3]:
aircraftFlightNumber latitude longitude pressure airTemperature
0 QGOBTRRA 35.10 -89.97 96750.0 283.4
1 QGOBTRRA 35.07 -89.97 99350.0 285.0
2 UOZDOZ2S 41.45 -75.43 24990.0 216.7
3 UOZDOZ2S 41.52 -75.63 22730.0 217.2
4 UOZDOZ2S 41.59 -75.87 20650.0 222.4
5 UOZDOZ2S 41.67 -76.16 18750.0 222.7
6 VUVTEWZQ 38.26 -78.57 20750.0 225.2
7 4IPASOZA 19.62 73.75 21660.0 222.7
8 WSSASKBA 42.31 -70.70 72710.0 266.2
9 WSSASKBA 42.29 -70.67 69790.0 265.7

Example 2

Getting data for a given flight only:

[4]:
df = pdbufr.read_bufr("aircraft_small.bufr",
    columns=("aircraftFlightNumber", "latitude", "longitude", "pressure", "airTemperature"),
    filters={"aircraftFlightNumber": "UOZDOZ2S"})
df
[4]:
aircraftFlightNumber latitude longitude pressure airTemperature
0 UOZDOZ2S 41.45 -75.43 24990.0 216.7
1 UOZDOZ2S 41.52 -75.63 22730.0 217.2
2 UOZDOZ2S 41.59 -75.87 20650.0 222.4
3 UOZDOZ2S 41.67 -76.16 18750.0 222.7

Example 3

Getting data for a given time interval only:

[5]:
df = pdbufr.read_bufr("aircraft_small.bufr",
    columns=("data_datetime", "aircraftFlightNumber",
             "latitude", "longitude", "pressure", "airTemperature"),
    filters={"data_datetime":
               slice(dt.datetime(2009,1,23,13,0), dt.datetime(2009,1,23,13,1))})
df
[5]:
aircraftFlightNumber latitude longitude pressure airTemperature data_datetime
0 QGOBTRRA 35.10 -89.97 96750.0 283.4 2009-01-23 13:00:00
1 QGOBTRRA 35.07 -89.97 99350.0 285.0 2009-01-23 13:01:00
2 UOZDOZ2S 41.59 -75.87 20650.0 222.4 2009-01-23 13:00:00
3 WSSASKBA 42.31 -70.70 72710.0 266.2 2009-01-23 13:00:00
4 WSSASKBA 42.29 -70.67 69790.0 265.7 2009-01-23 13:00:00