diff --git a/dfm_tools/download.py b/dfm_tools/download.py index b4205cbf6..11352c939 100644 --- a/dfm_tools/download.py +++ b/dfm_tools/download.py @@ -34,7 +34,7 @@ def download_ERA5(varkey, cds_credentials() # import cdsapi and create a Client instance # https://cds.climate.copernicus.eu/api-how-to - c = cds_client_withargs() + c = cdsapi.Client() #dictionary with ERA5 variables #this is not actively used variables_dict = {'ssr':'surface_net_solar_radiation', @@ -116,7 +116,7 @@ def cds_credentials(): try: # checks whether CDS apikey is in environment variable or ~/.cdsapirc file and if it is in correct format - c = cds_client_withargs() + c = cdsapi.Client() # checks whether credentials (uid and apikey) are correct c.retrieve(name="dummy", request={}) except Exception as e: @@ -164,17 +164,6 @@ def cds_remove_credentials(): os.remove(file_cds_credentials) -def cds_client_withargs(): - """ - Initialize a csdapi client with url and key from os environment variables - These are the default values for the url/key arguments, but somehow this - is necessary to use the key/url from environment variables. - """ - c = cdsapi.Client(url=os.environ.get("CDSAPI_URL"), - key=os.environ.get("CDSAPI_KEY")) - return c - - def download_CMEMS(varkey, longitude_min, longitude_max, latitude_min, latitude_max, date_min, date_max, freq='D', diff --git a/pyproject.toml b/pyproject.toml index f12961cb4..85d7ce746 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,8 +38,8 @@ dependencies = [ "bottleneck>=1.3.3", #xugrid<0.9.0 does not support partitioned 1d2d grids "xugrid>=0.9.0", - #cdsapi<0.6.1 is from Feb 2021 and does not support newer python versions - "cdsapi>=0.6.1", + #cdsapi<0.7.0 supports credentials from environment variables + "cdsapi>=0.7.0", #pydap<3.4.0 is from May 2017 and does not support newer python versions "pydap>=3.4.0", #erddapy<2.0.0 does not support pandas>=2.0.0