In this notebook you will see how to:
inspect BUFR data
extract BUFR data into a Pandas dataframe
Getting the data¶
First we read some BUFR data from disk with from_source().
import earthkit.data as ekd
d = ekd.from_source("file", "synop_10.bufr")
dFeaturelists and BUFR messages¶
To inspect BUFR data we need to convert it into a featureslist. It is a similar object to a fieldList, but it is an iterable of “features”, where a “feature” can be anything. In a BUFR featurelist each feature is a BUFR messag.
fl = d.to_featurelist()len(fl)fl.ls()BUFR messages¶
# f is the first message in the featurelist
f = fl[0]
ff.describe()Subsetting¶
fl1 = fl.sel(dataSubCategory=1, ident=[60545, 48352])
fl1.ls()Converting to pandas¶
BUFR data can be extracted into a Pandas dataframe using to_pandas(), which passes all the arguments to the read_bufr() <https://pdbufr.readthedocs.io/en/latest/read_bufr.html>_ method from pdbufr.
df = fl.to_pandas(columns=["latitude", "longitude",
"heightOfStation","airTemperatureAt2M"])
dfdf = fl.to_pandas(reader="synop")
dfPlease note it is also possible to call to_pandas() on the input data object “d”. It this case, first the data is converted to a featurelist under the hood, then to_pandas() is called on the featurelist.
df = d.to_pandas(columns=["latitude", "longitude",
"heightOfStation","airTemperatureAt2M"])
df