{ "cells": [ { "cell_type": "markdown", "id": "3599bcd8-a5ee-4911-96c9-976b849138fb", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "## Retieving data from WEkEO" ] }, { "cell_type": "raw", "id": "e0756690-e59f-47b4-a5a6-daf7e30b92af", "metadata": { "editable": true, "raw_mimetype": "text/restructuredtext", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "The :ref:`wekeo ` and :ref:`wekeocds ` sources provide access to `WEkEO `_." ] }, { "cell_type": "markdown", "id": "e32b8f13-137a-436e-8523-fcee759dfb02", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "#### Using the WEkEO grammar" ] }, { "cell_type": "raw", "id": "e6a6d76d-6563-4e6b-8aa6-e4f5a6b7b3d5", "metadata": { "editable": true, "raw_mimetype": "text/restructuredtext", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "When we want access data using the WEkEO grammar (see the `hda `_ documentation) we need to use the :ref:`wekeo ` source. The following example retrieves Normalized Difference Vegetation Index data derived from EO satellite imagery in NetCDF format:" ] }, { "cell_type": "code", "execution_count": 1, "id": "15d5599f-1242-4238-8d5d-e459694bc296", "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: 23GB\n",
       "Dimensions:      (time: 1, lat: 47040, lon: 120960)\n",
       "Coordinates:\n",
       "  * lat          (lat) float64 376kB 80.0 80.0 79.99 ... -59.99 -59.99 -60.0\n",
       "  * lon          (lon) float64 968kB -180.0 -180.0 -180.0 ... 180.0 180.0 180.0\n",
       "  * time         (time) datetime64[ns] 8B 2019-01-01\n",
       "Data variables:\n",
       "    crs          |S1 1B ...\n",
       "    day_of_burn  (time, lat, lon) float32 23GB dask.array<chunksize=(1, 888, 2283), meta=np.ndarray>\n",
       "Attributes: (12/19)\n",
       "    Conventions:          CF-1.6\n",
       "    processing_level:     L3\n",
       "    identifier:           urn:cgls:global:ba300_v3_333m:BA300-NTC_20190101000...\n",
       "    institution:          VITO NV\n",
       "    time_coverage_end:    2019-01-31T23:59:59Z\n",
       "    source:               Derived from EO satellite imagery\n",
       "    ...                   ...\n",
       "    time_coverage_start:  2019-01-01T00:00:00Z\n",
       "    platform:             Sentinel-3\n",
       "    title:                monthly Burnt Area 333M: GLOBE 2019-01-01T00:00:00Z\n",
       "    archive_facility:     VITO\n",
       "    parent_identifier:    urn:cgls:global:ba300_v3_333m\n",
       "    history:              2023-09-04: Processing line BA
" ], "text/plain": [ " Size: 23GB\n", "Dimensions: (time: 1, lat: 47040, lon: 120960)\n", "Coordinates:\n", " * lat (lat) float64 376kB 80.0 80.0 79.99 ... -59.99 -59.99 -60.0\n", " * lon (lon) float64 968kB -180.0 -180.0 -180.0 ... 180.0 180.0 180.0\n", " * time (time) datetime64[ns] 8B 2019-01-01\n", "Data variables:\n", " crs |S1 1B ...\n", " day_of_burn (time, lat, lon) float32 23GB dask.array\n", "Attributes: (12/19)\n", " Conventions: CF-1.6\n", " processing_level: L3\n", " identifier: urn:cgls:global:ba300_v3_333m:BA300-NTC_20190101000...\n", " institution: VITO NV\n", " time_coverage_end: 2019-01-31T23:59:59Z\n", " source: Derived from EO satellite imagery\n", " ... ...\n", " time_coverage_start: 2019-01-01T00:00:00Z\n", " platform: Sentinel-3\n", " title: monthly Burnt Area 333M: GLOBE 2019-01-01T00:00:00Z\n", " archive_facility: VITO\n", " parent_identifier: urn:cgls:global:ba300_v3_333m\n", " history: 2023-09-04: Processing line BA" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import earthkit.data as ekd\n", "\n", "ds = ekd.from_source(\n", " \"wekeo\",\n", " \"EO:CLMS:DAT:CLMS_GLOBAL_BA_300M_V3_MONTHLY_NETCDF\",\n", " request={\n", " \"dataset_id\": \"EO:CLMS:DAT:CLMS_GLOBAL_BA_300M_V3_MONTHLY_NETCDF\",\n", " \"startdate\": \"2019-01-01T00:00:00.000Z\",\n", " \"enddate\": \"2019-01-01T23:59:59.999Z\",\n", " }\n", " )\n", "\n", "ds.to_xarray()" ] }, { "cell_type": "markdown", "id": "23cd1784-1478-4ac0-8ad8-cf6d8d5358f8", "metadata": {}, "source": [ "#### Using the CDSAPI grammar" ] }, { "cell_type": "raw", "id": "4673ee18-c3be-49dd-b704-2f5bacb56b42", "metadata": { "editable": true, "raw_mimetype": "text/restructuredtext", "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "We can use the :ref:`wekeocds ` source to access `Copernicus Climate Data Store (CDS) `_ datasets served on `WEkEO `_ using the `cdsapi `_ standard grammar." ] }, { "cell_type": "markdown", "id": "777ec204-fbff-41f3-8ae2-3f60c6acb39f", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "The following example retrieves ERA5 surface data in GRIB format:" ] }, { "cell_type": "code", "execution_count": 2, "id": "eff2587c-eb03-4de5-b3c4-f894d31027be", "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
0ecmf2tsurface02012120112000an0regular_ll
1ecmfmslsurface02012120112000an0regular_ll
\n", "
" ], "text/plain": [ " centre shortName typeOfLevel level dataDate dataTime stepRange dataType \\\n", "0 ecmf 2t surface 0 20121201 1200 0 an \n", "1 ecmf msl surface 0 20121201 1200 0 an \n", "\n", " number gridType \n", "0 0 regular_ll \n", "1 0 regular_ll " ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ds = ekd.from_source(\n", " \"wekeocds\",\n", " \"EO:ECMWF:DAT:REANALYSIS_ERA5_SINGLE_LEVELS_MONTHLY_MEANS\",\n", " request=dict(\n", " variable=[\"2m_temperature\", \"mean_sea_level_pressure\"],\n", " product_type=[\"monthly_averaged_reanalysis_by_hour_of_day\"],\n", " year=\"2012\",\n", " month=\"12\",\n", " time=\"12:00\",\n", " data_format=\"grib\",\n", " download_format=\"zip\",\n", " ),\n", ")\n", "\n", "ds.ls()" ] }, { "cell_type": "code", "execution_count": null, "id": "fffe1e96-03da-434d-a3cd-fa51ed847ac6", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "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 }