[1]:
!test -f aircraft_small.bufr \
    || wget https://sites.ecmwf.int/repository/pdbufr/test-data/aircraft_small.bufr \
             --output-document=aircraft_small.bufr

Flat reader: aircraft data

[2]:
import pdbufr

The notebook demonstrates the usage of the flat reader with aircraft data in block extraction mode.

Block extraction is activated by passing one of the special values “all”, “header” or “data” to the columns parameter. The default (columns=[]) is equivalent to columns=”all”.

Using columns

By default all the header and data keys are extracted.

[3]:
df = pdbufr.read_bufr("aircraft_small.bufr", reader="flat")
df.T
[3]:
0 1 2 3 4 5 6 7 8 9
edition 3 3 3 3 3 3 3 3 3 3
masterTableNumber 0 0 0 0 0 0 0 0 0 0
bufrHeaderSubCentre 0 0 0 0 0 0 0 0 0 0
bufrHeaderCentre 98 98 98 98 98 98 98 98 98 98
updateSequenceNumber 0 0 0 0 0 0 0 0 0 0
... ... ... ... ... ... ... ... ... ... ...
#1#dewpointTemperature None None None None None None None None None None
#1#relativeHumidity None None None None None None None None None None
#1#airframeIcing None None None None None None None None None None
#1#centre 98 98 98 98 98 98 98 98 98 98
#1#generatingApplication 1 1 1 1 1 1 1 1 1 1

81 rows × 10 columns

However, we can extract only the header keys:

[4]:
df = pdbufr.read_bufr("aircraft_small.bufr", columns="header", reader="flat")
df.T[:6]
[4]:
0 1 2 3 4 5 6 7 8 9
edition 3 3 3 3 3 3 3 3 3 3
masterTableNumber 0 0 0 0 0 0 0 0 0 0
bufrHeaderSubCentre 0 0 0 0 0 0 0 0 0 0
bufrHeaderCentre 98 98 98 98 98 98 98 98 98 98
updateSequenceNumber 0 0 0 0 0 0 0 0 0 0
dataCategory 4 4 4 4 4 4 4 4 4 4

or only the data keys:

[5]:
df = pdbufr.read_bufr("aircraft_small.bufr", columns="data", reader="flat")
df.T[:18]
[5]:
0 1 2 3 4 5 6 7 8 9
subsetNumber 1 1 1 1 1 1 1 1 1 1
#1#aircraftFlightNumber QGOBTRRA QGOBTRRA UOZDOZ2S UOZDOZ2S UOZDOZ2S UOZDOZ2S VUVTEWZQ 4IPASOZA WSSASKBA WSSASKBA
#1#aircraftRegistrationNumberOrOtherIdentification HGSKJFBA HGSKJFBA O2RYR4JA O2RYR4JA O2RYR4JA O2RYR4JA 4NK13QZA 0IKWU1JA P4MAWDZA P4MAWDZA
#1#aircraftNavigationalSystem None None None None None None None None None None
#1#aircraftDataRelaySystemType 3 3 3 3 3 3 3 3 3 3
#1#instrumentationForWindMeasurement 4 4 4 4 4 4 4 4 4 4
#1#temperatureObservationPrecision 0.1 0.1 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25
#1#originalSpecificationOfLatitudeOrLongitude 1 1 10 10 10 10 10 1 10 10
#1#aircraftRollAngle None None None None None None None None None None
#1#stationType 0 0 0 0 0 0 0 0 0 0
#1#year 2009 2009 2009 2009 2009 2009 2009 2009 2009 2009
#1#month 1 1 1 1 1 1 1 1 1 1
#1#day 23 23 23 23 23 23 23 23 23 23
#1#hour 13 13 12 12 13 13 13 13 13 13
#1#minute 0 1 56 58 0 2 2 2 0 0
#1#latitude 35.1 35.07 41.45 41.52 41.59 41.67 38.26 19.62 42.31 42.29
#1#longitude -89.97 -89.97 -75.43 -75.63 -75.87 -76.16 -78.57 73.75 -70.7 -70.67
#1#phaseOfAircraftFlight 6.0 6.0 NaN NaN NaN NaN 3.0 NaN 5.0 5.0

Filtering

Filtering works similarly to the hierarchical (i.e. non-flat) mode. In the following example only the messages/subsets matching a given flight number are extracted.

[6]:
df = pdbufr.read_bufr(
    "aircraft_small.bufr", columns="data", filters={"aircraftFlightNumber": "UOZDOZ2S"}, reader="flat"
)
df.T.iloc[:18]
[6]:
0 1 2 3
subsetNumber 1 1 1 1
#1#aircraftFlightNumber UOZDOZ2S UOZDOZ2S UOZDOZ2S UOZDOZ2S
#1#aircraftRegistrationNumberOrOtherIdentification O2RYR4JA O2RYR4JA O2RYR4JA O2RYR4JA
#1#aircraftNavigationalSystem None None None None
#1#aircraftDataRelaySystemType 3 3 3 3
#1#instrumentationForWindMeasurement 4 4 4 4
#1#temperatureObservationPrecision 0.25 0.25 0.25 0.25
#1#originalSpecificationOfLatitudeOrLongitude 10 10 10 10
#1#aircraftRollAngle None None None None
#1#stationType 0 0 0 0
#1#year 2009 2009 2009 2009
#1#month 1 1 1 1
#1#day 23 23 23 23
#1#hour 12 12 13 13
#1#minute 56 58 0 2
#1#latitude 41.45 41.52 41.59 41.67
#1#longitude -75.43 -75.63 -75.87 -76.16
#1#phaseOfAircraftFlight None None None None