I am trying to download ERA5 daily statistics from hourly ones with the ERA5 daily statistics calculator. Since I need multiple years and months I am using API. Following the instruction in the documentation. I created the following python script:
import cdsapi
c = cdsapi.Client()
YEARS = [
"1991", "1992"
]
MONTHS = [
"01", "02", "03"
]
for year in YEARS:
for month 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": "2m_temperature",
"statistic": "daily_minimum",
"year": year,
"month": month,
"time_zone": "UTC+00:00",
"frequency": "1-hourly",
"grid": "0.25/0.25",
"area": {"lat": [-90, 90], "lon": [-180, 180]}
},
"workflow_name": "application"
},
)
c.download(result)
The downloaded files have a default name that is not explicative. I would like to specify the file name like Tmin_year_month.nc
You just need to pass the desired filename as the second argument to the download function:
file="my_output_file.nc"
c.download(result,[file])
NOTE! Unlike the normal api for data, the second argument needs to be a list, otherwise the download procedure will take [0] of the filename string and return the file called "m" in my example. I already flagged this to ECMWF as a feature (bug!) to be corrected. I also mentioned that they could add this to the Wiki.