From db34e25ae399b0a77a3964c293629f1cbbd3380d Mon Sep 17 00:00:00 2001 From: Sandor Kertesz Date: Fri, 22 Nov 2024 14:01:44 +0000 Subject: [PATCH] Add earthkit-time (#81) * Add earthkit-time --- docs/components_overview.rst | 3 + docs/conf.py | 4 ++ docs/index.rst | 1 + environment.yml | 3 +- pyproject.toml | 3 +- src/earthkit/__init__.py | 2 + tests/environment-unit-tests.yml | 3 +- tests/test_import.py | 45 +++++++++++++++ tests/test_obj.py | 96 ++++++++++++++++++++++++++++++++ tests/test_version.py | 16 ++++++ 10 files changed, 173 insertions(+), 3 deletions(-) create mode 100644 tests/test_import.py create mode 100644 tests/test_obj.py diff --git a/docs/components_overview.rst b/docs/components_overview.rst index fbdfedd..a99f491 100644 --- a/docs/components_overview.rst +++ b/docs/components_overview.rst @@ -28,6 +28,9 @@ This is the summary of the available ``earthkit`` components. * - :xref:`earthkit-regrid` - Regridding of geospatial data. - + * - :xref:`earthkit-time` + - Manipulation of dates and time for weather forecasting. + - * - :xref:`earthkit-transforms` - Aggregation and transformation of geospatial data. - diff --git a/docs/conf.py b/docs/conf.py index 8590b1a..38be858 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -81,6 +81,10 @@ "earthkit-regrid", "https://earthkit-regrid.readthedocs.io", ), + "earthkit-time": ( + "earthkit-time", + "https://earthkit-time.readthedocs.io", + ), "earthkit-transforms": ( "earthkit-transforms", "https://earthkit-transforms.readthedocs.io", diff --git a/docs/index.rst b/docs/index.rst index 1e6f071..e13a5f0 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -30,6 +30,7 @@ The interface of :ref:`earthkit components ` is designed to be high- earthkit-meteo earthkit-plots earthkit-regrid + earthkit-time earthkit-transforms .. toctree:: diff --git a/environment.yml b/environment.yml index 8c0c2c5..7a89998 100644 --- a/environment.yml +++ b/environment.yml @@ -6,8 +6,9 @@ dependencies: - earthkit-data>=0.11.1 - geos - pip: - - earthkit-geo>=0.2.0 + - earthkit-geo>=0.3.0 - earthkit-meteo>=0.1.1 - earthkit-plots>=0.2.5 - earthkit-regrid>=0.3.4 + - earthkit-time>=0.1.6 - earthkit-transforms>=0.3.4 diff --git a/pyproject.toml b/pyproject.toml index f2f16e7..abc162b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,10 +28,11 @@ classifiers = [ dynamic = [ "version" ] dependencies = [ "earthkit-data[all]>=0.11.1", - "earthkit-geo>=0.2", + "earthkit-geo>=0.3", "earthkit-meteo>=0.1.1", "earthkit-plots>=0.2.5", "earthkit-regrid>=0.3.4", + "earthkit-time>=0.1.6", "earthkit-transforms>=0.3.4", ] optional-dependencies.test = [ "pytest" ] diff --git a/src/earthkit/__init__.py b/src/earthkit/__init__.py index 84aa07e..87e8c31 100644 --- a/src/earthkit/__init__.py +++ b/src/earthkit/__init__.py @@ -21,6 +21,7 @@ import earthkit.meteo as meteo import earthkit.plots as plots import earthkit.regrid as regrid +import earthkit.time as time import earthkit.transforms as transforms __all__ = [ @@ -29,6 +30,7 @@ "meteo", "plots", "regrid", + "time", "transforms", "__version__", ] diff --git a/tests/environment-unit-tests.yml b/tests/environment-unit-tests.yml index 9dccbb5..0e96f33 100644 --- a/tests/environment-unit-tests.yml +++ b/tests/environment-unit-tests.yml @@ -9,8 +9,9 @@ dependencies: - geos - pip: - earthkit-data[all]>=0.11.1 - - earthkit-geo>=0.2.0 + - earthkit-geo>=0.3.0 - earthkit-meteo>=0.1.1 - earthkit-plots>=0.2.5 - earthkit-regrid>=0.3.4 + - earthkit-time>=0.1.6 - earthkit-transforms>=0.3.4 diff --git a/tests/test_import.py b/tests/test_import.py new file mode 100644 index 0000000..c3f5fd7 --- /dev/null +++ b/tests/test_import.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 + +# (C) Copyright 2023 ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# In applying this licence, ECMWF does not waive the privileges and immunities +# granted to it by virtue of its status as an intergovernmental organisation +# nor does it submit to any jurisdiction. +# + + +def test_earthkit_data_import(): + import earthkit.data # noqa + from earthkit.data import from_source # noqa + + +def test_earthkit_geo_import(): + import earthkit.geo # noqa + from earthkit.geo import nearest_point_kdtree # noqa + + +def test_earthkit_meteo_import(): + import earthkit.meteo # noqa + from earthkit.meteo import thermo # noqa + + +def test_earthkit_plots_import(): + import earthkit.plots # noqa + from earthkit.plots import quickmap # noqa + + +def test_earthkit_regrid_import(): + import earthkit.regrid # noqa + from earthkit.regrid import interpolate # noqa + + +def test_earthkit_time_import(): + import earthkit.time # noqa + from earthkit.time import DailySequence # noqa + + +def test_earthkit_transforms_import(): + import earthkit.transforms # noqa + from earthkit.transforms import aggregate # noqa diff --git a/tests/test_obj.py b/tests/test_obj.py new file mode 100644 index 0000000..9ae755c --- /dev/null +++ b/tests/test_obj.py @@ -0,0 +1,96 @@ +#!/usr/bin/env python3 + +# (C) Copyright 2023 ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# In applying this licence, ECMWF does not waive the privileges and immunities +# granted to it by virtue of its status as an intergovernmental organisation +# nor does it submit to any jurisdiction. +# + + +def test_earthkit_data_obj_1(): + import earthkit.data + + assert callable(earthkit.data.from_source) + + +def test_earthkit_data_obj_2(): + from earthkit import data + + assert callable(data.from_source) + + +def test_earthkit_geo_obj_1(): + import earthkit.geo + + assert callable(earthkit.geo.nearest_point_kdtree) + + +def test_earthkit_geo_obj_2(): + from earthkit import geo + + assert callable(geo.nearest_point_kdtree) + + +def test_earthkit_meteo_obj_1(): + import earthkit.meteo + + assert callable(earthkit.meteo.thermo.potential_temperature) + + +def test_earthkit_meteo_obj_2(): + from earthkit import meteo + + assert callable(meteo.thermo.potential_temperature) + + +def test_earthkit_plots_obj_1(): + import earthkit.plots + + assert callable(earthkit.plots.quickmap.plot) + + +def test_earthkit_plots_obj_2(): + from earthkit import plots + + assert callable(plots.quickmap.plot) + + +def test_earthkit_regrid_obj_1(): + import earthkit.regrid + + assert callable(earthkit.regrid.interpolate) + + +def test_earthkit_regrid_obj_2(): + from earthkit import regrid + + assert callable(regrid.interpolate) + + +def test_earthkit_time_obj_1(): + import earthkit.time + + x = earthkit.time.DailySequence() + assert x is not None + + +def test_earthkit_time_obj_2(): + from earthkit import time + + x = time.DailySequence() + assert x is not None + + +def test_earthkit_transforms_obj_1(): + import earthkit.transforms + + assert callable(earthkit.transforms.aggregate.spatial.masks) + + +def test_earthkit_transforms_obj_2(): + from earthkit import transforms + + assert callable(transforms.aggregate.spatial.masks) diff --git a/tests/test_version.py b/tests/test_version.py index 006bf3d..757a175 100644 --- a/tests/test_version.py +++ b/tests/test_version.py @@ -10,6 +10,9 @@ # import re +from importlib.metadata import version + +import pytest VERSION_RX = re.compile(r"""\d+\.\d+\.*""") @@ -81,6 +84,19 @@ def test_earthkit_regrid_version_2(): assert VERSION_RX.match(regrid.__version__) is not None +def test_earthkit_time_version_1(): + import earthkit.time # noqa + + assert VERSION_RX.match(version("earthkit.time")) is not None + + +@pytest.mark.xfail(reason="version not available") +def test_earthkit_time_version_2(): + from earthkit import time # noqa + + assert VERSION_RX.match(time.__version__) is not None + + def test_earthkit_transforms_version_1(): import earthkit.transforms # noqa