{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "07f3d9ac-2a07-4861-9c35-c44d21ea6b75", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "!test -f temp_small.bufr || wget https://get.ecmwf.int/repository/test-data/pdbufr/test-data/temp_small.bufr\n", "!test -f temp_hires.bufr || wget https://get.ecmwf.int/repository/test-data/pdbufr/test-data/temp_hires.bufr" ] }, { "cell_type": "markdown", "id": "ea721def-efc0-4cc1-a2d2-3b0b2c879858", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "## Temp: geopotential" ] }, { "cell_type": "code", "execution_count": 2, "id": "679a56c8-92da-4bdc-9d79-477bf380be6c", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "import pdbufr" ] }, { "cell_type": "raw", "id": "bc056fea-403f-4af2-b632-fd6ad6e7080b", "metadata": { "editable": true, "raw_mimetype": "text/restructuredtext", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "Temp BUFR messages can typically contain either geopotential (older format) or geopotential height (newer format) data. In this example we have 2 BUFR files: \"temp_small.bufr\" containing geopotential and \"temp_hires.bufr\" containing geopotential height data.\n", "\n", "We can control the extraction of these parameters via the ``geopotential`` keyword of the :ref:`temp reader `." ] }, { "cell_type": "markdown", "id": "5fa310be-2e44-489b-9152-b1e5be9a192c", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "#### geopotential=z" ] }, { "cell_type": "markdown", "id": "e9040704-38af-4bb4-aaf4-d47a0c9c8910", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "The default option is ``geopotential=\"z\"``, which means that only the geopotential will be added to the results. When it is not available it will be computed from geopotential height (when possible)." ] }, { "cell_type": "code", "execution_count": 3, "id": "735f1bc7-cefb-41f1-aee5-1ea97ba4ddc0", "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", "
stnidlatlonelevationtimepressurezttdwind_speedwind_dir
07190758.47-78.08262008-12-08 12:00:00100300.0250.0258.3255.7NaNNaN
17190758.47-78.08262008-12-08 12:00:00100000.0430.0259.7258.30.00.0
27190758.47-78.08262008-12-08 12:00:0099800.0630.0261.1259.6NaNNaN
\n", "
" ], "text/plain": [ " stnid lat lon elevation time pressure z t \\\n", "0 71907 58.47 -78.08 26 2008-12-08 12:00:00 100300.0 250.0 258.3 \n", "1 71907 58.47 -78.08 26 2008-12-08 12:00:00 100000.0 430.0 259.7 \n", "2 71907 58.47 -78.08 26 2008-12-08 12:00:00 99800.0 630.0 261.1 \n", "\n", " td wind_speed wind_dir \n", "0 255.7 NaN NaN \n", "1 258.3 0.0 0.0 \n", "2 259.6 NaN NaN " ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# geopotential is available in this file\n", "df = df = pdbufr.read_bufr(\"temp_small.bufr\", reader=\"temp\", filters={\"count\": 1})\n", "df[:3]" ] }, { "cell_type": "code", "execution_count": 4, "id": "5314d422-6c57-4d3f-a5f6-22368b76b860", "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", "
stnidlatlonelevationtimepressurezttdwind_speedwind_dir
01095447.834110.8667760.02025-02-23 10:45:041000002467.353140NaNNaNNaNNaN
11095447.834110.8667760.02025-02-23 10:45:04940517454.034665280.65278.131.510.0
21095447.834110.8667760.02025-02-23 10:45:0493999NaN280.50278.111.019.0
\n", "
" ], "text/plain": [ " stnid lat lon elevation time pressure \\\n", "0 10954 47.8341 10.8667 760.0 2025-02-23 10:45:04 100000 \n", "1 10954 47.8341 10.8667 760.0 2025-02-23 10:45:04 94051 \n", "2 10954 47.8341 10.8667 760.0 2025-02-23 10:45:04 93999 \n", "\n", " z t td wind_speed wind_dir \n", "0 2467.353140 NaN NaN NaN NaN \n", "1 7454.034665 280.65 278.13 1.5 10.0 \n", "2 NaN 280.50 278.11 1.0 19.0 " ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# geopotential is not available in this file, will be computed from geopotential height\n", "df = df = pdbufr.read_bufr(\"temp_hires.bufr\", reader=\"temp\", filters={\"count\": 1})\n", "df[:3]" ] }, { "cell_type": "markdown", "id": "813194aa-a97d-4e8a-b1c3-b6c199f811b5", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "#### geopotential=zh" ] }, { "cell_type": "markdown", "id": "86e9a34e-1232-466f-964a-3411f16ee2dd", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "When ``geopotential=\"zh\"``, only the geopotential height will be added to the results. When it is not available it will be computed from geopotential (when possible)." ] }, { "cell_type": "code", "execution_count": 5, "id": "18a42ce4-4387-430d-89c5-076b48430f32", "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", "
stnidlatlonelevationtimepressurezhttdwind_speedwind_dir
07190758.47-78.08262008-12-08 12:00:00100300.025.492905258.3255.7NaNNaN
17190758.47-78.08262008-12-08 12:00:00100000.043.847797259.7258.30.00.0
27190758.47-78.08262008-12-08 12:00:0099800.064.242121261.1259.6NaNNaN
\n", "
" ], "text/plain": [ " stnid lat lon elevation time pressure zh \\\n", "0 71907 58.47 -78.08 26 2008-12-08 12:00:00 100300.0 25.492905 \n", "1 71907 58.47 -78.08 26 2008-12-08 12:00:00 100000.0 43.847797 \n", "2 71907 58.47 -78.08 26 2008-12-08 12:00:00 99800.0 64.242121 \n", "\n", " t td wind_speed wind_dir \n", "0 258.3 255.7 NaN NaN \n", "1 259.7 258.3 0.0 0.0 \n", "2 261.1 259.6 NaN NaN " ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# geopotential height is not available in this file, will be computed from geopotential\n", "df = df = pdbufr.read_bufr(\"temp_small.bufr\", reader=\"temp\", geopotential=\"zh\", filters={\"count\": 1})\n", "df[:3]" ] }, { "cell_type": "code", "execution_count": 6, "id": "91e5afec-5cb5-4353-80df-679f53f6bf6e", "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", "
stnidlatlonelevationtimepressurezhttdwind_speedwind_dir
01095447.834110.8667760.02025-02-23 10:45:04100000251.6NaNNaNNaNNaN
11095447.834110.8667760.02025-02-23 10:45:0494051760.1280.65278.131.510.0
21095447.834110.8667760.02025-02-23 10:45:0493999NaN280.50278.111.019.0
\n", "
" ], "text/plain": [ " stnid lat lon elevation time pressure zh \\\n", "0 10954 47.8341 10.8667 760.0 2025-02-23 10:45:04 100000 251.6 \n", "1 10954 47.8341 10.8667 760.0 2025-02-23 10:45:04 94051 760.1 \n", "2 10954 47.8341 10.8667 760.0 2025-02-23 10:45:04 93999 NaN \n", "\n", " t td wind_speed wind_dir \n", "0 NaN NaN NaN NaN \n", "1 280.65 278.13 1.5 10.0 \n", "2 280.50 278.11 1.0 19.0 " ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# geopotential height is available in this file\n", "df = df = pdbufr.read_bufr(\"temp_hires.bufr\", reader=\"temp\", geopotential=\"zh\", filters={\"count\": 1})\n", "df[:3]" ] }, { "cell_type": "markdown", "id": "bb777b3d-4735-451b-ad50-af549ddf5a33", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "#### geopotential=both" ] }, { "cell_type": "markdown", "id": "69fcc2cf-2e48-49de-a166-f771e0c01ddf", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "When ``geopotential=\"both\"``, both the geopotential and geopotential height will be added to the results. When one of it is not available it will be computed (when possible)." ] }, { "cell_type": "code", "execution_count": 7, "id": "8f1d8c24-af6d-4ca5-8200-e38c5390bc1b", "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", "
stnidlatlonelevationtimepressurezzhttdwind_speedwind_dir
07190758.47-78.08262008-12-08 12:00:00100300.0250.025.492905258.3255.7NaNNaN
17190758.47-78.08262008-12-08 12:00:00100000.0430.043.847797259.7258.30.00.0
27190758.47-78.08262008-12-08 12:00:0099800.0630.064.242121261.1259.6NaNNaN
\n", "
" ], "text/plain": [ " stnid lat lon elevation time pressure z \\\n", "0 71907 58.47 -78.08 26 2008-12-08 12:00:00 100300.0 250.0 \n", "1 71907 58.47 -78.08 26 2008-12-08 12:00:00 100000.0 430.0 \n", "2 71907 58.47 -78.08 26 2008-12-08 12:00:00 99800.0 630.0 \n", "\n", " zh t td wind_speed wind_dir \n", "0 25.492905 258.3 255.7 NaN NaN \n", "1 43.847797 259.7 258.3 0.0 0.0 \n", "2 64.242121 261.1 259.6 NaN NaN " ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = df = pdbufr.read_bufr(\"temp_small.bufr\", reader=\"temp\", geopotential=\"both\", filters={\"count\": 1})\n", "df[:3]" ] }, { "cell_type": "code", "execution_count": 8, "id": "549c64c3-7a49-454d-b3d7-43746462a4cf", "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", "
stnidlatlonelevationtimepressurezzhttdwind_speedwind_dir
01095447.834110.8667760.02025-02-23 10:45:041000002467.353140251.6NaNNaNNaNNaN
11095447.834110.8667760.02025-02-23 10:45:04940517454.034665760.1280.65278.131.510.0
21095447.834110.8667760.02025-02-23 10:45:0493999NaNNaN280.50278.111.019.0
\n", "
" ], "text/plain": [ " stnid lat lon elevation time pressure \\\n", "0 10954 47.8341 10.8667 760.0 2025-02-23 10:45:04 100000 \n", "1 10954 47.8341 10.8667 760.0 2025-02-23 10:45:04 94051 \n", "2 10954 47.8341 10.8667 760.0 2025-02-23 10:45:04 93999 \n", "\n", " z zh t td wind_speed wind_dir \n", "0 2467.353140 251.6 NaN NaN NaN NaN \n", "1 7454.034665 760.1 280.65 278.13 1.5 10.0 \n", "2 NaN NaN 280.50 278.11 1.0 19.0 " ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = df = pdbufr.read_bufr(\"temp_hires.bufr\", reader=\"temp\", geopotential=\"both\", filters={\"count\": 1})\n", "df[:3]" ] }, { "cell_type": "markdown", "id": "a68baf7b-fe4f-4ced-ba81-57fc8d0b68de", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "#### geopotential=raw" ] }, { "cell_type": "markdown", "id": "5cba3f07-44d8-4ec2-bc8d-211284f6bdcb", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "When ``geopotential=\"raw\"``, both the geopotential and geopotential height will be added to the results, but no computation will be done. So there will be missing values in the output when the data is not available. " ] }, { "cell_type": "code", "execution_count": 9, "id": "8d74c1f7-a8aa-4465-a05b-a403184e565e", "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", "
stnidlatlonelevationtimepressurezzhttdwind_speedwind_dir
07190758.47-78.08262008-12-08 12:00:00100300.0250.0None258.3255.7NaNNaN
17190758.47-78.08262008-12-08 12:00:00100000.0430.0None259.7258.30.00.0
27190758.47-78.08262008-12-08 12:00:0099800.0630.0None261.1259.6NaNNaN
\n", "
" ], "text/plain": [ " stnid lat lon elevation time pressure z zh \\\n", "0 71907 58.47 -78.08 26 2008-12-08 12:00:00 100300.0 250.0 None \n", "1 71907 58.47 -78.08 26 2008-12-08 12:00:00 100000.0 430.0 None \n", "2 71907 58.47 -78.08 26 2008-12-08 12:00:00 99800.0 630.0 None \n", "\n", " t td wind_speed wind_dir \n", "0 258.3 255.7 NaN NaN \n", "1 259.7 258.3 0.0 0.0 \n", "2 261.1 259.6 NaN NaN " ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# only geopotential is available in this file\n", "df = df = pdbufr.read_bufr(\"temp_small.bufr\", reader=\"temp\", geopotential=\"raw\", filters={\"count\": 1})\n", "df[:3]" ] }, { "cell_type": "code", "execution_count": 10, "id": "7419473e-506e-4862-a73f-28bf0c7c1922", "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", "
stnidlatlonelevationtimepressurezzhttdwind_speedwind_dir
01095447.834110.8667760.02025-02-23 10:45:04100000None251.6NaNNaNNaNNaN
11095447.834110.8667760.02025-02-23 10:45:0494051None760.1280.65278.131.510.0
21095447.834110.8667760.02025-02-23 10:45:0493999NoneNaN280.50278.111.019.0
\n", "
" ], "text/plain": [ " stnid lat lon elevation time pressure z \\\n", "0 10954 47.8341 10.8667 760.0 2025-02-23 10:45:04 100000 None \n", "1 10954 47.8341 10.8667 760.0 2025-02-23 10:45:04 94051 None \n", "2 10954 47.8341 10.8667 760.0 2025-02-23 10:45:04 93999 None \n", "\n", " zh t td wind_speed wind_dir \n", "0 251.6 NaN NaN NaN NaN \n", "1 760.1 280.65 278.13 1.5 10.0 \n", "2 NaN 280.50 278.11 1.0 19.0 " ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# only geopotential height is available in this file\n", "df = df = pdbufr.read_bufr(\"temp_hires.bufr\", reader=\"temp\", geopotential=\"raw\", filters={\"count\": 1})\n", "df[:3]" ] }, { "cell_type": "code", "execution_count": null, "id": "01115cca-9ceb-4fa8-a5aa-c30381acaef1", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [] } ], "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" } }, "nbformat": 4, "nbformat_minor": 5 }