Hi Luke,
Thanks for your reply.
I am trying to download the 3-hourly CAMS aerosol data at all 60 model-levels from 2009 to 2019.
Since there is a limit for requesting the data, I have modified the API script to loop over each month of each year.
The issue is that all model levels are downloaded if I request only a single hour for a single day (00:00, for example), without the loop.
but when I request all the timesteps, only model level 1 is downloaded. I do not understand why this is so.
Only a manual submit form request works for a single month for all times for all model levels. But this is not a feasible method for downloading over 10 years of data.
Please see my API request pasted below. It only downloads hybrid : levels=1. whereas I have requested all 60.
I’d appreciate any suggestions/help!
import cdsapi
import datetime
# Initialize the CDS API client
client = cdsapi.Client()
# Define the dataset
dataset = "cams-global-reanalysis-eac4"
# Define the date range
start_date = datetime.datetime(2009, 1, 1)
end_date = datetime.datetime(2010, 12, 31)
# Loop through each day in the date range
while start_date <= end_date:
# Format the current date
current_date_str = start_date.strftime('%Y-%m-%d')
# Update the request dictionary with the current date
request = {
'variable': [
'dust_aerosol_0.03-0.55um_mixing_ratio', 'dust_aerosol_0.55-0.9um_mixing_ratio',
'dust_aerosol_0.9-20um_mixing_ratio', 'hydrophilic_black_carbon_aerosol_mixing_ratio',
'hydrophilic_organic_matter_aerosol_mixing_ratio', 'hydrophobic_black_carbon_aerosol_mixing_ratio',
'hydrophobic_organic_matter_aerosol_mixing_ratio', 'sea_salt_aerosol_0.03-0.5um_mixing_ratio',
'sea_salt_aerosol_0.5-5um_mixing_ratio', 'sea_salt_aerosol_5-20um_mixing_ratio',
'specific_humidity', 'temperature'
],
'model_level': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19','20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39','40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59','60'],
'date': current_date_str, # Only request data for the current day
'time': ['00:00', '03:00', '06:00', '09:00', '12:00', '15:00', '18:00', '21:00'],
'format': 'grib'
}
# Construct the file name based on the current date
file_name = '{}.grib'.format(current_date_str)
# Perform the data retrieval and download
print(f"Downloading data for {current_date_str}...")
client.retrieve(dataset, request).download(file_name)
# Move to the next day
start_date += datetime.timedelta(days=1)