CoverageJSON: retrieving vertical profiles with Polytope

The polytope source provides access to the Polytope web services.

The following example retrieves vertical profiles on pressure levels using polytope.

[1]:
import earthkit.data as ekd

location = [38.9, -9.1] # lat, lon

request = {
    "class": "od",
    "stream": "enfo",
    "type": "pf",
    "date": -1,
    "time": "0000",
    "levtype": "pl",
    "expver": 1,
    "domain": "g",
    "param": "203/133",
    "number": "1",
    "step": "0",
    "levelist": "1/to/1000",
    "feature": {
        "type": "verticalprofile",
        "points": [location],
    },
}

ds = ekd.from_source("polytope", "ecmwf-mars", request=request, stream=False, address='polytope.ecmwf.int')

The data is retrieved as CoverageJSON, which we can convert to Xarray for further processing (the conversion uses the covjsonkit package under the hood).

[2]:
ds.to_xarray()
[2]:
<xarray.Dataset> Size: 640B
Dimensions:    (latitude: 1, longitude: 1, number: 1, datetime: 1, time: 1,
                levelist: 22)
Coordinates:
  * latitude   (latitude) float64 8B 38.91
  * longitude  (longitude) float64 8B 350.9
  * number     (number) int64 8B 1
  * datetime   (datetime) <U20 80B '2025-10-21T00:00:00Z'
  * time       (time) int64 8B 0
  * levelist   (levelist) int64 176B 1 2 3 5 7 10 ... 500 600 700 850 925 1000
Data variables:
    q          (latitude, longitude, number, datetime, time, levelist) float64 176B ...
    o3         (latitude, longitude, number, datetime, time, levelist) float64 176B ...
Attributes:
    class:          od
    Forecast date:  2025-10-21T00:00:00Z
    domain:         g
    expver:         0001
    levelist:       1
    levtype:        pl
    number:         1
    stream:         enfo
    type:           pf
[ ]: