Skip to content

Commit

Permalink
set default buffert to 0.5 including test (#1009)
Browse files Browse the repository at this point in the history
  • Loading branch information
veenstrajelmer authored Sep 26, 2024
1 parent 78c6862 commit 600053d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dfm_tools/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
9 changes: 9 additions & 0 deletions tests/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 600053d

Please sign in to comment.