下载ERA5-Land数据及数据处理(每小时转日数据)_是一个橙子呀的博客-CSDN博客_cdsapi怎么安装
ERA5逐日资料下载方法-数据资料-气象家园_气象人自己的家园
ERA5数据下载和批处理教程_江湖是你画中亦是你的博客-CSDN博客_era-5shujuchuli
利用python批量下载ERA5-Daily数据_可乐要加冰_ice的博客-CSDN博客_era5 数据下载
ERA5逐日资料下载方法-数据资料-气象家园_气象人自己的家园
How to install and use CDS API on Windows - Copernicus Knowledge Base - ECMWF Confluence Wiki
# -*- coding: utf-8 -*-
"""
@author:hangsirm
"""
import time
import cdsapi
import requests
import multiprocessing
# CDS API script to use CDS service to retrieve daily ERA5* variables and iterate over
# all months in the specified years.
# Requires:
# 1) the CDS API to be installed and working on your system
# 2) You have agreed to the ERA5 Licence (via the CDS web page)
# 3) Selection of required variable, daily statistic, etc
# Output:
# 1) separate netCDF file for chosen daily statistic/variable for each month
# Uncomment years as required
# For valid keywords, see Table 2 of:
# https://datastore.copernicus-climate.eu/documents/app-c3s-daily-era5-statistics/C3S_Application-Documentation_ERA5-daily-statistics-v2.pdf
# select your variable; name must be a valid ERA5 CDS API name.
# Select the required statistic, valid names given in link above
c = cdsapi.Client() # timeout=300
years = [str(id1) for id1 in range(2013, 2014)]
# months = ['%02d' % id2 for id2 in range(1, 13)]
months = ['01', '02', '12']
# var = "2m_temperature"
# 下载的数据类型
stat = "daily_mean"
# vars = ['2m_temperature', 'soil_temperature_level_1', 'snow_density']
vars = ['2m_temperature', 'soil_temperature_level_1']
def Download(iyear, imonth, var):
t000 = time.time()
result = c.service(
"tool.toolbox.orchestrator.workflow",
params={
"realm": "c3s",
"project": "app-c3s-daily-era5-statistics",
"version": "master",
"kwargs": {
"dataset": "reanalysis-era5-land",
"product_type": "reanalysis",
"variable": var,
"statistic": stat,
"year": iyear,
"month": imonth,
"time_zone": "UTC+00:0",
"frequency": "1-hourly",
#
# Users can change the output grid resolution and selected area
#
"grid": "0.1/0.1", # 10km分辨率
"area": {
"lat": [24, 41],
"lon": [64, 106]
}
},
"workflow_name": "application"
}
)
# set name of output file for each month (statistic, variable, year, month
file_name = r"G:\ERA5\\" + stat + "_" + var + iyear + imonth + ".nc"
location = result[0]['location']
res = requests.get(location, stream=True)
print("Writing data to " + file_name)
with open(file_name, 'wb') as fh:
for r in res.iter_content(chunk_size=1024):
fh.write(r)
fh.close()
print('***样本%s 保存结束, 耗时: %.3f s / %.3f mins****************' % (
file_name, (time.time() - t000), (time.time() - t000) / 60))
if __name__ == "__main__":
t0 = time.time()
# ===================================================================================
print('*****************程序开始*********************')
for v in vars:
for yr in years:
for mn in months:
Download(yr, mn, v)
print('***********************程序结束, 耗时: %.3f s / %.3f mins****************' % (
(time.time() - t0), (time.time() - t0) / 60))
代码注意事项:
1、变量命名,2m_temperature不能是2m temperature,下划线不能改成空格
2、在user下要有cdsapirc文件
处理好的文件是nc格式,在arcgis中打开只显示一个波段,并且看不到有哪些数据集,要在ENVI中打开,可以用IDL处理为单波段
for b = 0, dim[3] - 1 do begin
data_wind2 = fltarr(dim[1],dim[2])
for m = 0,dim[1]-1 do begin
for n = 0,dim[2]-1 do begin
temp = data_wind[*,*,b]
data_wind2[m,n] = temp[m,abs(n-dim[2]+1)];南北颠倒
endfor
endfor
write_tiff,'G:\ERA5Test\'+tifname+string(b+1,format='(i2.2)')+'.tif',data_wind2,geotiff=geo,/FLOAT
;write_tiff,'E:\wdtif\'+tifname+'_tair.tif',data_wind,geotiff=geo,/FLOAT;图像是倒置的
print,'G:\ERA5Test\'+tifname+string(b+1,format='(i2.2)')+'.tif'+" is ok!"
endfor