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
  • Trajectory Open Data Example

Trajectory Open Data Example¶

In [ ]:
Copied!
import numpy as np

n = 10
lons = np.linspace(0, 5*360, n)
lats = np.linspace(-85, 85, n)
linspace = np.stack([lats, lons], axis=1)
pts = linspace.tolist()

import earthkit.data

request = {
    "class": "ai",
    "stream" : "oper",
    "type" : "fc",
    "date" : -1,
    "time" : "0000",
    "levtype" : "sfc",
    "expver" : "0001", 
    "model": "aifs-single",
    "domain" : "g",
    "param" : "166/167/169",
    "step" : "0",
    "feature" :{ 
        "type" : "trajectory", 
        "points" : [[0,0],[10,10],[20,20], [30,30], [30, 50], [50, 10]],#pts, 
        "inflation" : 0.5, 
        "inflate" : "round",
        "axes" :["latitude", "longitude"], 
    },
}

ds = earthkit.data.from_source("polytope", "ecmwf-mars", request, stream=False, address='polytope.ecmwf.int')
import numpy as np n = 10 lons = np.linspace(0, 5*360, n) lats = np.linspace(-85, 85, n) linspace = np.stack([lats, lons], axis=1) pts = linspace.tolist() import earthkit.data request = { "class": "ai", "stream" : "oper", "type" : "fc", "date" : -1, "time" : "0000", "levtype" : "sfc", "expver" : "0001", "model": "aifs-single", "domain" : "g", "param" : "166/167/169", "step" : "0", "feature" :{ "type" : "trajectory", "points" : [[0,0],[10,10],[20,20], [30,30], [30, 50], [50, 10]],#pts, "inflation" : 0.5, "inflate" : "round", "axes" :["latitude", "longitude"], }, } ds = earthkit.data.from_source("polytope", "ecmwf-mars", request, stream=False, address='polytope.ecmwf.int')

Convert to xarray¶

In [23]:
Copied!
da = ds.to_xarray()
da
da = ds.to_xarray() da
Out[23]:
<xarray.Dataset> Size: 80kB
Dimensions:    (datetimes: 1, number: 1, steps: 1, points: 1254)
Coordinates:
  * datetimes  (datetimes) <U20 80B '2025-02-24T00:00:00Z'
  * number     (number) int64 8B 0
  * steps      (steps) int64 8B 0
  * points     (points) int64 10kB 0 1 2 3 4 5 ... 1248 1249 1250 1251 1252 1253
    x          (points) float64 10kB -0.4215 -0.4215 -0.4215 ... 50.16 50.44
    y          (points) float64 10kB 0.0 0.2812 359.7 0.0 ... 10.0 10.42 10.0
    level      (points) float64 10kB 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0 0.0
    time       (points) int64 10kB 0 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0
Data variables:
    10v        (datetimes, number, steps, points) float64 10kB 0.4052 ... 1.475
    2t         (datetimes, number, steps, points) float64 10kB 298.6 ... 277.1
    ssrd       (datetimes, number, steps, points) float64 10kB 0.0 0.0 ... 0.0
Attributes:
    class:          ai
    Forecast date:  2025-02-24T00:00:00Z
    domain:         g
    expver:         0102
    levtype:        sfc
    model:          aifs-single
    step:           0
    stream:         oper
    type:           fc
    number:         0
xarray.Dataset
    • datetimes: 1
    • number: 1
    • steps: 1
    • points: 1254
    • datetimes
      (datetimes)
      <U20
      '2025-02-24T00:00:00Z'
      array(['2025-02-24T00:00:00Z'], dtype='<U20')
    • number
      (number)
      int64
      0
      array([0])
    • steps
      (steps)
      int64
      0
      array([0])
    • points
      (points)
      int64
      0 1 2 3 4 ... 1250 1251 1252 1253
      array([   0,    1,    2, ..., 1251, 1252, 1253])
    • x
      (points)
      float64
      -0.4215 -0.4215 ... 50.16 50.44
      array([-0.42154554, -0.42154554, -0.42154554, ..., 50.1639135 ,
             50.1639135 , 50.44494373])
    • y
      (points)
      float64
      0.0 0.2812 359.7 ... 10.42 10.0
      array([0.00000000e+00, 2.81250000e-01, 3.59718750e+02, ...,
             1.00000000e+01, 1.04166667e+01, 1.00000000e+01])
    • level
      (points)
      float64
      0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0
      array([0., 0., 0., ..., 0., 0., 0.])
    • time
      (points)
      int64
      0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0
      array([0, 0, 0, ..., 0, 0, 0])
    • 10v
      (datetimes, number, steps, points)
      float64
      0.4052 0.3974 1.742 ... 2.058 1.475
      type :
      Parameter
      units :
      m s**-1
      long_name :
      10v
      array([[[[0.40518188, 0.39736938, 1.74209595, ..., 0.78311157,
                2.05752563, 1.47549438]]]])
    • 2t
      (datetimes, number, steps, points)
      float64
      298.6 299.0 298.8 ... 274.9 277.1
      type :
      Parameter
      units :
      K
      long_name :
      2t
      array([[[[298.63464355, 298.96276855, 298.8494873 , ..., 273.94909668,
                274.91003418, 277.08972168]]]])
    • ssrd
      (datetimes, number, steps, points)
      float64
      0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0
      type :
      Parameter
      units :
      J m**-2
      long_name :
      ssrd
      array([[[[0., 0., 0., ..., 0., 0., 0.]]]])
    • datetimes
      PandasIndex
      PandasIndex(Index(['2025-02-24T00:00:00Z'], dtype='object', name='datetimes'))
    • number
      PandasIndex
      PandasIndex(Index([0], dtype='int64', name='number'))
    • steps
      PandasIndex
      PandasIndex(Index([0], dtype='int64', name='steps'))
    • points
      PandasIndex
      PandasIndex(Index([   0,    1,    2,    3,    4,    5,    6,    7,    8,    9,
             ...
             1244, 1245, 1246, 1247, 1248, 1249, 1250, 1251, 1252, 1253],
            dtype='int64', name='points', length=1254))
  • class :
    ai
    Forecast date :
    2025-02-24T00:00:00Z
    domain :
    g
    expver :
    0102
    levtype :
    sfc
    model :
    aifs-single
    step :
    0
    stream :
    oper
    type :
    fc
    number :
    0

Visualise¶

In [24]:
Copied!
import earthkit.plots

chart = earthkit.plots.Map()
chart.point_cloud(da['2t'], x="y", y="x")
chart.coastlines()
chart.borders()
chart.title("{variable_name}")
chart.legend()
chart.show()
import earthkit.plots chart = earthkit.plots.Map() chart.point_cloud(da['2t'], x="y", y="x") chart.coastlines() chart.borders() chart.title("{variable_name}") chart.legend() chart.show()
No description has been provided for this image
In [ ]:
Copied!


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