{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "!test -f aircraft_small.bufr || wget https://get.ecmwf.int/repository/test-data/pdbufr/test-data/aircraft_small.bufr" ] }, { "cell_type": "markdown", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "# Generic: aircraft data" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "import datetime as dt\n", "import pdbufr" ] }, { "cell_type": "raw", "metadata": { "editable": true, "raw_mimetype": "text/restructuredtext", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "The input BUFR data contains aircraft observations. Each message represents a single measurement of temperature, wind etc. at a given time and (3D) location.\n", "\n", "In this notebook we read this data with the :ref:`generic reader `, which is the default reader." ] }, { "cell_type": "markdown", "metadata": { "editable": true, "raw_mimetype": "text/x-rst", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "#### Example 1\n", "\n", "Extract all temperature observations." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
aircraftFlightNumberlatitudelongitudepressureairTemperature
0QGOBTRRA35.10-89.9796750.0283.4
1QGOBTRRA35.07-89.9799350.0285.0
2UOZDOZ2S41.45-75.4324990.0216.7
3UOZDOZ2S41.52-75.6322730.0217.2
4UOZDOZ2S41.59-75.8720650.0222.4
5UOZDOZ2S41.67-76.1618750.0222.7
6VUVTEWZQ38.26-78.5720750.0225.2
74IPASOZA19.6273.7521660.0222.7
8WSSASKBA42.31-70.7072710.0266.2
9WSSASKBA42.29-70.6769790.0265.7
\n", "
" ], "text/plain": [ " aircraftFlightNumber latitude longitude pressure airTemperature\n", "0 QGOBTRRA 35.10 -89.97 96750.0 283.4\n", "1 QGOBTRRA 35.07 -89.97 99350.0 285.0\n", "2 UOZDOZ2S 41.45 -75.43 24990.0 216.7\n", "3 UOZDOZ2S 41.52 -75.63 22730.0 217.2\n", "4 UOZDOZ2S 41.59 -75.87 20650.0 222.4\n", "5 UOZDOZ2S 41.67 -76.16 18750.0 222.7\n", "6 VUVTEWZQ 38.26 -78.57 20750.0 225.2\n", "7 4IPASOZA 19.62 73.75 21660.0 222.7\n", "8 WSSASKBA 42.31 -70.70 72710.0 266.2\n", "9 WSSASKBA 42.29 -70.67 69790.0 265.7" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = pdbufr.read_bufr(\"aircraft_small.bufr\", \n", " columns=(\"aircraftFlightNumber\", \"latitude\", \"longitude\", \"pressure\", \"airTemperature\"))\n", "df" ] }, { "cell_type": "markdown", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "#### Example 2\n", "\n", "Getting data for a given flight only:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
aircraftFlightNumberlatitudelongitudepressureairTemperature
0UOZDOZ2S41.45-75.4324990.0216.7
1UOZDOZ2S41.52-75.6322730.0217.2
2UOZDOZ2S41.59-75.8720650.0222.4
3UOZDOZ2S41.67-76.1618750.0222.7
\n", "
" ], "text/plain": [ " aircraftFlightNumber latitude longitude pressure airTemperature\n", "0 UOZDOZ2S 41.45 -75.43 24990.0 216.7\n", "1 UOZDOZ2S 41.52 -75.63 22730.0 217.2\n", "2 UOZDOZ2S 41.59 -75.87 20650.0 222.4\n", "3 UOZDOZ2S 41.67 -76.16 18750.0 222.7" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = pdbufr.read_bufr(\"aircraft_small.bufr\",\n", " columns=(\"aircraftFlightNumber\", \"latitude\", \"longitude\", \"pressure\", \"airTemperature\"),\n", " filters={\"aircraftFlightNumber\": \"UOZDOZ2S\"})\n", "df" ] }, { "cell_type": "markdown", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "#### Example 3\n", "\n", "Getting data for a given time interval only:" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
aircraftFlightNumberlatitudelongitudepressureairTemperaturedata_datetime
0QGOBTRRA35.10-89.9796750.0283.42009-01-23 13:00:00
1QGOBTRRA35.07-89.9799350.0285.02009-01-23 13:01:00
2UOZDOZ2S41.59-75.8720650.0222.42009-01-23 13:00:00
3WSSASKBA42.31-70.7072710.0266.22009-01-23 13:00:00
4WSSASKBA42.29-70.6769790.0265.72009-01-23 13:00:00
\n", "
" ], "text/plain": [ " aircraftFlightNumber latitude longitude pressure airTemperature \\\n", "0 QGOBTRRA 35.10 -89.97 96750.0 283.4 \n", "1 QGOBTRRA 35.07 -89.97 99350.0 285.0 \n", "2 UOZDOZ2S 41.59 -75.87 20650.0 222.4 \n", "3 WSSASKBA 42.31 -70.70 72710.0 266.2 \n", "4 WSSASKBA 42.29 -70.67 69790.0 265.7 \n", "\n", " data_datetime \n", "0 2009-01-23 13:00:00 \n", "1 2009-01-23 13:01:00 \n", "2 2009-01-23 13:00:00 \n", "3 2009-01-23 13:00:00 \n", "4 2009-01-23 13:00:00 " ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = pdbufr.read_bufr(\"aircraft_small.bufr\", \n", " columns=(\"data_datetime\", \"aircraftFlightNumber\", \n", " \"latitude\", \"longitude\", \"pressure\", \"airTemperature\"),\n", " filters={\"data_datetime\": \n", " slice(dt.datetime(2009,1,23,13,0), dt.datetime(2009,1,23,13,1))})\n", "df" ] } ], "metadata": { "kernelspec": { "display_name": "dev", "language": "python", "name": "dev" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.12" }, "vscode": { "interpreter": { "hash": "22dc05efe0944894879e71a134ce5db002aedecbcd8b98acee6e3c2217e44519" } } }, "nbformat": 4, "nbformat_minor": 4 }