{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "!test -f temp.bufr || wget https://get.ecmwf.int/repository/test-data/pdbufr/test-data/sample-data/temp.bufr" ] }, { "cell_type": "markdown", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "# Generic: radiosonde data" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "import pdbufr" ] }, { "cell_type": "raw", "metadata": { "editable": true, "raw_mimetype": "text/restructuredtext", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "The input BUFR data contains radiosonde observations. Each message represents a given station and contains vertical profiles on a set of pressure levels. \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", "Getting the WMO station ID and location for each message. Notice that since \"WMO_station_id\" is a computed key it appears as the last column in the resulting dataframe." ] }, { "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", "
latitudelongitudeWMO_station_id
058.47-78.0871907
153.75-73.6771823
2-90.000.0089009
318.43-69.8878486
421.98-159.3391165
\n", "
" ], "text/plain": [ " latitude longitude WMO_station_id\n", "0 58.47 -78.08 71907\n", "1 53.75 -73.67 71823\n", "2 -90.00 0.00 89009\n", "3 18.43 -69.88 78486\n", "4 21.98 -159.33 91165" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = pdbufr.read_bufr(\"temp.bufr\", \n", " columns=(\"WMO_station_id\", \"latitude\", \"longitude\"))\n", "df.head()" ] }, { "cell_type": "markdown", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "#### Example 2\n", "\n", "Extracting the same data but only for a given station." ] }, { "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", "
latitudelongitudeWMO_station_id
058.47-78.0871907
\n", "
" ], "text/plain": [ " latitude longitude WMO_station_id\n", "0 58.47 -78.08 71907" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = pdbufr.read_bufr(\"temp.bufr\", \n", " columns=(\"WMO_station_id\", \"latitude\", \"longitude\"),\n", " filters={\"WMO_station_id\": 71907},)\n", "df" ] }, { "cell_type": "markdown", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "#### Example 3\n", "\n", "Getting temperature profiles for two stations." ] }, { "cell_type": "code", "execution_count": 5, "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", " \n", " \n", "
pressureairTemperaturedata_datetimeWMO_station_id
0100300.0258.32008-12-08 12:00:0071907
1100000.0259.72008-12-08 12:00:0071907
299800.0261.12008-12-08 12:00:0071907
399100.0261.72008-12-08 12:00:0071907
492500.0258.12008-12-08 12:00:0071907
\n", "
" ], "text/plain": [ " pressure airTemperature data_datetime WMO_station_id\n", "0 100300.0 258.3 2008-12-08 12:00:00 71907\n", "1 100000.0 259.7 2008-12-08 12:00:00 71907\n", "2 99800.0 261.1 2008-12-08 12:00:00 71907\n", "3 99100.0 261.7 2008-12-08 12:00:00 71907\n", "4 92500.0 258.1 2008-12-08 12:00:00 71907" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = pdbufr.read_bufr(\"temp.bufr\",\n", " columns=(\"WMO_station_id\", \"data_datetime\", \"pressure\", \"airTemperature\"),\n", " filters={\"WMO_station_id\": [71823, 71907]})\n", "df.head()" ] }, { "cell_type": "code", "execution_count": 6, "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", " \n", " \n", "
pressureairTemperaturedata_datetimeWMO_station_id
4430000.0218.92008-12-08 12:00:0071823
4529700.0218.92008-12-08 12:00:0071823
4625000.0221.12008-12-08 12:00:0071823
4723200.0223.12008-12-08 12:00:0071823
4820500.0221.52008-12-08 12:00:0071823
\n", "
" ], "text/plain": [ " pressure airTemperature data_datetime WMO_station_id\n", "44 30000.0 218.9 2008-12-08 12:00:00 71823\n", "45 29700.0 218.9 2008-12-08 12:00:00 71823\n", "46 25000.0 221.1 2008-12-08 12:00:00 71823\n", "47 23200.0 223.1 2008-12-08 12:00:00 71823\n", "48 20500.0 221.5 2008-12-08 12:00:00 71823" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.tail()" ] }, { "cell_type": "markdown", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "#### Example 4\n", "\n", "Extracting temperature profiles for a given station only on standard pressure levels when temperature >= -30 C." ] }, { "cell_type": "code", "execution_count": 7, "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", "
pressureairTemperaturedata_datetimeWMO_station_id
0100000.0259.72008-12-08 12:00:0071907
192500.0258.12008-12-08 12:00:0071907
285000.0253.12008-12-08 12:00:0071907
\n", "
" ], "text/plain": [ " pressure airTemperature data_datetime WMO_station_id\n", "0 100000.0 259.7 2008-12-08 12:00:00 71907\n", "1 92500.0 258.1 2008-12-08 12:00:00 71907\n", "2 85000.0 253.1 2008-12-08 12:00:00 71907" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = pdbufr.read_bufr(\"temp.bufr\",\n", " columns=(\"WMO_station_id\", \"data_datetime\", \"pressure\", \"airTemperature\"),\n", " filters={\"WMO_station_id\": 71907, \n", " \"verticalSoundingSignificance\": 32, \n", " \"airTemperature\": slice(243.16, None)})\n", "df" ] }, { "cell_type": "markdown", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "#### Example 5\n", "\n", "Extracting temperature, dewpoint and wind values on 500 hPa in the tropics:" ] }, { "cell_type": "code", "execution_count": 8, "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", " \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", "
latitudelongitudepressureairTemperaturedewpointTemperaturewindDirectionwindSpeed
018.43-69.8850000.0267.5247.52754.0
118.03-63.1250000.0267.5244.53405.0
213.47144.7850000.0270.3249.311012.0
37.08171.3850000.0268.9226.92206.0
47.45151.8350000.0269.9249.95018.0
........................
69-10.17123.6750000.0269.5267.07011.0
70-1.18136.1250000.0264.1262.6808.0
71-2.17106.1350000.0268.9263.91356.0
722.83-60.7050000.0267.5258.5908.0
73-3.67-69.6750000.0266.7266.63504.0
\n", "

74 rows × 7 columns

\n", "
" ], "text/plain": [ " latitude longitude pressure airTemperature dewpointTemperature \\\n", "0 18.43 -69.88 50000.0 267.5 247.5 \n", "1 18.03 -63.12 50000.0 267.5 244.5 \n", "2 13.47 144.78 50000.0 270.3 249.3 \n", "3 7.08 171.38 50000.0 268.9 226.9 \n", "4 7.45 151.83 50000.0 269.9 249.9 \n", ".. ... ... ... ... ... \n", "69 -10.17 123.67 50000.0 269.5 267.0 \n", "70 -1.18 136.12 50000.0 264.1 262.6 \n", "71 -2.17 106.13 50000.0 268.9 263.9 \n", "72 2.83 -60.70 50000.0 267.5 258.5 \n", "73 -3.67 -69.67 50000.0 266.7 266.6 \n", "\n", " windDirection windSpeed \n", "0 275 4.0 \n", "1 340 5.0 \n", "2 110 12.0 \n", "3 220 6.0 \n", "4 50 18.0 \n", ".. ... ... \n", "69 70 11.0 \n", "70 80 8.0 \n", "71 135 6.0 \n", "72 90 8.0 \n", "73 350 4.0 \n", "\n", "[74 rows x 7 columns]" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = pdbufr.read_bufr(\"temp.bufr\",\n", " columns=(\"latitude\", \"longitude\", \"pressure\", \"airTemperature\", \"dewpointTemperature\", \"windDirection\", \"windSpeed\"),\n", " filters={\"latitude\": slice(-20, 20), \"pressure\": 50000})\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 }