diff --git a/icclim/main.py b/icclim/main.py index a92ec938..1e5f98c0 100644 --- a/icclim/main.py +++ b/icclim/main.py @@ -21,6 +21,7 @@ from xarray.core.dataset import Dataset from icclim.ecad.ecad_indices import EcadIndexRegistry +from icclim.ecad.xclim_binding import XCLIM_BINDING from icclim.generic_indices.generic_indicators import ( GenericIndicator, GenericIndicatorRegistry, @@ -569,7 +570,17 @@ def _compute_climate_index( else: result_da = result_da.rename(climate_index.name) result_da.attrs[UNITS_KEY] = _get_unit(config.out_unit, result_da) - if config.frequency.post_processing is not None and "time" in result_da.dims: + if ( + config.frequency.post_processing is not None + and "time" in result_da.dims + and not isinstance( + climate_index, + ( + XCLIM_BINDING.StandardizedPrecipitationIndex6, + XCLIM_BINDING.StandardizedPrecipitationIndex3, + ), + ) + ): resampled_da, time_bounds = config.frequency.post_processing(result_da) result_ds = resampled_da.to_dataset() if time_bounds is not None: diff --git a/icclim/tests/test_input_parsing.py b/icclim/tests/test_input_parsing.py index 424dcc6f..4a9a66b6 100644 --- a/icclim/tests/test_input_parsing.py +++ b/icclim/tests/test_input_parsing.py @@ -108,7 +108,7 @@ def test_read_dataset_xr_ds__simple(self): # THEN xr.testing.assert_equal(ds_res.pouet, ds.pouet) - def test_read_dataset_netcdf_success(self): + def test_read_dataset__netcdf_success(self): # GIVEN ds = xr.Dataset({"pouet": self.pr_da}) ds.to_netcdf(self.OUTPUT_NC_FILE) @@ -117,7 +117,7 @@ def test_read_dataset_netcdf_success(self): # THEN xr.testing.assert_equal(ds_res.pouet, ds.pouet) - def test_read_dataset_multi_netcdf_success(self): + def test_read_dataset__multi_netcdf_success(self): # GIVEN ds = xr.Dataset({"pouet": self.pr_da}) ds.to_netcdf(self.OUTPUT_NC_FILE) @@ -128,7 +128,7 @@ def test_read_dataset_multi_netcdf_success(self): xr.testing.assert_equal(ds_res.pouet, ds.pouet) xr.testing.assert_equal(ds_res.patapouet, ds.pouet) - def test_read_dataset_zarr_store_success(self): + def test_read_dataset__zarr_store_success(self): # GIVEN ds = xr.Dataset({"pouet": self.pr_da}) ds.to_zarr(self.OUTPUT_ZARR_STORE) @@ -137,7 +137,7 @@ def test_read_dataset_zarr_store_success(self): # THEN xr.testing.assert_equal(ds_res.pouet, ds.pouet) - def test_read_dataset_not_implemented_error(self): + def test_read_dataset__not_implemented_error(self): # THEN with pytest.raises(NotImplementedError): # WHEN diff --git a/icclim/tests/test_main.py b/icclim/tests/test_main.py index 3e712087..3ee2e770 100644 --- a/icclim/tests/test_main.py +++ b/icclim/tests/test_main.py @@ -400,6 +400,15 @@ def test_indices_all_from_Dataset__seasonal_SPI_error(self): base_period_time_range=("2042-01-01", "2042-12-31"), ) + def test_spi6__no_time_bounds(self): + dataset = icclim.index( + index_name="spi6", + in_files=self.full_data, + var_name="pr", + base_period_time_range=["2042-01-01", "2042-06-01"], + ).load() + assert "time_bounds" not in dataset.coords + def test_indices_all_from_Dataset__seasonal(self): res = icclim.indices( index_group="all",