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 Example

Trajectory Example¶

In [ ]:
Copied!
import numpy as np

n = 1000
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": "od",
    "stream" : "enfo",
    "type" : "pf",
    "date" : -1,
    "time" : 0,
    "levtype" : "sfc",
    "expver" : 1,
    "domain" : "g",
    "param" : [ 167 ],
    "number" : [ 1 ],
    "step": [ 0 ],
    "feature" :{ 
        "type" : "trajectory", 
        "points" : pts, 
        "inflation" : 0.1, 
        "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 = 1000 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": "od", "stream" : "enfo", "type" : "pf", "date" : -1, "time" : 0, "levtype" : "sfc", "expver" : 1, "domain" : "g", "param" : [ 167 ], "number" : [ 1 ], "step": [ 0 ], "feature" :{ "type" : "trajectory", "points" : pts, "inflation" : 0.1, "inflate" : "round", "axes" :["latitude", "longitude"], }, } ds = earthkit.data.from_source("polytope", "ecmwf-mars", request, stream=False, address='polytope.ecmwf.int')

Convert to xarray¶

In [5]:
Copied!
da = ds.to_xarray()
da
da = ds.to_xarray() da
Out[5]:
<xarray.Dataset> Size: 847kB
Dimensions:    (datetimes: 1, number: 1, steps: 1, points: 21170)
Coordinates:
  * datetimes  (datetimes) <U20 80B '2024-11-17T00:00:00Z'
  * number     (number) int64 8B 1
  * steps      (steps) int64 8B 0
  * points     (points) int64 169kB 0 1 2 3 4 ... 21165 21166 21167 21168 21169
    x          (points) float64 169kB -84.96 -84.89 -84.82 ... 84.96 85.03 85.1
    y          (points) float64 169kB 0.0 1.169 1.154 2.278 ... 358.8 0.0 0.0
    t          (points) int64 169kB 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0
Data variables:
    2t         (datetimes, number, steps, points) float64 169kB 237.9 ... 255.2
Attributes:
    class:          od
    Forecast date:  2024-11-17T00:00:00Z
    domain:         g
    expver:         0001
    levtype:        sfc
    number:         1
    step:           0
    stream:         enfo
    type:           pf
xarray.Dataset
    • datetimes: 1
    • number: 1
    • steps: 1
    • points: 21170
    • datetimes
      (datetimes)
      <U20
      '2024-11-17T00:00:00Z'
      array(['2024-11-17T00:00:00Z'], dtype='<U20')
    • number
      (number)
      int64
      1
      array([1])
    • steps
      (steps)
      int64
      0
      array([0])
    • points
      (points)
      int64
      0 1 2 3 ... 21166 21167 21168 21169
      array([    0,     1,     2, ..., 21167, 21168, 21169])
    • x
      (points)
      float64
      -84.96 -84.89 -84.82 ... 85.03 85.1
      array([-84.95605089, -84.88575229, -84.81545369, ...,  84.95605089,
              85.02634949,  85.09664807])
    • y
      (points)
      float64
      0.0 1.169 1.154 ... 358.8 0.0 0.0
      array([  0.        ,   1.16883117,   1.15384615, ..., 358.81578947,
               0.        ,   0.        ])
    • t
      (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])
    • 2t
      (datetimes, number, steps, points)
      float64
      237.9 237.4 237.3 ... 255.4 255.2
      type :
      Parameter
      units :
      K
      long_name :
      2t
      array([[[[237.862854  , 237.44683838, 237.27496338, ..., 255.64996338,
                255.38238525, 255.2300415 ]]]])
    • datetimes
      PandasIndex
      PandasIndex(Index(['2024-11-17T00:00:00Z'], dtype='object', name='datetimes'))
    • number
      PandasIndex
      PandasIndex(Index([1], 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,
             ...
             21160, 21161, 21162, 21163, 21164, 21165, 21166, 21167, 21168, 21169],
            dtype='int64', name='points', length=21170))
  • class :
    od
    Forecast date :
    2024-11-17T00:00:00Z
    domain :
    g
    expver :
    0001
    levtype :
    sfc
    number :
    1
    step :
    0
    stream :
    enfo
    type :
    pf

Visualise¶

In [6]:
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.