From bed731fad9a936e7b9ac05719146980a002a49dd Mon Sep 17 00:00:00 2001 From: Mostafa Farrag Date: Sun, 15 Jan 2023 22:10:31 +0100 Subject: [PATCH] refactor --- earth2observe/utils.py | 2 +- examples/abstract_implementation.py | 8 ++++---- examples/chirps_data.py | 10 +++++++++- examples/ecmwf_data.py | 4 ++-- requirements.txt | 2 +- tests/conftest.py | 18 ++++++++++++++---- 6 files changed, 31 insertions(+), 13 deletions(-) diff --git a/earth2observe/utils.py b/earth2observe/utils.py index cc6d4c9..a3697a4 100644 --- a/earth2observe/utils.py +++ b/earth2observe/utils.py @@ -42,4 +42,4 @@ def print_progress_bar( sys.stdout.flush() if i == total: - print() \ No newline at end of file + print() diff --git a/examples/abstract_implementation.py b/examples/abstract_implementation.py index 46f2a6d..b260695 100644 --- a/examples/abstract_implementation.py +++ b/examples/abstract_implementation.py @@ -16,7 +16,7 @@ lat_lim=latlim, lon_lim=lonlim, temporal_resolution=temporal_resolution, - path=path + path=path, ) # e2o.download() #%% @@ -30,7 +30,7 @@ lat_lim=latlim, lon_lim=lonlim, temporal_resolution=temporal_resolution, - path=path + path=path, ) # e2o.download(cores=4) #%% @@ -46,6 +46,6 @@ lat_lim=latlim, lon_lim=lonlim, temporal_resolution=temporal_resolution, - path=path + path=path, ) -e2o.download() \ No newline at end of file +e2o.download() diff --git a/examples/chirps_data.py b/examples/chirps_data.py index d11026a..d717b82 100644 --- a/examples/chirps_data.py +++ b/examples/chirps_data.py @@ -1,4 +1,5 @@ from earth2observe.chirps import CHIRPS + # %% precipitation start = "2009-01-01" end = "2009-01-10" @@ -7,7 +8,14 @@ lonlim = [-75.65, -74.73] path = r"examples\data\chirps" -Coello = CHIRPS(start=start, end=end, lat_lim=latlim, lon_lim=lonlim, temporal_resolution=time, path=path) +Coello = CHIRPS( + start=start, + end=end, + lat_lim=latlim, + lon_lim=lonlim, + temporal_resolution=time, + path=path, +) #%% Coello.download() # cores=4 #%% diff --git a/examples/ecmwf_data.py b/examples/ecmwf_data.py index a1c5ce7..d9979e4 100644 --- a/examples/ecmwf_data.py +++ b/examples/ecmwf_data.py @@ -38,7 +38,7 @@ path=path, variables=variables, lat_lim=latlim, - lon_lim=lonlim + lon_lim=lonlim, ) Coello.download(dataset="interim") @@ -51,7 +51,7 @@ path=path, variables=variables, lat_lim=latlim, - lon_lim=lonlim + lon_lim=lonlim, ) Coello.download() diff --git a/requirements.txt b/requirements.txt index 1908cb8..6c4cffa 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,8 +6,8 @@ loguru >=0.6.0 netCDF4 >=1.6.1 numpy ==1.24.1 pandas >=1.4.4 +pathlib >=1.0.1 pip >=22.3.1 pyramids-gis >=0.2.12 PyYAML >=6.0 -pathlib >=1.0.1 requests >=2.28.1 diff --git a/tests/conftest.py b/tests/conftest.py index fd95f6d..26b5b3c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,22 +1,26 @@ -import pytest -from typing import List from pathlib import Path -from tests.gee.conftest import * +from typing import List +import pytest + +from tests.gee.conftest import * @pytest.fixture(scope="session") def dates() -> List: return ["2009-01-01", "2009-01-05"] + @pytest.fixture(scope="session") def number_downloaded_files() -> int: return 5 + @pytest.fixture(scope="session") def daily_temporal_resolution() -> str: return "daily" + @pytest.fixture(scope="session") def lat_bounds() -> List: return [4.19, 4.64] @@ -26,6 +30,7 @@ def lat_bounds() -> List: def lon_bounds() -> List: return [-75.65, -74.73] + @pytest.fixture(scope="session") def chirps_base_dir() -> str: return "tests/data/delete/chirps" @@ -40,22 +45,27 @@ def ecmwf_base_dir() -> Path: def chirps_variables() -> List[str]: return ["precipitation"] # "T", + @pytest.fixture(scope="session") def ecmwf_variables() -> List[str]: return ["E"] # "T", + @pytest.fixture(scope="session") def ecmwf_data_source() -> str: return "ecmwf" + @pytest.fixture(scope="session") def ecmwf_data_source_output_dir() -> str: return Path("tests/data/delete/ecmwf-backend").absolute() + @pytest.fixture(scope="session") def chirps_data_source() -> str: return "chirps" + @pytest.fixture(scope="session") def chirps_data_source_output_dir() -> str: - return Path("tests/data/delete/chirps-backend").absolute() \ No newline at end of file + return Path("tests/data/delete/chirps-backend").absolute()