Polytope
  • Home
  • Installation
  • Quick Start
  • Data Portfolio

Full Fields

  • Full Fields

Features

  • Overview
  • Time Series
  • Vertical Profile
  • Polygon
  • Bounding Box
  • Trajectory
  • Circle
  • Position

Examples

  • Examples
Polytope
  • Position example

Position Example¶

This example demonstrates how to extract a position for a single point.

In [ ]:
Copied!
import earthkit.data

LOCATION = [[-9.11, 38.79]]

request = {
    "class": "od",
    "stream" : "enfo",
    "type" : "pf",
    "date" : -1,  # Note: date must be within the last two days 
    "time" : "0000",
    "levtype" : "sfc",
    "expver" : "0001", 
    "domain" : "g",
    "param" : "164/167/169",
    "number" : "1",
    "step" : "0",
    "feature" : {
        "type" : "position",
        "points": LOCATION,
        "axes" : ["latitude", "longitude"]
    },
}

ds = earthkit.data.from_source(
    "polytope",
    "ecmwf-mars",
    request,
    stream=False,
    address='polytope.ecmwf.int',
)
import earthkit.data LOCATION = [[-9.11, 38.79]] request = { "class": "od", "stream" : "enfo", "type" : "pf", "date" : -1, # Note: date must be within the last two days "time" : "0000", "levtype" : "sfc", "expver" : "0001", "domain" : "g", "param" : "164/167/169", "number" : "1", "step" : "0", "feature" : { "type" : "position", "points": LOCATION, "axes" : ["latitude", "longitude"] }, } ds = earthkit.data.from_source( "polytope", "ecmwf-mars", request, stream=False, address='polytope.ecmwf.int', )

Convert to Xarray¶

In [4]:
Copied!
da = ds.to_xarray()
print(da)
da = ds.to_xarray() print(da)
<xarray.Dataset> Size: 144B
Dimensions:    (latitude: 1, longitude: 1, levelist: 1, number: 1, datetime: 1,
                t: 1)
Coordinates:
  * latitude   (latitude) float64 8B -9.104
  * longitude  (longitude) float64 8B 38.81
  * levelist   (levelist) int64 8B 0
  * number     (number) int64 8B 1
  * datetime   (datetime) <U20 80B '2025-12-01T00:00:00Z'
  * t          (t) datetime64[ns] 8B 2025-12-01
Data variables:
    tcc        (latitude, longitude, levelist, number, datetime, t) float64 8B ...
    2t         (latitude, longitude, levelist, number, datetime, t) float64 8B ...
    ssrd       (latitude, longitude, levelist, number, datetime, t) float64 8B ...
Attributes:
    class:          od
    Forecast date:  2025-12-01T00:00:00Z
    domain:         g
    expver:         0001
    levtype:        sfc
    number:         1
    stream:         enfo
    type:           pf
In [ ]:
Copied!


Built with MkDocs using a theme provided by Read the Docs.