I want to download agrERA5 data using target to assign a custom file name and not have unzip after download.
When I use client.retrieve(dataset, request).download()
it downloads successfully and results in a .zip with a single netcdf in it.
If I use client.retrieve(dataset, request, target)
, the resulting .nc file is corrupted, I cannot open it on Panoply or read it with ncdump.
Here’s my code:
import cdsapi
client = cdsapi.Client()
dataset = "sis-agrometeorological-indicators"
basedir='path/to/folder'
request = {
"variable": "precipitation_flux",
"year": ["1979"],
"month": [
"01",
# "02", "03",
# "04", "05", "06",
# "07", "08", "09",
# "10", "11", "12"
],
"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"
],
"version": "1_1",
"area": [38, -18, -35, 52],
"data_format": "netcdf", # I've tried with and without this line
}
target = basedir + "precipitation_flux_1979_01_01.nc"
client.retrieve(dataset, request, target)
# client.retrieve(dataset, request).download()