I can not find any examples on how to download data with specified name for new API. When I put ‘target’ key into the cdsapi.Client().retrieve(), I get the error message saying I am using deprecated API endpoint. What is the proper way of downloading a file with a specified file name? Thanks.
Hi.
Are you using the latest cdsapi?
is your .cdsapirc file correct?
Does the example request from Climate Data Store work for you?:
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)
Also consider checking if your system uses the correct key by setting it (temporarily) in you retrieval script by using:
ALternative options: Is there elsewhere to put the .cdsapirc file? Running it on Databricks
Yes. I believe I am using CDSAPI version 0.7.3 off of pypi.
Ahh… I just realized that I was using the following and getting the error message.
client.retrieve(dataset, request, target).download()
.download() part was giving me the problem.
Everything is working fine now. Thanks.