{ "cells": [ { "cell_type": "markdown", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "## GRIB: inspecting contents" ] }, { "cell_type": "raw", "metadata": { "editable": true, "raw_mimetype": "text/restructuredtext", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "We will work with a GRIB file containing 6 messages. First we ensure the example file is available, then read the file with :ref:`from_source() `." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "import earthkit.data as ekd\n", "ekd.download_example_file(\"test6.grib\")" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "fs = ekd.from_source(\"file\", \"test6.grib\")" ] }, { "cell_type": "markdown", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "### Using head(), tail() and ls()" ] }, { "cell_type": "raw", "metadata": { "editable": true, "raw_mimetype": "text/restructuredtext", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "All these methods (:py:meth:`~data.readers.grib.index.GribFieldList.head`, :py:meth:`~data.readers.grib.index.GribFieldList.tail` and :py:meth:`~data.readers.grib.index.GribFieldList.ls`) take the same set of keyword arguments:\n", "\n", "- n: number of messages to list\n", "- keys: the metadata keys to dump\n", "- extra_keys: extra keys of top of the default set of keys\n", "- namespace: the :xref:`eccodes_namespace` to use" ] }, { "cell_type": "markdown", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "#### head()" ] }, { "cell_type": "raw", "metadata": { "editable": true, "raw_mimetype": "text/restructuredtext", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ ":py:meth:`~data.readers.grib.index.GribFieldList.head` displays the first 5 messages by default:" ] }, { "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", "
centreshortNametypeOfLevelleveldataDatedataTimestepRangedataTypenumbergridType
0ecmftisobaricInhPa10002018080112000an0regular_ll
1ecmfuisobaricInhPa10002018080112000an0regular_ll
2ecmfvisobaricInhPa10002018080112000an0regular_ll
3ecmftisobaricInhPa8502018080112000an0regular_ll
4ecmfuisobaricInhPa8502018080112000an0regular_ll
\n", "
" ], "text/plain": [ " centre shortName typeOfLevel level dataDate dataTime stepRange \\\n", "0 ecmf t isobaricInhPa 1000 20180801 1200 0 \n", "1 ecmf u isobaricInhPa 1000 20180801 1200 0 \n", "2 ecmf v isobaricInhPa 1000 20180801 1200 0 \n", "3 ecmf t isobaricInhPa 850 20180801 1200 0 \n", "4 ecmf u isobaricInhPa 850 20180801 1200 0 \n", "\n", " dataType number gridType \n", "0 an 0 regular_ll \n", "1 an 0 regular_ll \n", "2 an 0 regular_ll \n", "3 an 0 regular_ll \n", "4 an 0 regular_ll " ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fs.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The number of fields can be passed as an argument:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "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", "
centreshortNametypeOfLevelleveldataDatedataTimestepRangedataTypenumbergridType
0ecmftisobaricInhPa10002018080112000an0regular_ll
1ecmfuisobaricInhPa10002018080112000an0regular_ll
\n", "
" ], "text/plain": [ " centre shortName typeOfLevel level dataDate dataTime stepRange \\\n", "0 ecmf t isobaricInhPa 1000 20180801 1200 0 \n", "1 ecmf u isobaricInhPa 1000 20180801 1200 0 \n", "\n", " dataType number gridType \n", "0 an 0 regular_ll \n", "1 an 0 regular_ll " ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fs.head(2)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "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", "
centreshortNametypeOfLevelleveldataDatedataTimestepRangedataTypenumbergridType
0ecmftisobaricInhPa10002018080112000an0regular_ll
1ecmfuisobaricInhPa10002018080112000an0regular_ll
\n", "
" ], "text/plain": [ " centre shortName typeOfLevel level dataDate dataTime stepRange \\\n", "0 ecmf t isobaricInhPa 1000 20180801 1200 0 \n", "1 ecmf u isobaricInhPa 1000 20180801 1200 0 \n", "\n", " dataType number gridType \n", "0 an 0 regular_ll \n", "1 an 0 regular_ll " ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fs.head(n=2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The keys can be taken from an [ecCodes GRIB namespace](https://confluence.ecmwf.int/display/UDOC/What+are+namespaces+-+ecCodes+GRIB+FAQ):" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "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", "
maxminavgsdskewkurtconst
0320.564178240.564178279.70703619.674217-0.731230-0.1690460.0
117.713120-6.286880-0.3821195.6053101.1390041.0187800.0
211.833481-16.166519-0.0712816.140457-0.217654-0.8399830.0
3304.539169232.539169272.72964619.241867-0.9981890.1357180.0
427.101624-12.8983760.3397198.1410471.5425731.8640890.0
\n", "
" ], "text/plain": [ " max min avg sd skew kurt const\n", "0 320.564178 240.564178 279.707036 19.674217 -0.731230 -0.169046 0.0\n", "1 17.713120 -6.286880 -0.382119 5.605310 1.139004 1.018780 0.0\n", "2 11.833481 -16.166519 -0.071281 6.140457 -0.217654 -0.839983 0.0\n", "3 304.539169 232.539169 272.729646 19.241867 -0.998189 0.135718 0.0\n", "4 27.101624 -12.898376 0.339719 8.141047 1.542573 1.864089 0.0" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fs.head(namespace=\"statistics\")" ] }, { "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
centreparamIdunitsnameshortName
0ecmf130KTemperaturet
1ecmf131m s**-1U component of windu
2ecmf132m s**-1V component of windv
3ecmf130KTemperaturet
4ecmf131m s**-1U component of windu
\n", "
" ], "text/plain": [ " centre paramId units name shortName\n", "0 ecmf 130 K Temperature t\n", "1 ecmf 131 m s**-1 U component of wind u\n", "2 ecmf 132 m s**-1 V component of wind v\n", "3 ecmf 130 K Temperature t\n", "4 ecmf 131 m s**-1 U component of wind u" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fs.head(namespace=\"parameter\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The list of keys can be prescribed:" ] }, { "cell_type": "code", "execution_count": 8, "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", "
bitsPerValuepackingType
04grid_simple
14grid_simple
\n", "
" ], "text/plain": [ " bitsPerValue packingType\n", "0 4 grid_simple\n", "1 4 grid_simple" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fs.head(n=2, keys=[\"bitsPerValue\", \"packingType\"])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The list of keys can also be extended:" ] }, { "cell_type": "code", "execution_count": 9, "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
centreshortNametypeOfLevelleveldataDatedataTimestepRangedataTypenumbergridTypeparamId
0ecmftisobaricInhPa10002018080112000an0regular_ll130
1ecmfuisobaricInhPa10002018080112000an0regular_ll131
2ecmfvisobaricInhPa10002018080112000an0regular_ll132
3ecmftisobaricInhPa8502018080112000an0regular_ll130
4ecmfuisobaricInhPa8502018080112000an0regular_ll131
\n", "
" ], "text/plain": [ " centre shortName typeOfLevel level dataDate dataTime stepRange \\\n", "0 ecmf t isobaricInhPa 1000 20180801 1200 0 \n", "1 ecmf u isobaricInhPa 1000 20180801 1200 0 \n", "2 ecmf v isobaricInhPa 1000 20180801 1200 0 \n", "3 ecmf t isobaricInhPa 850 20180801 1200 0 \n", "4 ecmf u isobaricInhPa 850 20180801 1200 0 \n", "\n", " dataType number gridType paramId \n", "0 an 0 regular_ll 130 \n", "1 an 0 regular_ll 131 \n", "2 an 0 regular_ll 132 \n", "3 an 0 regular_ll 130 \n", "4 an 0 regular_ll 131 " ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fs.head(extra_keys=\"paramId\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### tail()" ] }, { "cell_type": "raw", "metadata": { "editable": true, "raw_mimetype": "text/restructuredtext", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ ":py:meth:`~data.readers.grib.index.GribFieldList.tail` displays the last 5 messages by default:" ] }, { "cell_type": "code", "execution_count": 10, "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", "
centreshortNametypeOfLevelleveldataDatedataTimestepRangedataTypenumbergridType
0ecmfuisobaricInhPa10002018080112000an0regular_ll
1ecmfvisobaricInhPa10002018080112000an0regular_ll
2ecmftisobaricInhPa8502018080112000an0regular_ll
3ecmfuisobaricInhPa8502018080112000an0regular_ll
4ecmfvisobaricInhPa8502018080112000an0regular_ll
\n", "
" ], "text/plain": [ " centre shortName typeOfLevel level dataDate dataTime stepRange \\\n", "0 ecmf u isobaricInhPa 1000 20180801 1200 0 \n", "1 ecmf v isobaricInhPa 1000 20180801 1200 0 \n", "2 ecmf t isobaricInhPa 850 20180801 1200 0 \n", "3 ecmf u isobaricInhPa 850 20180801 1200 0 \n", "4 ecmf v isobaricInhPa 850 20180801 1200 0 \n", "\n", " dataType number gridType \n", "0 an 0 regular_ll \n", "1 an 0 regular_ll \n", "2 an 0 regular_ll \n", "3 an 0 regular_ll \n", "4 an 0 regular_ll " ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fs.tail(5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### ls()" ] }, { "cell_type": "raw", "metadata": { "editable": true, "raw_mimetype": "text/restructuredtext", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "By default :py:meth:`~data.readers.grib.index.GribFieldList.ls` lists all the fields:" ] }, { "cell_type": "code", "execution_count": 11, "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", "
centreshortNametypeOfLevelleveldataDatedataTimestepRangedataTypenumbergridType
0ecmftisobaricInhPa10002018080112000an0regular_ll
1ecmfuisobaricInhPa10002018080112000an0regular_ll
2ecmfvisobaricInhPa10002018080112000an0regular_ll
3ecmftisobaricInhPa8502018080112000an0regular_ll
4ecmfuisobaricInhPa8502018080112000an0regular_ll
5ecmfvisobaricInhPa8502018080112000an0regular_ll
\n", "
" ], "text/plain": [ " centre shortName typeOfLevel level dataDate dataTime stepRange \\\n", "0 ecmf t isobaricInhPa 1000 20180801 1200 0 \n", "1 ecmf u isobaricInhPa 1000 20180801 1200 0 \n", "2 ecmf v isobaricInhPa 1000 20180801 1200 0 \n", "3 ecmf t isobaricInhPa 850 20180801 1200 0 \n", "4 ecmf u isobaricInhPa 850 20180801 1200 0 \n", "5 ecmf v isobaricInhPa 850 20180801 1200 0 \n", "\n", " dataType number gridType \n", "0 an 0 regular_ll \n", "1 an 0 regular_ll \n", "2 an 0 regular_ll \n", "3 an 0 regular_ll \n", "4 an 0 regular_ll \n", "5 an 0 regular_ll " ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fs.ls()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The number of fields to list can also be specified:" ] }, { "cell_type": "code", "execution_count": 12, "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", "
centreshortNametypeOfLevelleveldataDatedataTimestepRangedataTypenumbergridType
0ecmftisobaricInhPa10002018080112000an0regular_ll
1ecmfuisobaricInhPa10002018080112000an0regular_ll
\n", "
" ], "text/plain": [ " centre shortName typeOfLevel level dataDate dataTime stepRange \\\n", "0 ecmf t isobaricInhPa 1000 20180801 1200 0 \n", "1 ecmf u isobaricInhPa 1000 20180801 1200 0 \n", "\n", " dataType number gridType \n", "0 an 0 regular_ll \n", "1 an 0 regular_ll " ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fs.ls(2)" ] }, { "cell_type": "code", "execution_count": 13, "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", "
centreshortNametypeOfLevelleveldataDatedataTimestepRangedataTypenumbergridType
0ecmfuisobaricInhPa8502018080112000an0regular_ll
1ecmfvisobaricInhPa8502018080112000an0regular_ll
\n", "
" ], "text/plain": [ " centre shortName typeOfLevel level dataDate dataTime stepRange \\\n", "0 ecmf u isobaricInhPa 850 20180801 1200 0 \n", "1 ecmf v isobaricInhPa 850 20180801 1200 0 \n", "\n", " dataType number gridType \n", "0 an 0 regular_ll \n", "1 an 0 regular_ll " ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fs.ls(-2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Using describe" ] }, { "cell_type": "raw", "metadata": { "editable": true, "raw_mimetype": "text/restructuredtext", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "We can :py:meth:`~data.readers.grib.index.GribFieldList.describe` the whole object:" ] }, { "cell_type": "code", "execution_count": 14, "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", "
  leveldatetimestepparamIdclassstreamtypeexperimentVersionNumber
shortNametypeOfLevel         
tisobaricInhPa1000,8502018080112000130odoperan0001
uisobaricInhPa1000,8502018080112000131odoperan0001
visobaricInhPa1000,8502018080112000132odoperan0001
\n" ], "text/plain": [ "" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fs.describe()" ] }, { "cell_type": "raw", "metadata": { "editable": true, "raw_mimetype": "text/restructuredtext", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "We can also :py:meth:`~data.readers.grib.index.GribFieldList.describe` a given parameter (defined by shortName or paramId):" ] }, { "cell_type": "code", "execution_count": 15, "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", "
shortNamet
typeOfLevelisobaricInhPa
level1000,850
date20180801
time1200
step0
paramId130
classod
streamoper
typean
experimentVersionNumber0001
\n" ], "text/plain": [ "" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fs.describe(\"t\")" ] }, { "cell_type": "code", "execution_count": 16, "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", " \n", "
shortNameu
typeOfLevelisobaricInhPa
level1000,850
date20180801
time1200
step0
paramId131
classod
streamoper
typean
experimentVersionNumber0001
\n" ], "text/plain": [ "" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fs.describe(131)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Accessing metadata" ] }, { "cell_type": "raw", "metadata": { "editable": true, "raw_mimetype": "text/restructuredtext", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ ":py:meth:`~data.readers.grib.index.GribFieldList.metadata` with positional arguments works for both for a :py:meth:`field ` and a :py:meth:`fieldlist `. Key type qualifiers are allowed to be used." ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "['isobaricInhPa',\n", " 'isobaricInhPa',\n", " 'isobaricInhPa',\n", " 'isobaricInhPa',\n", " 'isobaricInhPa',\n", " 'isobaricInhPa']" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fs.metadata(\"typeOfLevel\")" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['isobaricInhPa', 1000, 'ecmf', 98]" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fs[0].metadata([\"typeOfLevel\", \"level\", \"centre\", \"centre\"], astype=(None, None, str, int))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For single fields the bracket operator can also be used:" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'t'" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fs[0][\"param\"]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Namespace keys can be fetched as a dict for single fields:" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'centre': 'ecmf',\n", " 'paramId': 130,\n", " 'units': 'K',\n", " 'name': 'Temperature',\n", " 'shortName': 't'}" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fs[0].metadata(namespace=\"parameter\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Inspecting all the namespace keys for a message" ] }, { "cell_type": "raw", "metadata": { "editable": true, "raw_mimetype": "text/restructuredtext", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ ":py:meth:`~data.readers.grib.codes.GribField.dump` gives a tabbed interface to inspect the various namespaces:" ] }, { "cell_type": "code", "execution_count": 21, "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [ { "data": { "text/html": [ "
GribFieldMetadata
\n", "
\n", "
\n", "
\n", "
\n", "
\n", "\n", "\n", "\n", "
\n", "\n", "\n", "\n", "
globalDomaing
GRIBEditionNumber1
eps0
offsetSection00
section0Length8
totalLength150
editionNumber1
WMO0
productionStatusOfProcessedData0
section1Length52
wrongPadding0
table2Version128
centreecmf
centreDescriptionEuropean Centre for Medium-Range Weather Forecasts
generatingProcessIdentifier254
gridDefinition255
indicatorOfParameter130
parameterNameTemperature
parameterUnitsK
indicatorOfTypeOfLevelpl
pressureUnitshPa
typeOfLevelECMFisobaricInhPa
typeOfLevelisobaricInhPa
level1000
yearOfCentury18
month8
day1
hour12
minute0
second0
unitOfTimeRange1
P10
P20
timeRangeIndicator0
numberIncludedInAverage0
numberMissingFromAveragesOrAccumulations0
centuryOfReferenceTimeOfData21
subCentre0
paramIdECMF130
paramId130
cfNameECMFair_temperature
cfNameair_temperature
unitsECMFK
unitsK
nameECMFTemperature
nameTemperature
decimalScaleFactor0
setLocalDefinition0
optimizeScaleFactor0
dataDate20180801
year2018
dataTime1200
julianDay2458332.0
stepUnits1
stepTypeinstant
stepRange0
startStep0
endStep0
marsParam130.128
validityDate20180801
validityTime1200
validityDateTime2458331.5083333333
deleteLocalDefinition0
localUsePresent1
reservedNeedNotBePresent['']
localDefinitionNumber1
GRIBEXSection1Problem0
marsClassod
marsTypean
marsStreamoper
experimentVersionNumber0001
perturbationNumber0
numberOfForecastsInEnsemble0
padding_local1_100
grib2LocalSectionNumber1
localExtensionPadding
_xNone
section1Padding
shortNameECMFt
shortNamet
cfVarNameECMFt
cfVarNamet
ifsParam130
stepTypeForConversionunknown
md5Section13ae6b1f6f34f431c6134c40ec42f27fa
md5Product54697e1d910c88b76a8759b67e5c7a9c
paramIdForConversion0
gridDescriptionSectionPresent1
bitmapPresent0
angleSubdivisions1000
section2Length32
radius6367470
numberOfVerticalCoordinateValues0
neitherPresent255
pvlLocation255
dataRepresentationType0
gridDefinitionDescriptionLatitude/Longitude Grid
gridDefinitionTemplateNumber0
Ni12
Nj7
latitudeOfFirstGridPoint90000
latitudeOfFirstGridPointInDegrees90.0
longitudeOfFirstGridPoint0
longitudeOfFirstGridPointInDegrees0.0
resolutionAndComponentFlags128
ijDirectionIncrementGiven1
earthIsOblate0
resolutionAndComponentFlags30
resolutionAndComponentFlags40
uvRelativeToGrid0
resolutionAndComponentFlags60
resolutionAndComponentFlags70
resolutionAndComponentFlags80
latitudeOfLastGridPoint-90000
latitudeOfLastGridPointInDegrees-90.0
longitudeOfLastGridPoint330000
longitudeOfLastGridPointInDegrees330.0
iDirectionIncrement30000
jDirectionIncrement30000
isGridded1
scanningMode0
iScansNegatively0
jScansPositively0
jPointsAreConsecutive0
alternativeRowScanning0
iScansPositively1
jScansNegatively1
scanningMode40
scanningMode50
scanningMode60
scanningMode70
scanningMode80
swapScanningAlternativeRows0
jDirectionIncrementInDegrees30.0
iDirectionIncrementInDegrees30.0
numberOfDataPoints84
numberOfValues84
zeros
PVPresent0
padding_sec2_2
PLPresent0
padding_sec2_1
deletePV1
padding_sec2_3
md5Section2e09e4d6171c0ac85da1d256b2f8acf88
isSpectral0
lengthOfHeaders85
md5Headers9160fb809a9d7b1efc95163bf36e6b51
missingValue9999
tableReference0
section4Length54
halfByte8
dataFlag8
binaryScaleFactor3
referenceValue240.56417846679688
referenceValueError1.52587890625e-05
sphericalHarmonics0
complexPacking0
integerPointValues0
additionalFlagPresent0
orderOfSPD2
boustrophedonic0
hideThis0
packingTypegrid_simple
bitsPerValue4
constantFieldHalfByte8
bitMapIndicator255
numberOfCodedValues84
packingError4.000007629394531
unpackedError1.52587890625e-05
maximum320.5641784667969
minimum240.56417846679688
average279.70703560965404
standardDeviation19.67421739058438
skewness-0.7312302105044429
kurtosis-0.16904561574741717
isConstant0.0
numberOfMissing0
dataLength5
changeDecimalPrecision0
decimalPrecision0
bitsPerValueAndRepack4
setPackingTypegrid_simple
scaleValuesBy1.0
offsetValuesBy0.0
gridTyperegular_ll
getNumberOfValues84
padding_sec4_1
md5Section47ea3331d80a962b5dc99276b76451eac
section5Length4
77777777
\n", "
\n", " \n", "\n", "\n", "
\n", "\n", "\n", "\n", "
edition1
centreecmf
typeOfLevelisobaricInhPa
level1000
dataDate20180801
stepRange0
dataTypean
shortNamet
packingTypegrid_simple
gridTyperegular_ll
\n", "
\n", " \n", "\n", "\n", "
\n", "\n", "\n", "\n", "
bitmapPresent0
Ni12
Nj7
latitudeOfFirstGridPointInDegrees90.0
longitudeOfFirstGridPointInDegrees0.0
latitudeOfLastGridPointInDegrees-90.0
longitudeOfLastGridPointInDegrees330.0
iScansNegatively0
jScansPositively0
jPointsAreConsecutive0
jDirectionIncrementInDegrees30.0
iDirectionIncrementInDegrees30.0
gridTyperegular_ll
\n", "
\n", " \n", "\n", "\n", "
\n", "\n", "\n", "\n", "
domaing
levtypepl
levelist1000
date20180801
time1200
step0
paramt
classod
typean
streamoper
expver0001
\n", "
\n", " \n", "\n", "\n", "
\n", "\n", "\n", "\n", "
centreecmf
paramId130
unitsK
nameTemperature
shortNamet
\n", "
\n", " \n", "\n", "\n", "
\n", "\n", "\n", "\n", "
max320.5641784667969
min240.56417846679688
avg279.70703560965404
sd19.67421739058438
skew-0.7312302105044429
kurt-0.16904561574741717
const0.0
\n", "
\n", " \n", "\n", "\n", "
\n", "\n", "\n", "\n", "
dataDate20180801
dataTime1200
stepUnits1
stepTypeinstant
stepRange0
startStep0
endStep0
validityDate20180801
validityTime1200
\n", "
\n", " \n", "\n", "\n", "
\n", "\n", "\n", "\n", "
typeOfLevelisobaricInhPa
level1000
\n", "
\n", " \n", "
\n", "
\n", "
\n", "
\n", "
\n", " " ], "text/plain": [ "{'default': {'globalDomain': 'g',\n", " 'GRIBEditionNumber': 1,\n", " 'eps': 0,\n", " 'offsetSection0': 0,\n", " 'section0Length': 8,\n", " 'totalLength': 150,\n", " 'editionNumber': 1,\n", " 'WMO': 0,\n", " 'productionStatusOfProcessedData': 0,\n", " 'section1Length': 52,\n", " 'wrongPadding': 0,\n", " 'table2Version': 128,\n", " 'centre': 'ecmf',\n", " 'centreDescription': 'European Centre for Medium-Range Weather Forecasts',\n", " 'generatingProcessIdentifier': 254,\n", " 'gridDefinition': 255,\n", " 'indicatorOfParameter': 130,\n", " 'parameterName': 'Temperature',\n", " 'parameterUnits': 'K',\n", " 'indicatorOfTypeOfLevel': 'pl',\n", " 'pressureUnits': 'hPa',\n", " 'typeOfLevelECMF': 'isobaricInhPa',\n", " 'typeOfLevel': 'isobaricInhPa',\n", " 'level': 1000,\n", " 'yearOfCentury': 18,\n", " 'month': 8,\n", " 'day': 1,\n", " 'hour': 12,\n", " 'minute': 0,\n", " 'second': 0,\n", " 'unitOfTimeRange': 1,\n", " 'P1': 0,\n", " 'P2': 0,\n", " 'timeRangeIndicator': 0,\n", " 'numberIncludedInAverage': 0,\n", " 'numberMissingFromAveragesOrAccumulations': 0,\n", " 'centuryOfReferenceTimeOfData': 21,\n", " 'subCentre': 0,\n", " 'paramIdECMF': '130',\n", " 'paramId': 130,\n", " 'cfNameECMF': 'air_temperature',\n", " 'cfName': 'air_temperature',\n", " 'unitsECMF': 'K',\n", " 'units': 'K',\n", " 'nameECMF': 'Temperature',\n", " 'name': 'Temperature',\n", " 'decimalScaleFactor': 0,\n", " 'setLocalDefinition': 0,\n", " 'optimizeScaleFactor': 0,\n", " 'dataDate': 20180801,\n", " 'year': 2018,\n", " 'dataTime': 1200,\n", " 'julianDay': 2458332.0,\n", " 'stepUnits': 1,\n", " 'stepType': 'instant',\n", " 'stepRange': '0',\n", " 'startStep': 0,\n", " 'endStep': 0,\n", " 'marsParam': '130.128',\n", " 'validityDate': 20180801,\n", " 'validityTime': 1200,\n", " 'validityDateTime': 2458331.5083333333,\n", " 'deleteLocalDefinition': 0,\n", " 'localUsePresent': 1,\n", " 'reservedNeedNotBePresent': [''],\n", " 'localDefinitionNumber': 1,\n", " 'GRIBEXSection1Problem': 0,\n", " 'marsClass': 'od',\n", " 'marsType': 'an',\n", " 'marsStream': 'oper',\n", " 'experimentVersionNumber': '0001',\n", " 'perturbationNumber': 0,\n", " 'numberOfForecastsInEnsemble': 0,\n", " 'padding_local1_1': '00',\n", " 'grib2LocalSectionNumber': 1,\n", " 'localExtensionPadding': '',\n", " '_x': None,\n", " 'section1Padding': '',\n", " 'shortNameECMF': 't',\n", " 'shortName': 't',\n", " 'cfVarNameECMF': 't',\n", " 'cfVarName': 't',\n", " 'ifsParam': 130,\n", " 'stepTypeForConversion': 'unknown',\n", " 'md5Section1': '3ae6b1f6f34f431c6134c40ec42f27fa',\n", " 'md5Product': '54697e1d910c88b76a8759b67e5c7a9c',\n", " 'paramIdForConversion': 0,\n", " 'gridDescriptionSectionPresent': 1,\n", " 'bitmapPresent': 0,\n", " 'angleSubdivisions': 1000,\n", " 'section2Length': 32,\n", " 'radius': 6367470,\n", " 'numberOfVerticalCoordinateValues': 0,\n", " 'neitherPresent': 255,\n", " 'pvlLocation': 255,\n", " 'dataRepresentationType': 0,\n", " 'gridDefinitionDescription': 'Latitude/Longitude Grid',\n", " 'gridDefinitionTemplateNumber': 0,\n", " 'Ni': 12,\n", " 'Nj': 7,\n", " 'latitudeOfFirstGridPoint': 90000,\n", " 'latitudeOfFirstGridPointInDegrees': 90.0,\n", " 'longitudeOfFirstGridPoint': 0,\n", " 'longitudeOfFirstGridPointInDegrees': 0.0,\n", " 'resolutionAndComponentFlags': 128,\n", " 'ijDirectionIncrementGiven': 1,\n", " 'earthIsOblate': 0,\n", " 'resolutionAndComponentFlags3': 0,\n", " 'resolutionAndComponentFlags4': 0,\n", " 'uvRelativeToGrid': 0,\n", " 'resolutionAndComponentFlags6': 0,\n", " 'resolutionAndComponentFlags7': 0,\n", " 'resolutionAndComponentFlags8': 0,\n", " 'latitudeOfLastGridPoint': -90000,\n", " 'latitudeOfLastGridPointInDegrees': -90.0,\n", " 'longitudeOfLastGridPoint': 330000,\n", " 'longitudeOfLastGridPointInDegrees': 330.0,\n", " 'iDirectionIncrement': 30000,\n", " 'jDirectionIncrement': 30000,\n", " 'isGridded': 1,\n", " 'scanningMode': 0,\n", " 'iScansNegatively': 0,\n", " 'jScansPositively': 0,\n", " 'jPointsAreConsecutive': 0,\n", " 'alternativeRowScanning': 0,\n", " 'iScansPositively': 1,\n", " 'jScansNegatively': 1,\n", " 'scanningMode4': 0,\n", " 'scanningMode5': 0,\n", " 'scanningMode6': 0,\n", " 'scanningMode7': 0,\n", " 'scanningMode8': 0,\n", " 'swapScanningAlternativeRows': 0,\n", " 'jDirectionIncrementInDegrees': 30.0,\n", " 'iDirectionIncrementInDegrees': 30.0,\n", " 'numberOfDataPoints': 84,\n", " 'numberOfValues': 84,\n", " 'zeros': '',\n", " 'PVPresent': 0,\n", " 'padding_sec2_2': '',\n", " 'PLPresent': 0,\n", " 'padding_sec2_1': '',\n", " 'deletePV': '1',\n", " 'padding_sec2_3': '',\n", " 'md5Section2': 'e09e4d6171c0ac85da1d256b2f8acf88',\n", " 'isSpectral': 0,\n", " 'lengthOfHeaders': 85,\n", " 'md5Headers': '9160fb809a9d7b1efc95163bf36e6b51',\n", " 'missingValue': 9999,\n", " 'tableReference': 0,\n", " 'section4Length': 54,\n", " 'halfByte': 8,\n", " 'dataFlag': 8,\n", " 'binaryScaleFactor': 3,\n", " 'referenceValue': 240.56417846679688,\n", " 'referenceValueError': 1.52587890625e-05,\n", " 'sphericalHarmonics': 0,\n", " 'complexPacking': 0,\n", " 'integerPointValues': 0,\n", " 'additionalFlagPresent': 0,\n", " 'orderOfSPD': 2,\n", " 'boustrophedonic': 0,\n", " 'hideThis': 0,\n", " 'packingType': 'grid_simple',\n", " 'bitsPerValue': 4,\n", " 'constantFieldHalfByte': 8,\n", " 'bitMapIndicator': 255,\n", " 'numberOfCodedValues': 84,\n", " 'packingError': 4.000007629394531,\n", " 'unpackedError': 1.52587890625e-05,\n", " 'maximum': 320.5641784667969,\n", " 'minimum': 240.56417846679688,\n", " 'average': 279.70703560965404,\n", " 'standardDeviation': 19.67421739058438,\n", " 'skewness': -0.7312302105044429,\n", " 'kurtosis': -0.16904561574741717,\n", " 'isConstant': 0.0,\n", " 'numberOfMissing': 0,\n", " 'dataLength': 5,\n", " 'changeDecimalPrecision': 0,\n", " 'decimalPrecision': 0,\n", " 'bitsPerValueAndRepack': 4,\n", " 'setPackingType': 'grid_simple',\n", " 'scaleValuesBy': 1.0,\n", " 'offsetValuesBy': 0.0,\n", " 'gridType': 'regular_ll',\n", " 'getNumberOfValues': 84,\n", " 'padding_sec4_1': '',\n", " 'md5Section4': '7ea3331d80a962b5dc99276b76451eac',\n", " 'section5Length': 4,\n", " '7777': '7777'},\n", " 'ls': {'edition': 1,\n", " 'centre': 'ecmf',\n", " 'typeOfLevel': 'isobaricInhPa',\n", " 'level': 1000,\n", " 'dataDate': 20180801,\n", " 'stepRange': '0',\n", " 'dataType': 'an',\n", " 'shortName': 't',\n", " 'packingType': 'grid_simple',\n", " 'gridType': 'regular_ll'},\n", " 'geography': {'bitmapPresent': 0,\n", " 'Ni': 12,\n", " 'Nj': 7,\n", " 'latitudeOfFirstGridPointInDegrees': 90.0,\n", " 'longitudeOfFirstGridPointInDegrees': 0.0,\n", " 'latitudeOfLastGridPointInDegrees': -90.0,\n", " 'longitudeOfLastGridPointInDegrees': 330.0,\n", " 'iScansNegatively': 0,\n", " 'jScansPositively': 0,\n", " 'jPointsAreConsecutive': 0,\n", " 'jDirectionIncrementInDegrees': 30.0,\n", " 'iDirectionIncrementInDegrees': 30.0,\n", " 'gridType': 'regular_ll'},\n", " 'mars': {'domain': 'g',\n", " 'levtype': 'pl',\n", " 'levelist': 1000,\n", " 'date': 20180801,\n", " 'time': 1200,\n", " 'step': 0,\n", " 'param': 't',\n", " 'class': 'od',\n", " 'type': 'an',\n", " 'stream': 'oper',\n", " 'expver': '0001'},\n", " 'parameter': {'centre': 'ecmf',\n", " 'paramId': 130,\n", " 'units': 'K',\n", " 'name': 'Temperature',\n", " 'shortName': 't'},\n", " 'statistics': {'max': 320.5641784667969,\n", " 'min': 240.56417846679688,\n", " 'avg': 279.70703560965404,\n", " 'sd': 19.67421739058438,\n", " 'skew': -0.7312302105044429,\n", " 'kurt': -0.16904561574741717,\n", " 'const': 0.0},\n", " 'time': {'dataDate': 20180801,\n", " 'dataTime': 1200,\n", " 'stepUnits': 1,\n", " 'stepType': 'instant',\n", " 'stepRange': '0',\n", " 'startStep': 0,\n", " 'endStep': 0,\n", " 'validityDate': 20180801,\n", " 'validityTime': 1200},\n", " 'vertical': {'typeOfLevel': 'isobaricInhPa', 'level': 1000}}" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fs[0].dump()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "dev_ecc", "language": "python", "name": "dev_ecc" }, "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.10.13" } }, "nbformat": 4, "nbformat_minor": 4 }