气象海洋数据下载——ERA5再分析——CDS-python

编程入门 行业动态 更新时间:2024-10-25 19:33:43

1、 欧洲中期天气预报中新ERA5再分析数据简介

下载网址
ERA5是一种综合性的再分析数据,ECMWF的Integrated Forecast System (IFS)的4D-Var data assimilation 和 CY41R2 模型预报产生的。ERA5数据集包含一个高分辨率(hourly,31km,0.2815degrees,“HRES”)和一个分辨率降低的十个集合(hourly,63km,0.5625degrees,“EDA”)。ERA5大气模型与陆面模型和波浪模型耦合,支持1979-至今的实时数据。
ERA5ERA5提供大量大气、陆地和海洋气候变量的每小时估计。这些数据以30公里的网格覆盖地球,并利用从地表到80公里高度的137层来解析大气。ERA5包含所有变量在降低的空间和时间分辨率下的不确定性信息。
数据产品类型:
Analyses:再分析数据、Ensemble members:、Ensemble mean:总平均值

2、 数据集

1、Popular


10m u-component of wind:10米U行风量
10m v-component of wind:10米v行风量
2m dewpoint temperature:2米露点温度
2m temperature:2米温度
Mean sea level pressure:平均海平面气压
Mean wave direction:平均波方向
Mean wave period:平均波周期
Sea surface temperature:海洋表面温度
Significant height of combined wind waves and swelll:综合风浪和风浪的显著高度
Surface pressure:表面压力
Total precipitation:总降水量

2、Popular


Ice temperature layer 1:冰层温度
Maximum 2m temperature since previous post-processing:自上次后处理以来最高2m的温度
Skin temperature:表层温度

3、Wind


10m u-component of neutral wind:10m u中风

4、Mean rates

4、Radiation and heat(辐射和热)

5、Clouds(云)

6、Lakes(湖)

7、蒸发和径流

8、降水和雨

9、雪

9、

10、垂直积分

11、植被

12、海浪

14、其他

3、CDS API数据下载

参考博客
Key获取

再分析单个文件下载:

import cdsapi
c = cdsapi.Client()
c.retrieve("reanalysis-era5-pressure-levels",
{
"variable": "temperature",
"pressure_level": "1000",
"product_type": "reanalysis",
"year": "2008",
"month": "01",
"day": "01",
"time": "12:00",
"format": "grib"
}, "download.grib")

冰川单个文件下载:

import cdsapi
c = cdsapi.Client()
c.retrieve("insitu-glaciers-elevation-mass",
{
"variable": "all",
"product_type": "elevation_change",
"file_version": "20170405",
"format": "tgz"
},
"download.tar.gz")

cds 多进行批量下载

'''
Author: your name
Date: 2021-07-22 08:42:25
LastEditTime: 2021-07-23 15:18:56
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath: \Test\Python-book-BK\Python-book-BK\code\chap4\chap4_batch_download_cds_nc_files.py
'''
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@毕凯,北京市人工影响天气办公室
@ email: bikai_picard@vip.sina 
"""
import os
os.chdir(r"D:\Python base\Test\BIKAI_books") 
os.getcwd()
import cdsapi 
import datetime as dt 
from queue import Queue 
from threading import Thread #导入多线性编程最核心的模块,进行并发下载,每个Threading代表一个线程
import time 
start =time.clock()

class DownloadCDS(Thread): 
   def __init__(self, queue): 
       Thread.__init__(self)
       self.queue = queue 
   def run(self):
       while True:
           #从队列中获取任务并扩展
           date_file_name = self.queue.get() #获取任务,并使用get从另一端删除。
           download_single_cds_file(date_file_name)
           self.queue.task_done() #告知队列该任务已完成

def download_single_cds_file(date_file_name):
    filename=date_file_name+'.nc' 
    if(os.path.isfile(filename)): 
      print("当前数据文件已经存在: ",filename) 
    else:
      print("当前正在下载:",filename)
      c = cdsapi.Client() 
      c.retrieve(
          'reanalysis-era5-pressure-levels', 
          {
              'product_type' : 'reanalysis',
              'format'       : 'netcdf', #数据格式,可以是grib
              'variable': ['geopotential', 'relative_humidity','temperature','u_component_of_wind', 'v_component_of_wind', 'vertical_velocity'],
              'pressure_level': ['100','150','200','250', '300', '350','400', '450', '500','550', '600', '650','700', '750', '775','800', '825', '850','875', '900', '925','950', '975', '1000'], #输入压力高度                     
              'year' : date_file_name[0:4], 
              'month': date_file_name[-4:-2], 
              'day'  : date_file_name[-2:], 
              'time':['00:00','08:00','14:00','20:00'], #时刻
              'area': [70, 90, 30, 130], 
              'grid': [0.5, 0.5], 
          },         
          filename) #filename,数据存储的文件

    # #冰川数据下载
    # c.retrieve("insitu-glaciers-elevation-mass",
    #     {
    #     "variable": "all",
    #     "product_type": "elevation_change",
    #     "file_version": "20170405",
    #     "format": "tgz"
    #     },
    #     "download.tar.gz")

if __name__ == '__main__': 
    
    file_numbers_at_same_time=4  
    start_date ='2019-01-01' #开始时间
    end_date ='2019-01-05'   #结束时间
    start_date_result=dt.datetime.strptime(start_date,'%Y-%m-%d')
    end_date_result=dt.datetime.strptime(end_date,'%Y-%m-%d')
    print("start_date_result",start_date_result)
 
    file_gap_time = dt.timedelta(days=1) #下载日期间隔,以天为单位
    print('下载文件开始日期 : '+ start_date)

    date_list_download=[] #需要下载数据得时间列表
    while start_date_result <= end_date_result: 
        date_file_name=start_date_result.strftime("%Y%m%d") #调整日期得显示格式
        
        date_list_download.append(str(date_file_name))
        start_date_result =start_date_result +file_gap_time
    
    #创建一个主进程和工作线程,初始化进程对象,容量不设上限
    single_queue = Queue() #FOFO队列,其添加得第一个任务是检索得任务

    for i in range(file_numbers_at_same_time): 
        single_task = DownloadCDS(single_queue)
        single_task.daemon = True
        single_task.start()     

    for ii in date_list_download:
        single_queue.put((ii))  #使用put将元素添加到序列的一个“末端”
    single_queue.join() #处理完了所有线程
   
end = time.clock()
print('>>> Total running time: %s Seconds'%(end-start))

更多推荐

气象海洋数据下载——ERA5再分析——CDS-python

本文发布于:2023-06-10 16:29:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/620851.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:气象   海洋   数据   python   CDS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!