{ "cells": [ { "cell_type": "markdown", "id": "7ec282fb-fdf9-45ba-b3f7-3d46ef212e98", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "## Retrieving data from the CDS" ] }, { "cell_type": "raw", "id": "589c568f-19c3-4a23-9e7a-37b0220bebfb", "metadata": { "editable": true, "raw_mimetype": "text/restructuredtext", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "The :ref:`cds ` data source provides access to the `Copernicus Climate Data Store (CDS) `_." ] }, { "cell_type": "code", "execution_count": 1, "id": "f24509e0-dd8c-4032-9a3c-5a963ad544d9", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [], "source": [ "import earthkit.data as ekd" ] }, { "cell_type": "markdown", "id": "9f4ce2c9-aaa3-4b76-aacb-1f597df3e338", "metadata": {}, "source": [ "### Getting GRIB data" ] }, { "cell_type": "code", "execution_count": 2, "id": "be1b53fd-4871-4ebf-ae6c-a62fd1117082", "metadata": {}, "outputs": [], "source": [ "ds = ekd.from_source(\n", " \"cds\",\n", " \"reanalysis-era5-single-levels\",\n", " request=dict(\n", " variable=[\"2t\", \"msl\"],\n", " product_type=\"reanalysis\",\n", " area=[50, -10, 40, 10], # N,W,S,E\n", " grid=[2, 2],\n", " date=\"2012-05-10\",\n", " time=\"12:00\",\n", " ),\n", ")" ] }, { "cell_type": "code", "execution_count": 3, "id": "09210614-fad6-46cf-915d-aae4a592d2d5", "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
0ecmf2tsurface02012051012000an0regular_ll
1ecmfmslsurface02012051012000an0regular_ll
\n", "
" ], "text/plain": [ " centre shortName typeOfLevel level dataDate dataTime stepRange dataType \\\n", "0 ecmf 2t surface 0 20120510 1200 0 an \n", "1 ecmf msl surface 0 20120510 1200 0 an \n", "\n", " number gridType \n", "0 0 regular_ll \n", "1 0 regular_ll " ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ds.ls()" ] }, { "cell_type": "markdown", "id": "eed0bfe1-eb81-4c26-a48b-5150f67bbb79", "metadata": {}, "source": [ "### Getting NetCDF data" ] }, { "cell_type": "code", "execution_count": 4, "id": "47f368bd-64c7-4268-bacf-7f3f1aad1b24", "metadata": {}, "outputs": [], "source": [ "ds1 = ekd.from_source(\n", " \"cds\",\n", " \"reanalysis-era5-single-levels\",\n", " request=dict(\n", " variable=[\"2t\", \"msl\"],\n", " product_type=\"reanalysis\",\n", " area=[50, -10, 40, 10], # N,W,S,E\n", " grid=[2, 2],\n", " date=\"2012-05-10\",\n", " time=\"12:00\",\n", " format=\"netcdf\",\n", " ),\n", ")" ] }, { "cell_type": "code", "execution_count": 5, "id": "71d9a8f0-5cc7-45ce-a748-44791d9d1220", "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", "
variablelevelvalid_datetimeunits
0t2mNone2012-05-10T12:00:00K
1mslNone2012-05-10T12:00:00Pa
\n", "
" ], "text/plain": [ " variable level valid_datetime units\n", "0 t2m None 2012-05-10T12:00:00 K\n", "1 msl None 2012-05-10T12:00:00 Pa" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ds1.ls()" ] }, { "cell_type": "code", "execution_count": null, "id": "5514f18a-0441-4995-8451-4f4fdd54d60f", "metadata": {}, "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 }