Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added copernicusmarine_reset #714

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading