Hello,
I’m trying to download the ERA5-Land post-processed daily statistics from 1950 to the present using the CDS API, but I’m encountering an authentication error. Below is the code I used in a Colab environment:
pip install --upgrade cdsapi
!echo “url: https://cds.climate.copernicus.eu/api” > ~/.cdsapirc
!echo “key: ” >> ~/.cdsapirc
I replaced <my key>
with the API Token from my profile.
Then, I created the .cdsapirc
file in Colab as follows:
api_key = “”
with open(‘/root/.cdsapirc’, ‘w’) as f:
f.write(f"url: https://cds.climate.copernicus.eu/api\nkey: {api_key}")
Here’s the script I used to download the data:
import cdsapi
dataset = “derived-era5-land-daily-statistics”
request = {
“variable”: [“2m_temperature”],
“year”: “1960”,
“month”: “01”,
“day”: [“01”, “02”, “03”, “04”, “05”, “06”, “07”, “08”, “09”, “10”, “11”, “12”, “13”, “14”, “15”, “16”, “17”, “18”, “19”, “20”, “21”, “22”, “23”, “24”, “25”, “26”, “27”, “28”, “29”, “30”, “31”],
“daily_statistic”: “daily_minimum”,
“time_zone”: “utc+00:00”,
“frequency”: “6_hourly”,
“area”: [51, -5, 41, 10]
}
client = cdsapi.Client()
client.retrieve(dataset, request).download()
However, I’m getting the following error:
HTTPError: 401 Client Error: Unauthorized for url: https://cds.climate.copernicus.eu/api/retrieve/v1/processes/derived-era5-land-daily-statistics/execution
Authentication failed
operation not allowed
I’ve logged into CDS and double-checked my API Token, but I still can’t figure out why it’s not working.
Could anyone help me identify what I might be missing or doing wrong?
Thank you in advance!