Hi Leo,
I think it was a temporary issue with the daily application on the CDS. The "realm" line should be
"realm": "user-apps" as in the example above.
This script works for me:
% more workflow.py
import cdsapi
import requests
# CDS API script to use CDS service to retrieve daily ERA5* variables and iterate over
# all months in the specified years.
# Requires:
# 1) the CDS API to be installed and working on your system
# 2) You have agreed to the ERA5 Licence (via the CDS web page)
# 3) Selection of required variable, daily statistic, etc
# Output:
# 1) separate netCDF file for chosen daily statistic/variable for each month
c = cdsapi.Client(timeout=300)
# Uncomment years as required
years = [
'1979'
# ,'1980', '1981',
# '1982', '1983', '1984',
# '1985', '1986', '1987',
# '1988', '1989', '1990',
# '1991', '1992', '1993',
# '1994', '1995', '1996',
# '1997', '1998', '1999',
# '2000', '2001', '2002',
# '2003', '2004', '2005',
# '2006', '2007', '2008',
# '2009', '2010', '2011',
# '2012', '2013', '2014',
# '2015', '2016', '2017',
# '2018', '2019', '2020',
# '2021'
]
# Retrieve all months for a given year.
months = ['01', '02', '03',
'04', '05', '06',
'07', '08', '09',
'10', '11', '12']
# For valid keywords, see Table 2 of:
# select your variable; name must be a valid ERA5 CDS API name.
var = "surface_net_solar_radiation"
# Select the required statistic, valid names given in link above
stat = "daily_mean"
# Loop over years and months
for yr in years:
for mn in months:
result = c.service(
"tool.toolbox.orchestrator.workflow",
params={
"realm": "user-apps",
"project": "app-c3s-daily-era5-statistics",
"version": "master",
"kwargs": {
"dataset": "reanalysis-era5-single-levels",
"product_type": "reanalysis",
"variable": var,
"statistic": stat,
"year": yr,
"month": mn,
"time_zone": "UTC+00:0",
"frequency": "1-hourly",
#
# Users can change the output grid resolution and selected area
#
# "grid": "1.0/1.0",
# "area":{"lat": [10, 60], "lon": [65, 140]}
},
"workflow_name": "application"
})
# set name of output file for each month (statistic, variable, year, month
file_name = "download_" + stat + "_" + var + "_" + yr + "_" + mn + ".nc"
location=result[0]['location']
res = requests.get(location, stream = True)
print("Writing data to " + file_name)
with open(file_name,'wb') as fh:
for r in res.iter_content(chunk_size = 1024):
fh.write(r)
fh.close()
which gives:
% python3 workflow.py
2023-03-29 14:39:23,123 INFO Welcome to the CDS
2023-03-29 14:39:23,123 INFO Sending request to https://cds.climate.copernicus.eu/api/v2/tasks/services/tool/toolbox/orchestrator/workflow/clientid-ca92e3febe0b49d18d70984583f3a282
2023-03-29 14:39:23,194 INFO Request is queued
2023-03-29 14:53:44,946 INFO Request is running
2023-03-29 14:55:45,209 INFO Request is completed
Writing data to download_daily_mean_surface_net_solar_radiation_1979_01.nc
2023-03-29 14:56:08,137 INFO Welcome to the CDS
2023-03-29 14:56:08,137 INFO Sending request to https://cds.climate.copernicus.eu/api/v2/tasks/services/tool/toolbox/orchestrator/workflow/clientid-0d0746c3abb8414894ce6abf2d263c53
2023-03-29 14:56:08,209 INFO Request is queued
2023-03-29 15:22:29,376 INFO Request is running
2023-03-29 15:24:29,630 INFO Request is completed
Writing data to download_daily_mean_surface_net_solar_radiation_1979_02.nc
..etc
(The ERA5-Land accumulated parameters have been removed from the app as it is fairly straightforward to derive these from the dataset)
Hope that helps,
Kevin