ecmwf / earthkit-data

A format-agnostic Python interface for geospatial data
Apache License 2.0
56 stars 13 forks source link

Add support for polytope covjson #282

Closed sandorkertesz closed 8 months ago

sandorkertesz commented 8 months ago

This PR adds support for loading covearge json from a file or a polytope service. Requires the latest develop branches from polytope-client and eccovjson.

This code works when we have the right polytope credentials:

import earthkit.data

request = {
    "class": "od",
    "stream": "oper",
    "type": "fc",
    "levtype": "sfc",
    "date": "20240103",
    "time": "00",
    "expver": "0001",
    "domain": "g",
    "param": "167",  # 2t
    "feature": {
        "type": "timeseries",
        "points": [[0.035149384216, 0.0]],
        "start": 0,
        "end": 9,
    },
}

ds = earthkit.data.from_source("polytope", "ecmwf-mars-beta",
                       request, address="polytope-dev.ecmwf.int")

ds.to_xarray()

This code works too:

import earthkit.data

ds = earthkit.data.from_source("file", "tests/data/time_series.covjson")
ds.to_xarray()