From 425731941606d766aaa93b75b82675ae4a12bb9f Mon Sep 17 00:00:00 2001 From: abel Date: Wed, 27 Apr 2022 14:02:41 +0200 Subject: [PATCH 1/4] DOC: Update release process Added info about twine for release and made it a dev dependency --- doc/source/dev/release_process.rst | 2 +- environment.yml | 1 + requirements_dev.txt | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/source/dev/release_process.rst b/doc/source/dev/release_process.rst index 1f028b15..5db086e4 100644 --- a/doc/source/dev/release_process.rst +++ b/doc/source/dev/release_process.rst @@ -19,7 +19,7 @@ Release process python3 -m setup sdist -#. Try to upload on testpypi first. +#. Try to upload on testpypi first. ``twine`` must be installed in your env beforehand. .. code-block:: sh diff --git a/environment.yml b/environment.yml index 363145bb..c1ec3a10 100644 --- a/environment.yml +++ b/environment.yml @@ -29,6 +29,7 @@ dependencies: - pytest - pytest-cov - setuptools + - twine # Extra dependencies - matplotlib - cartopy diff --git a/requirements_dev.txt b/requirements_dev.txt index 895fa2b8..41c72f51 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -16,6 +16,7 @@ pytest-cov rechunker~=0.5 setuptools>=49.6.0 sphinx +twine xarray~=0.19.0 xclim~=0.34.0 zarr From 1689213f21ac48aeb05fb744546658cfd16ff194 Mon Sep 17 00:00:00 2001 From: abel Date: Wed, 27 Apr 2022 14:03:22 +0200 Subject: [PATCH 2/4] MAINT: Add forgotten mandatory dependency --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index b549708a..1cb7d033 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,7 @@ cftime dask[array] distributed fsspec +netCDF4~=1.5.7 numpy pandas pytest From e7e9b6efed93243a3f0a631547260f0d90463c0d Mon Sep 17 00:00:00 2001 From: abel Date: Wed, 27 Apr 2022 14:04:16 +0200 Subject: [PATCH 3/4] MAINT: Make use of new API in README --- README.rst | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/README.rst b/README.rst index 8c322136..a8ced923 100644 --- a/README.rst +++ b/README.rst @@ -20,19 +20,14 @@ From sources: How to use icclim ----------------- -Let's count the number of days above 25ºC, which corresponds to the index ``SU``, from a `tasmax` variable scattered in multiple netcdf files. +Let's count the number of days above 25ºC for each year, which corresponds to the index ``SU``, from a `tasmax` variable scattered in multiple netcdf files. `SU` is one of the many index that can be computed with icclim. See `the documentation `_ to explore what other index you can compute with icclim. .. code-block:: python - import glob import icclim - summer_days = icclim.index( - index_name="SU", - in_files=glob.glob(f"netcdf_files/tasmax*.nc"), - out_file="summer_days.nc" - ) + summer_days = icclim.su("netcdf_files/tasmax_1990-2100.nc", out_file="summer_days.nc") For more examples on how to use icclim, see icclim's `How to ... `_ documentation or `our notebooks `_. From a288fd3884bfc722b4a726d86d9ec019f724d791 Mon Sep 17 00:00:00 2001 From: abel Date: Wed, 27 Apr 2022 14:51:49 +0200 Subject: [PATCH 4/4] MAINT: Update SliceMode typing Now a Frequency instance can be used directly as a valid input for `slice_mode`. --- icclim/models/frequency.py | 5 +++-- icclim/tests/test_main.py | 13 +++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/icclim/models/frequency.py b/icclim/models/frequency.py index e814f75c..6de9bfc8 100644 --- a/icclim/models/frequency.py +++ b/icclim/models/frequency.py @@ -17,8 +17,6 @@ from icclim.icclim_exceptions import InvalidIcclimArgumentError -SliceMode = Union[str, List[Union[str, Tuple, int]]] - def seasons_resampler( month_list: list[int], @@ -232,3 +230,6 @@ def _get_frequency_from_list(slice_mode_list: list) -> Frequency: "The sampling frequency must be one of {'season', 'month'}" ) return custom_freq + + +SliceMode = Union[Frequency, str, List[Union[str, Tuple, int]]] diff --git a/icclim/tests/test_main.py b/icclim/tests/test_main.py index 134862a2..67a77a30 100644 --- a/icclim/tests/test_main.py +++ b/icclim/tests/test_main.py @@ -8,6 +8,7 @@ import icclim from icclim.models.ecad_indices import EcadIndex +from icclim.models.frequency import Frequency from icclim.models.index_group import IndexGroup @@ -68,6 +69,18 @@ def test_index_SU(self): ) np.testing.assert_array_equal(0, res.SU) + def test_index_SU__monthy_sampled(self): + res = icclim.index( + indice_name="SU", + in_files=self.data, + out_file=self.OUTPUT_FILE, + slice_mode=Frequency.MONTH, + ) + np.testing.assert_array_equal(0, res.SU) + np.testing.assert_array_equal( + len(np.unique(self.TIME_RANGE.year)) * 12, len(res.time) + ) + def test_indices_from_DataArray(self): res = icclim.indices( index_group=IndexGroup.HEAT, in_files=self.data, out_file=self.OUTPUT_FILE