Skip to content

Commit

Permalink
added copernicusmarine_reset (#714)
Browse files Browse the repository at this point in the history
* added copernicusmarine_reset

* updated whatsnew
  • Loading branch information
veenstrajelmer authored Dec 11, 2023
1 parent 06742b0 commit 08af61c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions dfm_tools/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import copernicus_marine_client as cmc
import cftime
import getpass
import shutil
import subprocess

__all__ = [
"download_ERA5",
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions docs/whats-new.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down

0 comments on commit 08af61c

Please sign in to comment.