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

Polygon Open Data Example¶

In [ ]:
Copied!
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": "polygon",
        "shape": [[41.870881288,-8.8791360], [41.694339317422646, -8.824238614026456], [40.171924585721314, -8.902386975546364], [38.75694209400925, -9.493088042617785], [38.42424252381525, -9.171674240710018], [38.49907333213173, -8.676525850529856], [37.057269459205145, -8.971873318897366], [37.162874354643776, -7.406745406502978], [38.19776118392036, -6.931663452624974], [38.4280922170291, -7.321584397020473], [39.011852875635526, -6.9787177479519755], [39.66227871551288, -7.5393956904523804], [39.66568774825791, -7.03915852435145], [40.0019453234905, -6.883203763416162], [40.20373392742229, -7.035724907677206], [40.350463990828985, -6.8135246275213035], [41.030499770212515, -6.905947651233703], [41.593647729084154, -6.22847017956974], [41.67712153119277, -6.544984134823352], [41.949682257268876, -6.567927092516641], [41.96960294343674, -7.1747800681640115], [41.88337981339092, -7.196871678410446], [41.81334515396762,-8.156666519264604], [42.14242723772878, -8.205142297350534], [41.870881288,-8.8791360]],
    },
}

ds = earthkit.data.from_source("polytope", "ecmwf-mars", request, stream=False, address='polytope.ecmwf.int')
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": "polygon", "shape": [[41.870881288,-8.8791360], [41.694339317422646, -8.824238614026456], [40.171924585721314, -8.902386975546364], [38.75694209400925, -9.493088042617785], [38.42424252381525, -9.171674240710018], [38.49907333213173, -8.676525850529856], [37.057269459205145, -8.971873318897366], [37.162874354643776, -7.406745406502978], [38.19776118392036, -6.931663452624974], [38.4280922170291, -7.321584397020473], [39.011852875635526, -6.9787177479519755], [39.66227871551288, -7.5393956904523804], [39.66568774825791, -7.03915852435145], [40.0019453234905, -6.883203763416162], [40.20373392742229, -7.035724907677206], [40.350463990828985, -6.8135246275213035], [41.030499770212515, -6.905947651233703], [41.593647729084154, -6.22847017956974], [41.67712153119277, -6.544984134823352], [41.949682257268876, -6.567927092516641], [41.96960294343674, -7.1747800681640115], [41.88337981339092, -7.196871678410446], [41.81334515396762,-8.156666519264604], [42.14242723772878, -8.205142297350534], [41.870881288,-8.8791360]], }, } ds = earthkit.data.from_source("polytope", "ecmwf-mars", request, stream=False, address='polytope.ecmwf.int')

Convert to xarray¶

In [2]:
Copied!
da = ds.to_xarray()
da
da = ds.to_xarray() da
Out[2]:
<xarray.Dataset> Size: 5kB
Dimensions:    (datetimes: 1, number: 1, steps: 1, points: 94)
Coordinates:
  * datetimes  (datetimes) <U20 80B '2025-02-24T00:00:00Z'
  * number     (number) int64 8B 0
  * steps      (steps) int64 8B 0
  * points     (points) int64 752B 0 1 2 3 4 5 6 7 8 ... 86 87 88 89 90 91 92 93
    x          (points) float64 752B 37.24 37.24 37.24 ... 41.73 41.73 42.01
    y          (points) float64 752B 351.3 351.7 352.0 ... 352.8 353.2 351.7
    z          (points) float64 752B 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 752B -1.994 ... 2.59
    2t         (datetimes, number, steps, points) float64 752B 283.4 ... 280.7
    ssrd       (datetimes, number, steps, points) float64 752B 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
    date:           2025-02-24T00:00:00Z
