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 `_. 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/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 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 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