From 600053d297ef81efa2633b8dd1223b0da167fff4 Mon Sep 17 00:00:00 2001 From: veenstrajelmer <60435591+veenstrajelmer@users.noreply.github.com> Date: Thu, 26 Sep 2024 17:36:22 +0200 Subject: [PATCH] set default buffert to 0.5 including test (#1009) --- dfm_tools/download.py | 4 ++-- tests/test_download.py | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/dfm_tools/download.py b/dfm_tools/download.py index 699d9235..979f7476 100644 --- a/dfm_tools/download.py +++ b/dfm_tools/download.py @@ -351,8 +351,8 @@ def copernicusmarine_get_buffer(dataset_id): resolution = ds.latitude.attrs["step"] buffer = 2 * resolution except (AttributeError, KeyError, TypeError): - print("failed to automatically derive a buffer from the dataset, using buffer=0") - buffer = 0 + print("failed to automatically derive a buffer from the dataset, using buffer=0.5") + buffer = 0.5 return buffer diff --git a/tests/test_download.py b/tests/test_download.py index 9283641e..7785616d 100644 --- a/tests/test_download.py +++ b/tests/test_download.py @@ -14,6 +14,7 @@ cds_set_credentials_rcfile, cds_remove_credentials_raise, copernicusmarine_credentials, + copernicusmarine_get_buffer, ) import dfm_tools as dfmt import xarray as xr @@ -165,6 +166,14 @@ def test_copernicusmarine_credentials(): copernicusmarine_credentials() +@pytest.mark.requiressecrets +@pytest.mark.unittest +def test_copernicusmarine_get_buffer_notfound(): + dataset_id = 'cmems_obs-oc_glo_bgc-transp_my_l3-multi-4km_P1D' + buffer = copernicusmarine_get_buffer(dataset_id) + assert buffer == 0.5 + + @pytest.mark.requiressecrets @pytest.mark.unittest def test_download_cmems_my(tmp_path):