xarray.Dataset
    • datetimes: 1
    • number: 1
    • steps: 1
    • points: 94
    • 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 5 6 ... 88 89 90 91 92 93
      array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17,
             18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
             36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
             54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
             72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
             90, 91, 92, 93])
    • x
      (points)
      float64
      37.24 37.24 37.24 ... 41.73 42.01
      array([37.23652069, 37.23652069, 37.23652069, 37.23652069, 37.517551  ,
             37.517551  , 37.517551  , 37.517551  , 37.517551  , 37.79858131,
             37.79858131, 37.79858131, 37.79858131, 37.79858131, 38.07961161,
             38.07961161, 38.07961161, 38.07961161, 38.07961161, 38.07961161,
             38.36064192, 38.36064192, 38.36064192, 38.36064192, 38.64167223,
             38.64167223, 38.64167223, 38.64167223, 38.64167223, 38.64167223,
             38.92270253, 38.92270253, 38.92270253, 38.92270253, 38.92270253,
             38.92270253, 38.92270253, 39.20373283, 39.20373283, 39.20373283,
             39.20373283, 39.20373283, 39.20373283, 39.48476313, 39.48476313,
             39.48476313, 39.48476313, 39.48476313, 39.76579343, 39.76579343,
             39.76579343, 39.76579343, 39.76579343, 39.76579343, 40.04682373,
             40.04682373, 40.04682373, 40.04682373, 40.04682373, 40.32785403,
             40.32785403, 40.32785403, 40.32785403, 40.32785403, 40.60888433,
             40.60888433, 40.60888433, 40.60888433, 40.60888433, 40.88991463,
             40.88991463, 40.88991463, 40.88991463, 40.88991463, 41.17094492,
             41.17094492, 41.17094492, 41.17094492, 41.17094492, 41.17094492,
             41.45197521, 41.45197521, 41.45197521, 41.45197521, 41.45197521,
             41.45197521, 41.45197521, 41.7330055 , 41.7330055 , 41.7330055 ,
             41.7330055 , 41.7330055 , 41.7330055 , 42.0140358 ])
    • y
      (points)
      float64
      351.3 351.7 352.0 ... 353.2 351.7
      array([351.33333333, 351.66666667, 352.        , 352.33333333,
             351.33333333, 351.66666667, 352.        , 352.33333333,
             352.66666667, 351.33333333, 351.66666667, 352.        ,
             352.33333333, 352.66666667, 351.33333333, 351.66666667,
             352.        , 352.33333333, 352.66666667, 353.        ,
             351.5625    , 351.9140625 , 352.265625  , 352.6171875 ,
             350.859375  , 351.2109375 , 351.5625    , 351.9140625 ,
             352.265625  , 352.6171875 , 350.859375  , 351.2109375 ,
             351.5625    , 351.9140625 , 352.265625  , 352.6171875 ,
             352.96875   , 350.859375  , 351.2109375 , 351.5625    ,
             351.9140625 , 352.265625  , 352.6171875 , 350.859375  ,
             351.2109375 , 351.5625    , 351.9140625 , 352.265625  ,
             351.2109375 , 351.5625    , 351.9140625 , 352.265625  ,
             352.6171875 , 352.96875   , 351.36      , 351.72      ,
             352.08      , 352.44      , 352.8       , 351.36      ,
             351.72      , 352.08      , 352.44      , 352.8       ,
             351.36      , 351.72      , 352.08      , 352.44      ,
             352.8       , 351.36      , 351.72      , 352.08      ,
             352.44      , 352.8       , 351.36      , 351.72      ,
             352.08      , 352.44      , 352.8       , 353.16      ,
             351.36      , 351.72      , 352.08      , 352.44      ,
             352.8       , 353.16      , 353.52      , 351.36      ,
             351.72      , 352.08      , 352.44      , 352.8       ,
             353.16      , 351.72      ])
    • 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., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
             0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
             0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
             0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
             0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
             0., 0., 0., 0., 0., 0., 0., 0., 0.])
    • 10v
      (datetimes, number, steps, points)
      float64
      -1.994 -2.695 ... 0.2392 2.59
      type :
      Parameter
      units :
      m s**-1
      long_name :
      10v
      array([[[[-1.99423218e+00, -2.69540405e+00, -1.19638062e+00,
                -8.58489990e-01,  1.11236572e-01, -8.70056152e-02,
                 6.43615723e-02,  5.94787598e-02, -7.41302490e-01,
                -2.25677490e-01,  3.58306885e-01, -3.00872803e-01,
                -2.35443115e-01, -1.38485718e+00, -1.82708740e-01,
                -8.88061523e-03, -4.12200928e-01, -4.17083740e-01,
                -7.33337402e-02,  7.75299072e-01, -4.12200928e-01,
                -2.38372803e-01,  8.48693848e-02, -3.23181152e-02,
                 2.80181885e-01, -1.23138428e-01, -3.12591553e-01,
                -4.94232178e-01, -2.79388428e-01, -1.06536865e-01,
                 1.08306885e-01,  2.27447510e-01, -9.97009277e-02,
                 3.81469727e-03,  9.05181885e-01,  4.31549072e-01,
                -1.45599365e-01,  1.21963501e+00, -4.92279053e-01,
                -4.98138428e-01, -1.53411865e-01,  2.29400635e-01,
                -1.55364990e-01,  2.12588501e+00,  2.66510010e-01,
                -4.57122803e-01, -3.40911865e-01,  7.99713135e-01,
                 1.37783813e+00, -4.83489990e-01,  2.83111572e-01,
                -2.08099365e-01,  1.34674072e-01,  6.74438477e-03,
                 1.89834595e+00,  8.12408447e-01,  5.95611572e-01,
                -1.30950928e-01, -1.76696777e-02,  1.95596313e+00,
                 1.86157227e-03,  9.46197510e-01,  5.37994385e-01,
                 1.20498657e+00,  2.43545532e+00,  3.32916260e-01,
                 2.23541260e-01,  1.07330322e-01,  2.51260376e+00,
                 3.61416626e+00,  1.80654907e+00,  3.14361572e-01,
                 1.65811157e+00,  1.95401001e+00,  3.17373657e+00,
                 1.84478760e-01,  1.14166260e-01,  1.94244385e-01,
                 4.59869385e-01,  1.14248657e+00,  2.20010376e+00,
                 2.57720947e-01,  1.68853760e-01,  9.00299072e-01,
                 5.99517822e-01,  4.75494385e-01,  1.75674438e+00,
                 9.35455322e-01,  8.87756348e-02,  1.85733032e+00,
                 1.16983032e+00, -4.60052490e-01,  2.39166260e-01,
                 2.58975220e+00]]]])
    • 2t
      (datetimes, number, steps, points)
      float64
      283.4 283.3 283.5 ... 279.3 280.7
      type :
      Parameter
      units :
      K
      long_name :
      2t
      array([[[[283.40612793, 283.27331543, 283.54675293, 283.89245605,
                282.82019043, 282.34558105, 284.08776855, 283.07409668,
                283.71862793, 283.46862793, 282.43151855, 282.20495605,
                282.5135498 , 282.88659668, 283.45300293, 282.67956543,
                283.0135498 , 282.85144043, 282.00769043, 281.04675293,
                282.70495605, 282.73815918, 283.23815918, 283.3963623 ,
                284.6463623 , 282.38659668, 283.0604248 , 283.66784668,
                282.77331543, 283.71472168, 282.97058105, 282.78894043,
                282.48034668, 282.5369873 , 282.58190918, 284.0682373 ,
                281.8182373 , 283.61315918, 282.5916748 , 282.82409668,
                282.32800293, 282.28308105, 284.20300293, 284.29284668,
                284.20495605, 282.09558105, 281.7401123 , 282.45495605,
                282.76550293, 281.5135498 , 283.37097168, 281.45495605,
                281.61315918, 281.60925293, 283.2479248 , 281.4354248 ,
                280.89245605, 280.47058105, 282.23425293, 282.66394043,
                281.6697998 , 281.9822998 , 279.9979248 , 281.13464355,
                282.82214355, 282.6385498 , 281.22839355, 281.1229248 ,
                279.8338623 , 284.80065918, 281.60925293, 280.32019043,
                279.8572998 , 280.9197998 , 284.54675293, 281.12487793,
                280.39050293, 280.02722168, 279.77526855, 280.75378418,
                283.36901855, 280.8182373 , 280.03308105, 279.6072998 ,
                279.79675293, 280.6854248 , 279.8807373 , 281.43151855,
                280.9588623 , 278.36706543, 280.0213623 , 279.1229248 ,
                279.29675293, 280.66003418]]]])
    • 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., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
                0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
                0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
                0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
                0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
                0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 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, 10, 11, 12, 13, 14, 15, 16, 17,
             18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
             36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
             54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
             72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
             90, 91, 92, 93],
            dtype='int64', name='points'))
  • 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
    date :
    2025-02-24T00:00:00Z

Visualise data¶

In [3]:
Copied!
da = ds.to_xarray()
import earthkit.plots
chart = earthkit.plots.Map(domain="Portugal")
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="Portugal") 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
In [ ]:
Copied!


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