{ "cells": [ { "cell_type": "markdown", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "## Using GRIB data" ] }, { "attachments": {}, "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": [ "ds = ekd.from_source(\"file\", \"test6.grib\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "No GRIB data is actually loaded at this point." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Iteration" ] }, { "cell_type": "raw", "metadata": { "editable": true, "raw_mimetype": "text/restructuredtext", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "A :ref:`GRIB ` data object is represented by a :py:class:`~data.readers.grib.index.GribFieldList` consisting of :py:class:`~data.readers.grib.codes.GribField`\\s. When used in iteration these are automatically created and released when going out of scope. As a result, during the iteration only one GRIB message at a time is kept in memory:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "GribField(t,1000,20180801,1200,0,0)\n", "GribField(u,1000,20180801,1200,0,0)\n", "GribField(v,1000,20180801,1200,0,0)\n", "GribField(t,850,20180801,1200,0,0)\n", "GribField(u,850,20180801,1200,0,0)\n", "GribField(v,850,20180801,1200,0,0)\n" ] } ], "source": [ "for f in ds:\n", " print(f)" ] }, { "cell_type": "markdown", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "### Inspecting the contents" ] }, { "cell_type": "raw", "metadata": { "editable": true, "raw_mimetype": "text/restructuredtext", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "We can use :py:meth:`~data.readers.grib.index.GribFieldList.ls` or :py:meth:`~data.readers.grib.index.GribFieldList.describe`." ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "editable": true, "raw_mimetype": "text/restructuredtext", "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "6" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(ds)" ] }, { "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \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": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ds.ls()" ] }, { "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", " \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": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ds.describe()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Slicing" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Standard Python slicing is available. It does not involve any loading/copying of GRIB data. " ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "GribField(u,1000,20180801,1200,0,0)" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "g = ds[1]\n", "g" ] }, { "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", " \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
\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", "\n", " dataType number gridType \n", "0 an 0 regular_ll \n", "1 an 0 regular_ll " ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "g = ds[1:3]\n", "g.ls()" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "GribField(v,850,20180801,1200,0,0)" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "g = ds[-1]\n", "g" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Getting data values" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Using values" ] }, { "cell_type": "raw", "metadata": { "editable": true, "raw_mimetype": "text/restructuredtext", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "The :py:attr:`~data.readers.grib.codes.GribField.values` property always returns a flat array per field:" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "(84,)" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "v = ds[0].values\n", "v.shape" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([272.56417847, 272.56417847, 272.56417847, 272.56417847])" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "v[0:4]" ] }, { "cell_type": "raw", "metadata": { "editable": true, "raw_mimetype": "text/restructuredtext", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "When called on the whole fieldlist :py:attr:`~data.readers.grib.index.GribFieldList.values` returns a 2D array:" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "(6, 84)" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "v = ds.values\n", "v.shape" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Using to_numpy()" ] }, { "cell_type": "raw", "metadata": { "editable": true, "raw_mimetype": "text/restructuredtext", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "With :py:meth:`~data.readers.grib.codes.GribField.to_numpy` the field shape is set on the array: " ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(7, 12)\n", "(7, 12)\n" ] } ], "source": [ "v = ds[0].to_numpy()\n", "print(v.shape)\n", "print(ds[0].shape)" ] }, { "cell_type": "raw", "metadata": { "editable": true, "raw_mimetype": "text/restructuredtext", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ ":py:meth:`~data.readers.grib.index.GribFieldList.to_numpy` behaves in the same way when called on a fieldlist:" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "(6, 7, 12)" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "v = ds.to_numpy()\n", "v.shape" ] }, { "cell_type": "markdown", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "### Metadata" ] }, { "cell_type": "raw", "metadata": { "editable": true, "raw_mimetype": "text/restructuredtext", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ ":py:meth:`~data.readers.grib.codes.GribField.metadata` access works both on individual fields and slices:" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'isobaricInhPa'" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ds[0].metadata(\"typeOfLevel\")" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[[1000, 130], [1000, 131]]" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ds[0:2].metadata([\"level\", \"paramId\"])" ] }, { "cell_type": "raw", "metadata": { "editable": true, "raw_mimetype": "text/restructuredtext", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "We can also call :py:meth:`~data.readers.grib.index.GribFieldList.metadata` on a fieldlist:" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "[1000, 1000, 1000, 850, 850, 850]" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ds.metadata(\"level\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Key qualifiers can be used to prescribe the required metadata type:" ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "['ecmf', 98, 'ecmf']" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ds[0].metadata([\"centre\", \"centre\", \"centre\"], astype=(None, int, str))" ] }, { "cell_type": "raw", "metadata": { "editable": true, "raw_mimetype": "text/restructuredtext", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "For each filed we can get the metadata as an :py:class:`object `:" ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "md = ds[0].metadata()\n", "md" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1000" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "md[\"level\"]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Selection" ] }, { "cell_type": "raw", "metadata": { "editable": true, "raw_mimetype": "text/restructuredtext", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ ":py:meth:`~data.readers.grib.index.GribFieldList.sel` offers metadata-based selection and always creates a \"view\", so no copying of GRIB data is involved." ] }, { "cell_type": "code", "execution_count": 21, "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", "
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": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "g = ds.sel(shortName=[\"u\", \"v\"], level=850)\n", "g.ls()" ] }, { "cell_type": "code", "execution_count": 22, "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
1ecmftisobaricInhPa8502018080112000an0regular_ll
\n", "
" ], "text/plain": [ " centre shortName typeOfLevel level dataDate dataTime stepRange \\\n", "0 ecmf t isobaricInhPa 1000 20180801 1200 0 \n", "1 ecmf t isobaricInhPa 850 20180801 1200 0 \n", "\n", " dataType number gridType \n", "0 an 0 regular_ll \n", "1 an 0 regular_ll " ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "g = ds.sel(param=\"t\")\n", "g.ls()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Xarray" ] }, { "cell_type": "raw", "metadata": { "editable": true, "raw_mimetype": "text/restructuredtext", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "Xarray conversion with :py:meth:`~data.readers.grib.index.GribFieldList.to_xarray` does not involve disk writing. Under the hood it uses cfgrib." ] }, { "cell_type": "code", "execution_count": 23, "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", "
<xarray.Dataset> Size: 2kB\n",
       "Dimensions:        (number: 1, time: 1, step: 1, isobaricInhPa: 2, latitude: 7,\n",
       "                    longitude: 12)\n",
       "Coordinates:\n",
       "  * number         (number) int64 8B 0\n",
       "  * time           (time) datetime64[ns] 8B 2018-08-01T12:00:00\n",
       "  * step           (step) timedelta64[ns] 8B 00:00:00\n",
       "  * isobaricInhPa  (isobaricInhPa) float64 16B 1e+03 850.0\n",
       "  * latitude       (latitude) float64 56B 90.0 60.0 30.0 0.0 -30.0 -60.0 -90.0\n",
       "  * longitude      (longitude) float64 96B 0.0 30.0 60.0 ... 270.0 300.0 330.0\n",
       "    valid_time     (time, step) datetime64[ns] 8B ...\n",
       "Data variables:\n",
       "    t              (number, time, step, isobaricInhPa, latitude, longitude) float32 672B ...\n",
       "    u              (number, time, step, isobaricInhPa, latitude, longitude) float32 672B ...\n",
       "    v              (number, time, step, isobaricInhPa, latitude, longitude) float32 672B ...\n",
       "Attributes:\n",
       "    GRIB_edition:            1\n",
       "    GRIB_centre:             ecmf\n",
       "    GRIB_centreDescription:  European Centre for Medium-Range Weather Forecasts\n",
       "    GRIB_subCentre:          0\n",
       "    Conventions:             CF-1.7\n",
       "    institution:             European Centre for Medium-Range Weather Forecasts\n",
       "    history:                 2025-03-10T15:18 GRIB to CDM+CF via cfgrib-0.9.1...
" ], "text/plain": [ " Size: 2kB\n", "Dimensions: (number: 1, time: 1, step: 1, isobaricInhPa: 2, latitude: 7,\n", " longitude: 12)\n", "Coordinates:\n", " * number (number) int64 8B 0\n", " * time (time) datetime64[ns] 8B 2018-08-01T12:00:00\n", " * step (step) timedelta64[ns] 8B 00:00:00\n", " * isobaricInhPa (isobaricInhPa) float64 16B 1e+03 850.0\n", " * latitude (latitude) float64 56B 90.0 60.0 30.0 0.0 -30.0 -60.0 -90.0\n", " * longitude (longitude) float64 96B 0.0 30.0 60.0 ... 270.0 300.0 330.0\n", " valid_time (time, step) datetime64[ns] 8B ...\n", "Data variables:\n", " t (number, time, step, isobaricInhPa, latitude, longitude) float32 672B ...\n", " u (number, time, step, isobaricInhPa, latitude, longitude) float32 672B ...\n", " v (number, time, step, isobaricInhPa, latitude, longitude) float32 672B ...\n", "Attributes:\n", " GRIB_edition: 1\n", " GRIB_centre: ecmf\n", " GRIB_centreDescription: European Centre for Medium-Range Weather Forecasts\n", " GRIB_subCentre: 0\n", " Conventions: CF-1.7\n", " institution: European Centre for Medium-Range Weather Forecasts\n", " history: 2025-03-10T15:18 GRIB to CDM+CF via cfgrib-0.9.1..." ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "xds = ds.to_xarray(engine=\"cfgrib\")\n", "xds" ] }, { "cell_type": "raw", "metadata": { "editable": true, "raw_mimetype": "text/restructuredtext", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "We can pass all the kwargs arguments cfgrib accepts. On top of that earthkit-data provides the :py:meth:`ignore_keys ` option to omit keys from the default set of keys used by cfgrib:" ] }, { "cell_type": "code", "execution_count": 24, "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", "
<xarray.Dataset> Size: 2kB\n",
       "Dimensions:        (time: 1, step: 1, isobaricInhPa: 2, latitude: 7,\n",
       "                    longitude: 12)\n",
       "Coordinates:\n",
       "  * time           (time) datetime64[ns] 8B 2018-08-01T12:00:00\n",
       "  * step           (step) timedelta64[ns] 8B 00:00:00\n",
       "  * isobaricInhPa  (isobaricInhPa) float64 16B 1e+03 850.0\n",
       "  * latitude       (latitude) float64 56B 90.0 60.0 30.0 0.0 -30.0 -60.0 -90.0\n",
       "  * longitude      (longitude) float64 96B 0.0 30.0 60.0 ... 270.0 300.0 330.0\n",
       "    valid_time     (time, step) datetime64[ns] 8B ...\n",
       "Data variables:\n",
       "    t              (time, step, isobaricInhPa, latitude, longitude) float32 672B ...\n",
       "    u              (time, step, isobaricInhPa, latitude, longitude) float32 672B ...\n",
       "    v              (time, step, isobaricInhPa, latitude, longitude) float32 672B ...\n",
       "Attributes:\n",
       "    GRIB_edition:            1\n",
       "    GRIB_centre:             ecmf\n",
       "    GRIB_centreDescription:  European Centre for Medium-Range Weather Forecasts\n",
       "    GRIB_subCentre:          0\n",
       "    Conventions:             CF-1.7\n",
       "    institution:             European Centre for Medium-Range Weather Forecasts\n",
       "    history:                 2025-03-10T15:18 GRIB to CDM+CF via cfgrib-0.9.1...
" ], "text/plain": [ " Size: 2kB\n", "Dimensions: (time: 1, step: 1, isobaricInhPa: 2, latitude: 7,\n", " longitude: 12)\n", "Coordinates:\n", " * time (time) datetime64[ns] 8B 2018-08-01T12:00:00\n", " * step (step) timedelta64[ns] 8B 00:00:00\n", " * isobaricInhPa (isobaricInhPa) float64 16B 1e+03 850.0\n", " * latitude (latitude) float64 56B 90.0 60.0 30.0 0.0 -30.0 -60.0 -90.0\n", " * longitude (longitude) float64 96B 0.0 30.0 60.0 ... 270.0 300.0 330.0\n", " valid_time (time, step) datetime64[ns] 8B ...\n", "Data variables:\n", " t (time, step, isobaricInhPa, latitude, longitude) float32 672B ...\n", " u (time, step, isobaricInhPa, latitude, longitude) float32 672B ...\n", " v (time, step, isobaricInhPa, latitude, longitude) float32 672B ...\n", "Attributes:\n", " GRIB_edition: 1\n", " GRIB_centre: ecmf\n", " GRIB_centreDescription: European Centre for Medium-Range Weather Forecasts\n", " GRIB_subCentre: 0\n", " Conventions: CF-1.7\n", " institution: European Centre for Medium-Range Weather Forecasts\n", " history: 2025-03-10T15:18 GRIB to CDM+CF via cfgrib-0.9.1..." ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "xds = ds.to_xarray(engine=\"cfgrib\", xarray_open_dataset_kwargs={\"backend_kwargs\": {\"ignore_keys\": [\"number\"]}})\n", "xds" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "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 }