From 22eb3b3070443a392845b24ddff5ec1c74bc6f79 Mon Sep 17 00:00:00 2001 From: veenstrajelmer Date: Mon, 11 Dec 2023 15:37:52 +0100 Subject: [PATCH 1/2] added copernicusmarine_reset --- dfm_tools/download.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dfm_tools/download.py b/dfm_tools/download.py index a601bc30d..d36af1876 100644 --- a/dfm_tools/download.py +++ b/dfm_tools/download.py @@ -14,6 +14,8 @@ import copernicus_marine_client as cmc import cftime import getpass +import shutil +import subprocess __all__ = [ "download_ERA5", @@ -329,6 +331,19 @@ def copernicusmarine_credentials(): return username, password +def copernicusmarine_reset(): + print("resetting Copernicus Marine Toolbox, you will have to login again.") + dir_cachier = os.path.expanduser("~/.cachier") + dir_cmc = os.path.expanduser("~/.copernicus-marine-client") + for dir_remove in [dir_cachier, dir_cmc]: + print(f"- removing {dir_remove}") + shutil.rmtree(dir_remove, ignore_errors=True) + print("- overwriting copernicus-marine metadata cache (takes some time)") + subprocess.run("copernicus-marine describe --overwrite-metadata-cache") + print("- updating copernicus-marine-client") + subprocess.run("pip install copernicus-marine-client -U") + + def copernicusmarine_dataset_timerange(dataset_id): ds = cmc.open_dataset(dataset_id=dataset_id) ds_tstart = pd.Timestamp(ds.time.isel(time=0).values) From 8e712c9ce71f951c91d6263ce04870e46cc01ae0 Mon Sep 17 00:00:00 2001 From: veenstrajelmer Date: Mon, 11 Dec 2023 15:39:11 +0100 Subject: [PATCH 2/2] updated whatsnew --- docs/whats-new.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/whats-new.md b/docs/whats-new.md index eb653ecbc..92b43cf67 100644 --- a/docs/whats-new.md +++ b/docs/whats-new.md @@ -1,6 +1,7 @@ ## UNRELEASED ### Feat +- added reset of Copernicus Marine Toolbox with `dfmt.download.copernicusmarine_reset()` by [@veenstrajelmer](https://github.com/veenstrajelmer) in [#685](https://github.com/Deltares/dfm_tools/pull/685) - automatically parse epsg from FM mapfile to crs in `dfmt.open_partitioned_dataset()` by [@veenstrajelmer](https://github.com/veenstrajelmer) in [#685](https://github.com/Deltares/dfm_tools/pull/685) - added spatial/temporal subsetting and retrieving of insitu observation data with `dfmt.ssh_catalog_subset()` and `dfmt.ssh_retrieve_data()` by [@veenstrajelmer](https://github.com/veenstrajelmer) in [#711](https://github.com/Deltares/dfm_tools/pull/711)