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

Update to copernicus-marine-client #630

Closed
14 tasks done
veenstrajelmer opened this issue Nov 2, 2023 · 0 comments · Fixed by #691
Closed
14 tasks done

Update to copernicus-marine-client #630

veenstrajelmer opened this issue Nov 2, 2023 · 0 comments · Fixed by #691

Comments

@veenstrajelmer
Copy link
Collaborator

veenstrajelmer commented Nov 2, 2023

Update to https://pypi.org/project/copernicus-marine-client/ instead of opendap (requires py>=3.9), now in open beta, but goes into service in Q1 2024. Shutdown of legacy services (like opendap) is planned in March 2024, but some opendap datasets are already deprecated from 30 November 2023.

Howto from https://help.marine.copernicus.eu/en/articles/8283072-copernicus-marine-client-api-subset:

import os
# pip install copernicus-marine-client
import copernicus_marine_client as cmc

# retrieving catalog
# catalog = copernicus_marine.describe(include_datasets=True)

# optionally provide username/password via environment variables
# if not set, the tool queries username/password
# but when embedding it into another tool it is not clear what for, an introduction text would be useful
# os.environ["COPERNICUS_MARINE_SERVICE_USERNAME"] = ""
# os.environ["COPERNICUS_MARINE_SERVICE_PASSWORD"] = ""

lon_min, lon_max, lat_min, lat_max = -68.55, -67.9, 11.8, 12.6

dataset = cmc.open_dataset(
     dataset_id = "cmems_mod_glo_phy-cur_anfc_0.083deg_PT6H-i",
     variables = ['uo', 'vo'],
     minimum_longitude = lon_min,
     maximum_longitude = lon_max,
     minimum_latitude = lat_min,
     maximum_latitude = lat_max,
     minimum_depth = 0,
     maximum_depth = 30,
     start_datetime = "2022-01-01 00:00:00",
     end_datetime = "2022-01-01 23:00:00",
)

output_filename = "CMEMS_Bonaire_currents_2022-01.nc"
dataset.to_netcdf(output_filename)

Todo:

  • Can only be added for python>=3.9. So drop py38 support or add check in download code that this function is only available for python>=3.9
  • duplication (replace old function with new one)
  • add copernicus-marine-client<0.10.0 as dependency
  • solve code smells
  • simplify authentication via cmc functions
  • also support custom dataset_id, skip some steps in that case
  • maybe get resolution/buffer
  • times of api datasets are at midnight due to subset, so dfmt.round_timestamp_to_outer_noon can be simplified
  • check if pre-processing works (e.g. with modelbuilder)
  • add testcase for cmems forecast (tstart/tstop at now and now+1D)
  • add testcase voor hycom/opendap
  • Solve the issues with the global product variable when changing timeframe in same python instance. For the testbank to work, we now remove it in test_download.py. Move to global time extents instead.
  • make copernicusmarine_credentials() return credentials, gtsm cmems retrieval currently depends on it
  • suggest copernicusmarine_credentials() as new feature for copernicus-marine-client

Follow up issues: #694 and #692

@veenstrajelmer veenstrajelmer changed the title Consider update to copernicus-marine-client Update to copernicus-marine-client Nov 3, 2023
This was referenced Nov 3, 2023
@veenstrajelmer veenstrajelmer linked a pull request Dec 6, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant