{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Polytope time series" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "First, we retrieve ENS time series data using polytope." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2024-12-18 09:11:07 - INFO - Key read from /Users/cgr/.polytopeapirc\n", "2024-12-18 09:11:07 - INFO - Sending request...\n", "{'request': 'class: od\\n'\n", " 'date: -1\\n'\n", " 'domain: g\\n'\n", " 'expver: 1\\n'\n", " 'feature:\\n'\n", " ' axes: step\\n'\n", " ' points:\\n'\n", " ' - - 38.78655345978706\\n'\n", " ' - -9.109280931080349\\n'\n", " ' type: timeseries\\n'\n", " 'levtype: sfc\\n'\n", " 'number: 1/to/50\\n'\n", " 'param: 164/167/169\\n'\n", " 'step: 0/to/360\\n'\n", " 'stream: enfo\\n'\n", " \"time: '0000'\\n\"\n", " 'type: pf\\n',\n", " 'verb': 'retrieve'}\n", "2024-12-18 09:11:07 - INFO - Polytope user key found in session cache for user cgr\n", "2024-12-18 09:11:07 - INFO - Request accepted. Please poll ./96d99675-364f-45cb-b3f4-e834db746625 for status\n", "2024-12-18 09:11:07 - INFO - Polytope user key found in session cache for user cgr\n", "2024-12-18 09:11:07 - INFO - Checking request status (./96d99675-364f-45cb-b3f4-e834db746625)...\n", "2024-12-18 09:11:07 - INFO - The current status of the request is 'processing'\n", "2024-12-18 09:11:19 - INFO - The current status of the request is 'processed'\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "", "version_major": 2, "version_minor": 0 }, "text/plain": [ "96d99675-364f-45cb-b3f4-e834db746625.covjson: 0%| | 0.00/520k [00:00, ?B/s]" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import earthkit.data\n", "\n", "# lat, lon\n", "location = [38.78655345978706, -9.109280931080349]\n", "\n", "request = {\n", " \"class\": \"od\",\n", " \"stream\" : \"enfo\",\n", " \"type\" : \"pf\",\n", " \"date\" : -1,\n", " \"time\" : \"0000\",\n", " \"levtype\" : \"sfc\",\n", " \"expver\" : 1, \n", " \"domain\" : \"g\",\n", " \"param\" : \"164/167/169\",\n", " \"number\" : \"1/to/50\",\n", " \"step\": \"0/to/360\",\n", " \"feature\" : {\n", " \"type\" : \"timeseries\",\n", " \"points\": [location],\n", " \"axes\": \"step\",\n", " },\n", "}\n", "\n", "ds = earthkit.data.from_source(\"polytope\", \"ecmwf-mars\", request, stream=False, address='polytope.ecmwf.int')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The retrieved CoverageJSON data can be converted Xarray." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.Dataset> Size: 176kB\n",
"Dimensions: (x: 1, y: 1, z: 1, number: 50, datetime: 1, t: 145)\n",
"Coordinates:\n",
" * x (x) float64 8B 38.77\n",
" * y (y) float64 8B 350.9\n",
" * z (z) int64 8B 0\n",
" * number (number) int64 400B 1 2 3 4 5 6 7 8 9 ... 43 44 45 46 47 48 49 50\n",
" * datetime (datetime) <U20 80B '2024-12-17T00:00:00Z'\n",
" * t (t) datetime64[ns] 1kB 2024-12-17 ... 2025-01-01\n",
"Data variables:\n",
" tcc (x, y, z, number, datetime, t) float64 58kB 1.0 0.9854 ... 0.999\n",
" 2t (x, y, z, number, datetime, t) float64 58kB 286.7 285.8 ... 286.3\n",
" ssrd (x, y, z, number, datetime, t) float64 58kB 0.0 0.0 ... 1.304e+08\n",
"Attributes:\n",
" class: od\n",
" Forecast date: 2024-12-17T00:00:00Z\n",
" domain: g\n",
" expver: 0001\n",
" levtype: sfc\n",
" number: 1\n",
" stream: enfo\n",
" type: pf