From 0c14a60e37d2882c6587831b0ba7e20530771b3d Mon Sep 17 00:00:00 2001 From: Bas des Tombe Date: Wed, 26 Jul 2023 09:44:56 +0200 Subject: [PATCH] Streamline resample implementation. Raise error for resample_datastore() --- CHANGELOG.rst | 4 ++++ ...re_functions_slice_mean_max_std_resample.ipynb | 15 ++------------- src/dtscalibration/datastore.py | 5 +++++ 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 93592290..3a9bbb23 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -12,6 +12,10 @@ Bug fixes * Single-ended measurements with `fix_alpha` failed due to a bug introduced in v2.0.0 ([#173](https://github.com/dtscalibration/python-dts-calibration/pull/173)). +Removed + +* Removed ds.resample_datastore() in favor of using xarray's resample function. See example notebook 2. + 2.0.0 (2023-05-24) ------------------ diff --git a/docs/notebooks/02Common_DataStore_functions_slice_mean_max_std_resample.ipynb b/docs/notebooks/02Common_DataStore_functions_slice_mean_max_std_resample.ipynb index 4b7bb081..e230e9fa 100644 --- a/docs/notebooks/02Common_DataStore_functions_slice_mean_max_std_resample.ipynb +++ b/docs/notebooks/02Common_DataStore_functions_slice_mean_max_std_resample.ipynb @@ -282,20 +282,9 @@ "metadata": {}, "outputs": [], "source": [ - "# We use the logic from xarray to resample. However, it returns an xarray dataset type\n", - "import xarray as xr\n", - "ds_xarray = xr.Dataset(ds).resample(time=\"47S\").mean()\n", - "\n", - "# Therefore we convert it back to the dtscalibration Datastore type.\n", + "# We use the logic from xarray to resample. However, it returns an xarray dataset type. Therefore we convert it back to the dtscalibration Datastore type.\n", "from dtscalibration import DataStore\n", - "ds_resampled2 = DataStore(ds_xarray)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Note that the resample function from dtscalibration has been removed in v2.1.0. The above example works versions from before 2.0.1 as well. Starting with version 2.1.0 the `xr.Dataset(ds).resample()` may become `ds.resample()`." + "ds_resampled = DataStore(ds.resample(time=\"47S\").mean())" ] }, { diff --git a/src/dtscalibration/datastore.py b/src/dtscalibration/datastore.py index b2f854d4..fe403bd0 100644 --- a/src/dtscalibration/datastore.py +++ b/src/dtscalibration/datastore.py @@ -5503,6 +5503,11 @@ def func(a): return out + def resample_datastore(*args, **kwargs): + raise "ds.resample_datastore() is deprecated. Use " \ + "from dtscalibration import DataStore; DataStore(ds.resample()) " \ + "instead. See example notebook 2." + class ParameterIndexDoubleEnded: """