Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undo using covjsonkit instead of eccovjson #476

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Alternatively, you can install the following components:
- odb: provides full support for the :ref:`odb` data type
- geopandas: adds geojson/geopandas support
- projection: adds projection support
- covjsonkit: provides access to coverage json data served by the :ref:`data-sources-polytope` source
- eccovjson: provides access to coverage json data served by the :ref:`data-sources-polytope` source

E.g. to add :ref:`data-sources-mars` support you can use:

Expand Down
10 changes: 1 addition & 9 deletions docs/release_notes/version_0.10_updates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@ Version 0.10 Updates
/////////////////////////


Version 0.10.5
===============

Changes
+++++++

- Use covjsonkit package instead of eccovjson (:pr:`445`).


Version 0.10.4
===============

Expand All @@ -20,6 +11,7 @@ Fixes
- Fixed issue when pandas was unnecessarily imported (:pr:`468`).



Version 0.10.3
===============

Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies:
- ecmwf-opendata>=0.1.2
- polytope-client>=0.7.4
- earthkit-meteo>=0.0.1
- covjsonkit>=0.0.19
- eccovjson>=0.0.5
- earthkit-geo>=0.2.0
- tqdm>=4.63.0
- lru-dict
Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ dependencies = [
optional-dependencies.all = [
"cartopy",
"cdsapi>=0.7.1",
"covjsonkit>=0.0.19",
"eccovjson>=0.0.5",
"ecmwf-api-client>=1.6.1",
"ecmwf-opendata>=0.3.3",
"geopandas",
Expand All @@ -69,14 +69,11 @@ optional-dependencies.ci = [
"array-api-compat",
"torch",
]
optional-dependencies.covjsonkit = [
"covjsonkit>=0.0.19",
]
optional-dependencies.dev = [
"cartopy",
"cdsapi>=0.7.1",
"covjsonkit>=0.0.19",
"earthkit-data-demo-source",
"eccovjson>=0.0.5",
"ecmwf-api-client>=1.6.1",
"ecmwf-opendata>=0.3.3",
"geopandas",
Expand All @@ -91,6 +88,9 @@ optional-dependencies.dev = [
"pytest-forked",
"pytest-timeout",
]
optional-dependencies.eccovjson = [
"eccovjson>=0.0.5",
]
optional-dependencies.ecmwf-opendata = [
"ecmwf-opendata>=0.3.3",
]
Expand Down
6 changes: 3 additions & 3 deletions src/earthkit/data/readers/covjson.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
class XarrayMixIn:
def to_xarray(self, **kwargs):
try:
from covjsonkit.api import Covjsonkit
from eccovjson.api import Eccovjson
except ImportError:
raise ImportError("covjson handling requires 'covjsonkit' to be installed")
raise ImportError("covjason handling requires 'eccovjson' to be installed")

decoder = Covjsonkit().decode(self._json())
decoder = Eccovjson().decode(self._json())
return decoder.to_xarray()


Expand Down
2 changes: 1 addition & 1 deletion src/earthkit/data/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def modules_installed(*modules):
NO_FDB = True

NO_POLYTOPE = not os.path.exists(os.path.expanduser("~/.polytopeapirc"))
NO_COVJSONKIT = not modules_installed("covjsonkit")
NO_ECCOVJSON = not modules_installed("eccovjson")
NO_PYTORCH = not modules_installed("torch")
NO_CUPY = not modules_installed("cupy")
if not NO_CUPY:
Expand Down
2 changes: 1 addition & 1 deletion tests/data/time_series.covjson
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"type": "CoverageCollection", "domainType": "PointSeries", "coverages": [{"mars:metadata": {"class": "od", "Forecast date": "20240103T00", "domain": "g", "expver": "0001", "levtype": "sfc", "stream": "oper", "type": "fc", "number": 1}, "type": "Coverage", "domain": {"type": "Domain", "axes": {"x": {"values": [0.035149384216]}, "y": {"values": [0.0]}, "z": {"values": ["sfc"]}, "t": {"values": ["2024-01-03T00:00:00", "2024-01-03T01:00:00", "2024-01-03T02:00:00", "2024-01-03T03:00:00", "2024-01-03T04:00:00", "2024-01-03T05:00:00", "2024-01-03T06:00:00", "2024-01-03T07:00:00", "2024-01-03T08:00:00"]}}}, "ranges": {"2t": {"type": "NdArray", "dataType": "float", "shape": [9], "axisNames": ["t"], "values": [298.9648132324219, 298.6933288574219, 298.9999694824219, 298.5683288574219, 298.9960632324219, 298.4452819824219, 299.05596923828125, 299.21807861328125, 298.95050048828125]}}}], "parameters": {"2t": {"type": "Parameter", "description": "Temperature", "unit": {"symbol": "K"}, "observedProperty": {"id": "2t", "label": {"en": "Temperature"}}}}, "referencing": [{"coordinates": ["x", "y", "z"], "system": {"type": "GeographicCRS", "id": "http://www.opengis.net/def/crs/OGC/1.3/CRS84"}}]}
{"type": "CoverageCollection", "domainType": "PointSeries", "coverages": [{"mars:metadata": {"class": "od", "date": "20240103T00", "domain": "g", "expver": "0001", "levtype": "sfc", "stream": "oper", "type": "fc", "number": 1}, "type": "Coverage", "domain": {"type": "Domain", "axes": {"x": {"values": [0.035149384216]}, "y": {"values": [0.0]}, "z": {"values": ["sfc"]}, "t": {"values": ["2024-01-03T00:00:00", "2024-01-03T01:00:00", "2024-01-03T02:00:00", "2024-01-03T03:00:00", "2024-01-03T04:00:00", "2024-01-03T05:00:00", "2024-01-03T06:00:00", "2024-01-03T07:00:00", "2024-01-03T08:00:00"]}}}, "ranges": {"t": {"type": "NdArray", "dataType": "float", "shape": [9], "axisNames": ["t"], "values": [298.9648132324219, 298.6933288574219, 298.9999694824219, 298.5683288574219, 298.9960632324219, 298.4452819824219, 299.05596923828125, 299.21807861328125, 298.95050048828125]}}}], "parameters": {"t": {"type": "Parameter", "description": "Temperature", "unit": {"symbol": "K"}, "observedProperty": {"id": "t", "label": {"en": "Temperature"}}}}, "referencing": [{"coordinates": ["x", "y", "z"], "system": {"type": "GeographicCRS", "id": "http://www.opengis.net/def/crs/OGC/1.3/CRS84"}}]}
2 changes: 1 addition & 1 deletion tests/environment-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies:
- polytope-client>=0.7.4
- earthkit-meteo>=0.0.1
- git+https://github.com/ecmwf/earthkit-data-demo-source
- covjsonkit>=0.0.19
- eccovjson>=0.0.5
- earthkit-geo>=0.2.0
- tqdm>=4.63.0
- lru-dict
Expand Down
10 changes: 5 additions & 5 deletions tests/readers/test_covjson_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import pytest

from earthkit.data import from_source
from earthkit.data.testing import NO_COVJSONKIT
from earthkit.data.testing import NO_ECCOVJSON
from earthkit.data.testing import earthkit_test_data_file


Expand All @@ -20,15 +20,15 @@ def test_covjson():
assert ds


@pytest.mark.skipif(NO_COVJSONKIT, reason="no covjsonkit available")
@pytest.mark.skipif(NO_ECCOVJSON, reason="no eccovjson available")
def test_covjson_to_xarray():
ds = from_source("file", earthkit_test_data_file("time_series.covjson"))
assert ds
a = ds.to_xarray()
assert len(a.data_vars) == 1


@pytest.mark.skipif(NO_COVJSONKIT, reason="no covjsonkit available")
@pytest.mark.skipif(NO_ECCOVJSON, reason="no eccovjson available")
def test_covjson_memory():
with open(earthkit_test_data_file("time_series.covjson"), "r") as f:
d = f.read().encode()
Expand All @@ -39,7 +39,7 @@ def test_covjson_memory():
assert len(a.data_vars) == 1


@pytest.mark.skipif(NO_COVJSONKIT, reason="no covjsonkit available")
@pytest.mark.skipif(NO_ECCOVJSON, reason="no eccovjson available")
def test_covjson_stream():
stream = open(earthkit_test_data_file("time_series.covjson"), "rb")

Expand All @@ -54,7 +54,7 @@ def test_covjson_stream():
next(it)


@pytest.mark.skipif(NO_COVJSONKIT, reason="no covjsonkit available")
@pytest.mark.skipif(NO_ECCOVJSON, reason="no eccovjson available")
def test_covjson_stream_memory():
stream = open(earthkit_test_data_file("time_series.covjson"), "rb")

Expand Down
Loading