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
  • Bounding Box Example

Bounding Box Example¶

In [ ]:
Copied!
import earthkit.data

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/166/167/169",
    "number" : "1",
    "step": "0",
    "feature" : {
        "type" : "boundingbox",
        "points" : [[53.55, 2.76], [50.66, 7.86]],
	},
}


ds = earthkit.data.from_source("polytope", "ecmwf-mars", request, stream=False, address='polytope.ecmwf.int')
import earthkit.data 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/166/167/169", "number" : "1", "step": "0", "feature" : { "type" : "boundingbox", "points" : [[53.55, 2.76], [50.66, 7.86]], }, } 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()
da
da = ds.to_xarray() da
Out[4]:
<xarray.Dataset> Size: 81kB
Dimensions:    (datetimes: 1, number: 1, steps: 1, points: 1258)
Coordinates:
  * datetimes  (datetimes) <U20 80B '2024-11-13T00:00:00Z'
  * number     (number) int64 8B 1
  * steps      (steps) int64 8B 0
  * points     (points) int64 10kB 0 1 2 3 4 5 ... 1252 1253 1254 1255 1256 1257
    x          (points) float64 10kB 50.72 50.72 50.72 ... 53.53 53.53 53.53
    y          (points) float64 10kB 2.877 3.037 3.197 3.357 ... 7.4 7.572 7.744
    z          (points) float64 10kB 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0 0.0
Data variables:
    tcc        (datetimes, number, steps, points) float64 10kB 0.9396 ... 1.0
    10v        (datetimes, number, steps, points) float64 10kB -1.797 ... -0....
    2t         (datetimes, number, steps, points) float64 10kB 278.3 ... 279.3
    ssrd       (datetimes, number, steps, points) float64 10kB 0.0 0.0 ... 0.0
Attributes:
    class:          od
    Forecast date:  2024-11-13T00:00:00Z
    domain:         g
    expver:         0001
    levtype:        sfc
    number:         1
    step:           0
    stream:         enfo
    type:           pf
    date:           2024-11-13T00:00:00Z
xarray.Dataset
    • datetimes: 1
    • number: 1
    • steps: 1
    • points: 1258
    • datetimes
      (datetimes)
      <U20
      '2024-11-13T00:00:00Z'
      array(['2024-11-13T00:00:00Z'], dtype='<U20')
    • number
      (number)
      int64
      1
      array([1])
    • steps
      (steps)
      int64
      0
      array([0])
    • points
      (points)
      int64
      0 1 2 3 4 ... 1254 1255 1256 1257
      array([   0,    1,    2, ..., 1255, 1256, 1257])
    • x
      (points)
      float64
      50.72 50.72 50.72 ... 53.53 53.53
      array([50.72056105, 50.72056105, 50.72056105, ..., 53.5325117 ,
             53.5325117 , 53.5325117 ])
    • y
      (points)
      float64
      2.877 3.037 3.197 ... 7.572 7.744
      array([2.87744227, 3.03730018, 3.19715808, ..., 7.39961759, 7.57170172,
             7.74378585])
    • z
      (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.])
    • tcc
      (datetimes, number, steps, points)
      float64
      0.9396 0.939 0.9566 ... 1.0 1.0
      type :
      Parameter
      units :
      (0 - 1)
      long_name :
      tcc
      array([[[[0.93958312, 0.93900329, 0.95661193, ..., 0.99860412,
                0.99999267, 0.99999267]]]])
    • 10v
      (datetimes, number, steps, points)
      float64
      -1.797 -1.686 ... -0.07678 -0.02014
      type :
      Parameter
      units :
      m s**-1
      long_name :
      10v
      array([[[[-1.79748535, -1.68615723, -1.77600098, ..., -0.18225098,
                -0.07678223, -0.0201416 ]]]])
    • 2t
      (datetimes, number, steps, points)
      float64
      278.3 278.2 279.2 ... 279.4 279.3
      type :
      Parameter
      units :
      K
      long_name :
      2t
      array([[[[278.28553772, 278.19569397, 279.19374084, ..., 279.41835022,
                279.35194397, 279.27381897]]]])
    • 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(['2024-11-13T00: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,
             ...
             1248, 1249, 1250, 1251, 1252, 1253, 1254, 1255, 1256, 1257],
            dtype='int64', name='points', length=1258))
  • class :
    od
    Forecast date :
    2024-11-13T00:00:00Z
    domain :
    g
    expver :
    0001
    levtype :
    sfc
    number :
    1
    step :
    0
    stream :
    enfo
    type :
    pf
    date :
    2024-11-13T00:00:00Z

Visualise¶

In [5]:
Copied!
da = ds.to_xarray()
import earthkit.plots
chart = earthkit.plots.Map(domain="Europe")
chart.point_cloud(da['2t'], x="y", y="x")

chart.coastlines()
chart.borders()
chart.gridlines()

chart.title("{variable_name} (number={number})")

chart.legend()

chart.show()
da = ds.to_xarray() import earthkit.plots chart = earthkit.plots.Map(domain="Europe") chart.point_cloud(da['2t'], x="y", y="x") chart.coastlines() chart.borders() chart.gridlines() chart.title("{variable_name} (number={number})") chart.legend() chart.show()
No description has been provided for this image

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