Step by step instructions on how to download data using new Climate Data Store Beta (CDS-Beta)

1. New ECMWF account

Your existing CDS credentials will not work in CDS-Beta
You need to have an ECMWF account - register one here

2. Accept all licences

Make sure that you accepted licences in the Download form of the product page

Check it from your profile page. It should be like below image:
image

3. Use Python 3.8 or above

You can check Python version you are using in terminal via
python --version

4. Update the .cdsapirc file

Make sure that you are logged in ECMWF then navigate to the CDSAPI setup page to copy the content for your .cdsapirc file.

url: https://cds-beta.climate.copernicus.eu/api
key: <Your Personal Access Token>

NOTE that in new version of the file there is no [UID:] part in the key
You can also find your Personal Access Token in your profile page.

6. Install CDS API client version 0.7 or above

Install the CDS API client is a Python based library (version 0.7 or above) using
pip install 'cdsapi>=0.7.0'

7. Test sample download

  import cdsapi

  client = cdsapi.Client()
  
  dataset = 'reanalysis-era5-pressure-levels'
  request = {
      'product_type': ['reanalysis'],
      'variable': ['geopotential'],
      'year': ['2024'],
      'month': ['03'],
      'day': ['01'],
      'time': ['13:00'],
      'pressure_level': ['1000'],
      'data_format': 'grib',
  }
  target = 'download.grib'
  
  client.retrieve(dataset, request, target)

Hope this helps. You can get more useful information from:

  1. CDS and ADS migrating to new infrastructure: Common Data Store (CDS) Engine
  2. CDSAPI setup.
3 Likes

I tried and it worked with Python 3.9.6

Thanks @Odil_Dasturlovchi for these instructions. I have a few questions/suggestions that might help improving the user experience.

Is the https://cds-beta.climate.copernicus.eu/api URL final or will it change in a few weeks if it is not beta anymore?

If one does not accept the copernicus product license they get a confusing error, can this be replaced with one that is more insightful? CDS beta raises incorrect error about accepting licenses · Issue #108 · ecmwf/cdsapi · GitHub

Furthermore, the ~/.cdsapirc file is ok to work with, but would it not just be possible to promt for user credentials if the file does not exist (or its contents are invalid), after which the cdsapi toolbox generates/retrieves the apikey and saves the ~/.cdsapirc file?

Hi, @Jelmer_Veenstra ,

According to @Anabelle

You will not have to update the URL in your .cdsapirc files in the immediate future. …there should be no impact to users when we switch from CDS-Beta to CDS in September as both CDS-Beta and CDS urls will continue to co-exist for longer

I

I agree, we can suggest it via Support Portal

If you have not set up your CDS API credentials with a ~/.cdsapirc file, it is still possible to provide the credentials when initialising the cdsapi.Client. like here:

# If you have not set up your CDS API credentials with a ~/.cdsapirc file,
# it is possible to provide the credentials when initialising the cdsapi.Client.

if os.path.isfile("~/.cdsapirc"):
    cdsapi_kwargs = {}
else:
    URL = 'https://cds.climate.copernicus.eu/api/v2'
    KEY = '##################################'
    cdsapi_kwargs = {
        'url': URL,
        'key': KEY,
    }

I borrowed it from the tutorials.

Thanks for you relaborate response, very helpful.

I already suggested it in [CUS-25567] and CDS beta raises incorrect error about accepting licenses · Issue #108 · ecmwf/cdsapi · GitHub

@Odil_Dasturlovchi how to change the request for netcdf file and specific grid resolution?

Duplicated post, deleted.

'data_format': 'netcdf',
# if you are looking sub-region extraction 
'area': [90, -180, -90, 180]
# if you are looking to grid (interpolated)
'grid': '0.5/0.5',
# for original grid
# 'grid': 'original_grid',

Hope this helps.

1 Like

thnx @Odil_Dasturlovchi