diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1a3844fa..ba481194 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,7 +39,7 @@ jobs: fail-fast: false matrix: os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] - python-version: ['3.8', '3.9', '3.10'] + python-version: ['3.9', '3.10'] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2b208300..9ecbeeef 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -16,6 +16,10 @@ Introduced limitations * Standardized parameter names. Reduced the freedom in choosing parameter names and dimension names in favor of simplifying the code. +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 1d3d883a..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.0.1. The above example works versions from before 2.0.1 as well. Starting with version 2.0.1 the `xr.Dataset(ds).resample()` may become `ds.resample()`." + "ds_resampled = DataStore(ds.resample(time=\"47S\").mean())" ] }, { diff --git a/pyproject.toml b/pyproject.toml index 28eff9f9..1e896d88 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,7 @@ name = "dtscalibration" description = "A Python package to load raw DTS files, perform a calibration, and plot the result." readme = "README.rst" license = "BSD-3-Clause" -requires-python = ">=3.8, <3.11" +requires-python = ">=3.9, <3.11" authors = [ {email = "bdestombe@gmail.com"}, {name = "Bas des Tombe, Bart Schilperoort"} @@ -46,7 +46,6 @@ classifiers = [ "Operating System :: POSIX", "Operating System :: Microsoft :: Windows", "Programming Language :: Python", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Topic :: Utilities", @@ -118,7 +117,7 @@ build = [ features = ["dev"] [[tool.hatch.envs.matrix_test.matrix]] -python = ["3.8", "3.9", "3.10"] +python = ["3.9", "3.10"] [tool.hatch.envs.matrix_test.scripts] test = ["pytest ./src/ ./tests/",] # --doctest-modules diff --git a/src/dtscalibration/datastore.py b/src/dtscalibration/datastore.py index 2582170d..7d751e45 100644 --- a/src/dtscalibration/datastore.py +++ b/src/dtscalibration/datastore.py @@ -5260,6 +5260,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: """ diff --git a/src/dtscalibration/datastore_utils.py b/src/dtscalibration/datastore_utils.py index 692a322e..6a4fc458 100644 --- a/src/dtscalibration/datastore_utils.py +++ b/src/dtscalibration/datastore_utils.py @@ -248,6 +248,9 @@ def merge_double_ended_times(ds_fw, ds_bw, verify_timedeltas=True, verbose=True) if verify_timedeltas: dt = (ds_bw.isel(time=iuse_chbw).time.values - ds_fw.isel(time=iuse_chfw).time.values) /\ np.array(1000000000, dtype='timedelta64[ns]') + dt = ( + (ds_bw.isel(time=iuse_chbw).time.values - ds_fw.isel(time=iuse_chfw).time.values) / + np.timedelta64(1, "s")) leaveout = np.zeros_like(dt, dtype=bool) leaveout[1:-1] = np.isclose(dt[:-2], dt[2:], atol=1.5, rtol=0.) * ~np.isclose(dt[:-2], dt[1:-1], atol=1.5, rtol=0.) iuse_chfw2 = np.array(iuse_chfw)[~leaveout] @@ -255,8 +258,11 @@ def merge_double_ended_times(ds_fw, ds_bw, verify_timedeltas=True, verbose=True) if verbose: for itfw, itbw in zip(np.array(iuse_chfw)[leaveout], np.array(iuse_chbw)[leaveout]): - print(f"FW: {ds_fw.isel(time=itfw).time.values} and BW: {ds_bw.isel(time=itbw).time.values} do not " - f"belong together as their timedelta is larger than their neighboring timedeltas. Thrown out.") + print( + "The following measurements do not belong together, as the time difference\n" + "between the\forward and backward measurements is more than 1.5 seconds\n" + "larger than the neighboring measurements.\n" + f"FW: {ds_fw.isel(time=itfw).time.values} and BW: {ds_bw.isel(time=itbw).time.values}") else: iuse_chfw2 = iuse_chfw diff --git a/tests/test_datastore.py b/tests/test_datastore.py index b5851803..5b26c500 100644 --- a/tests/test_datastore.py +++ b/tests/test_datastore.py @@ -563,7 +563,7 @@ def test_resample_datastore(): directory=filepath, timezone_netcdf='UTC', file_ext='*.xml') assert ds.time.size == 3 - ds_resampled = DataStore(xr.Dataset(ds).resample(time="47S").mean()) + ds_resampled = DataStore(ds.resample(time="47S").mean()) assert ds_resampled.time.size == 2 assert ds_resampled.st.dims == ('x', 'time'), 'The dimension have to ' \