import calendar
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
import cdsapi
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
c = cdsapi.Client()
for i in range(1979,2024):
c.retrieve(
'reanalysis-era5-pressure-levels',
{
'product_type': 'reanalysis',
'variable': [
'v_component_of_wind',
],
'pressure_level': [
'925' ,
],
'year': str(i),
'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',
],
'time': [
'00:00', '06:00', '12:00',
'18:00',
],
'format': 'netcdf',
'area': [
90, -180, -90,
180,
],
},
'E:\\data\\era5\\v\\v925\\v925_1979to2023_'+str(i)+'.nc')
存在的问题:如何并行提高速度,多开几个?
不做循环直接 下载的代码
import cdsapi
c = cdsapi.Client()
c.retrieve(
'reanalysis-era5-pressure-levels',
{
'product_type': 'reanalysis',
'variable': 'v_component_of_wind',
'pressure_level': '850',
'year': [
'2003',
'2004', '2005', '2006',
'2007', '2008', '2009',
'2010', '2011', '2012',
'2013', '2014', '2015',
'2016', '2017', '2018',
'2019', '2020', '2021',
'2022', '2023',
],
'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',
],
'time': '00:00',
'format': 'netcdf',
},
'data/v850.nc')