API download 'target' not working

exciting that I am able to gather ERA5 data in the beta CDS using the following script, but the target=‘save_to_filename’ does not work. Instead, the downloaded file ends up in the python path from which the download script is run.

this is after updating to the cdsapi using $ pip install ‘cdsapi>=0.7.0’

Anyone explain my issue?

script below

import cdsapi

dataset = “reanalysis-era5-single-levels-monthly-means”

request = {
    'product_type': ['monthly_averaged_reanalysis'],
    'variable': ['2m_temperature'],
    'year': [
        '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', '2022','2023','2024'],
    'month': ['06', '07', '08'],
    'time': ['00:00'],
    'data_format': 'grib',
    'download_format': 'unarchived',
    'area': [90, -180, 0, 180]
}

target = '/Users/jason/0_dat/ERA5/ERA5_t2m_1990-2024.grib'

hi, this worked for me (using cds api 0.7.3), running script in the ‘Downloads’ directory
target=“/Downloads/test_dir/test.grb”
client.retrieve(dataset, request,target)

% ls -lt /Downloads/test_dir
total 395264
-rw-r–r-- 1 - - 199352448 17 Sep 17:12 test.grb

1 Like