下载ERA5数据
从官网上下载ERA5主要分为三步:
- 官网注册账号,获取CDS API key。
- 安装python相关的库。
- 复制粘贴代码,下载数据。
注册账户获取密钥
点击网址:ERA5注册网址,右上角点击注册账户,一般使用教育邮箱
注册完成后登录,然后还是在这个网址:获取key密钥,点击下面图中的红色框,
然后,下图红框内就是你的密钥,将其全部复制下来:
如果你是Linux系统,就在你的系统用户目录下创建一个.cdsapirc
的文件,将刚刚复制的内容粘贴到该文件下:
- 如果你是windows系统,就在c盘/用户/用户名 这个目录下创建一个 创建一个
.cdsapirc
文件。可以先建立一个txt文件,将内容粘贴进去后再改文件名为.cdsapirc
。
安装python的cdsapi库
我这里是在Linux系统下, 直接在你的python环境下使用命令:conda install cdsapi
即可。window下应该同理。
获取ERA5数据
下载地址在官网上搜索你要下载的数据类型:
点击进入后勾选你需要的参数、时间、变量等。
然后到最后,选择红框内显示下载代码
将代码复制到你的python脚本中,运行脚本即可下载。
运行WRF模式
基于上述方式,我们可以通过下载ERA5数据制作WRF模式的初始场,运行wrf模式。其中,需要下载的ERA5的数据如下所示:
3D数据:
ERA5 monthly averaged data on pressure levels from 1979 to present**:Monthly averaged reanalysis by hour of day**
变量:
- Geopotential
- Relative humidity
- U-component of wind
- V-component of wind
- Temperature
压力层
所有
year
2022
month
02
day
17-18
Pressure level data (download.py)
import cdsapi c = cdsapi.Client() c.retrieve( 'reanalysis-era5-pressure-levels', { 'product_type': 'reanalysis', 'format': 'grib', 'variable': [ 'geopotential', 'relative_humidity', 'temperature','specific_humidity', 'u_component_of_wind', 'v_component_of_wind','vertical_velocity' ], 'pressure_level': [ '1', '2', '3', '5', '7', '10', '20', '30', '50', '70', '100', '125', '150', '175', '200', '225', '250', '300', '350', '400', '450', '500', '550', '600', '650', '700', '750', '775', '800', '825', '850', '875', '900', '925', '950', '975', '1000', ], 'year': '2022', 'month': '02', 'day': ['17','18',], 'time': [ '00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00', ], }, '/ERA5_data/ERA5-2022-02_17-18_pl.grib')
2D数据:
Product type
Monthly averaged reanalysis by hour of day
Variable
- 10m u-component of wind
- 10m v-component of wind
- Mean sea level pressure
- Sea surface temperature
- Surface pressure
- 2m temperature
- Soil data (temperature and moisture) and soil height
year
2021
month
02
day
17-18
Single level data (down.py)
import cdsapi c = cdsapi.Client() c.retrieve( 'reanalysis-era5-single-levels', { 'product_type': 'reanalysis', 'format': 'grib', 'variable': [ '10m_u_component_of_wind','10m_v_component_of_wind','2m_dewpoint_temperature', '2m_temperature','forecast_albedo', 'forecast_surface_roughness','high_cloud_cover', 'land_sea_mask','low_cloud_cover', 'mean_sea_level_pressure','medium_cloud_cover', 'sea_ice_cover','sea_surface_temperature', 'skin_temperature','snow_albedo', 'snow_depth','surface_pressure', 'total_cloud_cover', 'total_column_water','total_column_water_vapour', 'soil_temperature_level_1','soil_temperature_level_2', 'soil_temperature_level_3','soil_temperature_level_4','volumetric_soil_water_layer_1','volumetric_soil_water_layer_2', 'volumetric_soil_water_layer_3','volumetric_soil_water_layer_4' ], 'year': '2022', 'month': '02', 'day': ['17','18',], 'time': [ '00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00', ], }, '/ERA5_data/ERA5-2022-02_17-18-sl.grib')
具体细节的运行可以看这篇博客:
https://blog.csdn.net/weixin_44237337/article/details/123152177?spm=1001.2014.3001.5501
下面只介绍不同的地方
WPS前处理
链接Vtable这里需要进行修改,如下:
cd /Users/WRF/ERA_practice/ ln -sf ungrib/Variable_Tables/Vtable.ECMWF Vtable
然后同样是链接你下载的ERA5数据:
./link_grib.csh ../ERA5_data/ERA5-2022-02_17-18*
ungrid
因为我这个里是三层嵌套,需要修改namelist.wps后,再运行ungrid程序
&share wrf_core = 'ARW', start_date = '2022-02_17_00:00:00','2022-02_17_00:00:00','2022-02_17_00:00:00', end_date = '2022-02_17_06:00:00','2022-02_17_06:00:00','2022-02_17_06:00:00', interval_seconds = 10800, max_dom = 3, io_form_geogrid = 2, opt_output_from_geogrid_path = '/WRF/ERA5_pactice/', / ./ &geogrid parent_id = 1, 1, 2, parent_grid_ratio = 1, 3, 3, i_parent_start = 1, 21, 27, j_parent_start = 1, 21, 26, e_we = 247, 574, 1471, e_sn = 158, 370, 889, geog_data_res = 'default','default','default', dx = 36000, dy = 36000, map_proj = 'mercator', ref_lat = 15.00, ref_lon = 0.00, truelat1 = 10.0, truelat2 = 20.0, stand_lon =0.00, geog_data_path = '/Software/Models/WRF/WPS_GEOG', ! !!!!!!!!!!!!!!!!!!!!!!!!!!!! IMPORTANT NOTE !!!!!!!!!!!!!!!!!!!!!!!!!!!! ! The default datasets used to produce the MAXSNOALB and ALBEDO12M ! fields have changed in WPS v4.0. These fields are now interpolated ! from MODIS-based datasets. ! ! To match the output given by the default namelist.wps in WPS v3.9.1, ! the following setting for geog_data_res may be used: ! ! geog_data_res = 'maxsnowalb_ncep+albedo_ncep+default', 'maxsnowalb_ncep+albedo_ncep+default', ! !!!!!!!!!!!!!!!!!!!!!!!!!!!! IMPORTANT NOTE !!!!!!!!!!!!!!!!!!!!!!!!!!!! ! / &ungrib out_format = 'WPS', prefix = '/WRF/ERA5_pactice/FILE', / &metgrid fg_name = 'FILE', io_form_metgrid = 2, opt_output_from_metgrid_path = '/WRF/ERA5_pactice/', /
下面正常运行./geogrid.exe
、./metgrid.exe
WRF后处理
修改一下namelist.input
,与wps
中的一致:
&time_control run_days = 0, run_hours = 06, run_minutes = 0, run_seconds = 0, start_year = 2022, 2022, 2022, start_month = 02, 02, 02, start_day = 17, 17, 17, start_hour = 00, 00, 00, end_year = 2022, 2022, 2022, end_month = 02, 02, 02, end_day = 17, 17, 17, end_hour = 06, 06, 06, interval_seconds = 10800, input_from_file = .true.,.true.,.true., history_interval = 60, 60, 60, frames_per_outfile = 1000, 1000, 1000, restart = .false., restart_interval = 1440, io_form_history = 2 io_form_restart = 2 io_form_input = 2 io_form_boundary = 2 / &domains time_step = 60, time_step_fract_num = 0, time_step_fract_den = 1, max_dom = 3, i_parent_start = 1, 21, 27, j_parent_start = 1, 21, 26, e_we = 247, 574, 1471, e_sn = 158, 370, 889, e_vert = 50, 50, 50, p_top_requested = 5000, num_metgrid_levels = 38, num_metgrid_soil_levels = 4, dx = 36000, 12000,4000, dy = 36000, 12000,4000, grid_id = 1, 2, 3, parent_id = 1, 1, 2, parent_grid_ratio = 1, 3, 3, parent_time_step_ratio = 1, 3, 3, feedback = 1, smooth_option = 0, / &physics physics_suite = 'CONUS' mp_physics = -1, -1, -1, cu_physics = -1, -1, 0, ra_lw_physics = -1, -1, -1, ra_sw_physics = -1, -1, -1, bl_pbl_physics = -1, -1, -1, sf_sfclay_physics = -1, -1, -1, sf_surface_physics = -1, -1, -1, radt = 30, 30, 30, bldt = 0, 0, 0, cudt = 5, 5, 5, icloud = 1, num_land_cat = 21, sf_urban_physics = 0, 0, 0, / &fdda / &dynamics hybrid_opt = 2, w_damping = 0, diff_opt = 1, 1, 1, km_opt = 4, 4, 4, diff_6th_opt = 0, 0, 0, diff_6th_factor = 0.12, 0.12, 0.12, base_temp = 290. damp_opt = 3, zdamp = 5000., 5000., 5000., dampcoef = 0.2, 0.2, 0.2 khdif = 0, 0, 0, kvdif = 0, 0, 0, non_hydrostatic = .true., .true., .true., moist_adv_opt = 1, 1, 1, scalar_adv_opt = 1, 1, 1, gwd_opt = 1, / &bdy_control spec_bdy_width = 5, specified = .true. / &grib2 / &namelist_quilt nio_tasks_per_group = 0, nio_groups = 1, /
之后正常运行./real.exe、./wrf.exe即可、、、
一个努力学习python的海洋人 水平有限,欢迎指正!!! 欢迎评论、收藏、点赞、转发、关注。 关注我不后悔,记录学习进步的过程~~