Note
This is the tutorial of using WRF with ERA5 pressure level (38 vertical levels) data.
If you prefer model level (138 vertical levels), please check another tutorial.
I recommend the pressure level data, because the download speed is much faster.
If you don’t have cdsapi, please check this official tutorial.
Required Fields
WRF requires a number of fields as input.
3D Data (e.g. data on pressure levels)
- Temperature
- U and V components of Wind
- Geopotential Height
- Relative Humidity (the code can calculate RH if Specific Humidity is available;this is controlled in the Vtable)
2D Data
- Surface Pressure
- Mean Sea Level Pressure
- Skin Temperature/SST
- 2-meter Temperature
- 2-meter Relative or Specific Humidity
- 10-meter U and V components of wind
- Soil data (temperature and moisture) and soil height
If any masked field is ingested, then a LANDSEA field is recommended
Water equivalent snow depth (SNOW) is a nice field to have, but not required.
SEAICE is good to have for a high latitude winter case, but it is not required.
Single level data (GetERA5-sl.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','land_sea_mask','mean_sea_level_pressure',
'sea_ice_cover','sea_surface_temperature','skin_temperature',
'snow_depth','soil_temperature_level_1','soil_temperature_level_2',
'soil_temperature_level_3','soil_temperature_level_4','surface_pressure',
'volumetric_soil_water_layer_1','volumetric_soil_water_layer_2','volumetric_soil_water_layer_3',
'volumetric_soil_water_layer_4'
],
'date':'DATE1/DATE2',
'area':'Nort/West/Sout/East',
'time':'00/to/23/by/1',
},
'ERA5-DATE1-DATE2-sl.grib')
Pressure level data (GetERA5-pl.py)
import cdsapi
c = cdsapi.Client()
c.retrieve(
'reanalysis-era5-pressure-levels',
{
'product_type':'reanalysis',
'format':'grib',
'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'
],
'date':'DATE1/DATE2',
'area':'Nort/West/Sout/East',
'time':'00/to/23/by/1',
'variable':[
'geopotential','relative_humidity','specific_humidity',
'temperature','u_component_of_wind','v_component_of_wind'
]
},
'ERA5-DATE1-DATE2-pl.grib')
Automation script (Download)
You can automate the script rather than change elements one by one.
#!/bin/bash -l
CODEDIR=/nuist/u/home/yinyan/xin/scratch/data/ERA5/code
DATADIR=/nuist/u/home/yinyan/xin/scratch/data/ERA5/data
# Set your python environment
export PATH=~/xin/work/anaconda3/bin:$PATH
source activate root
cd $CODEDIR
DATE1=20170419
DATE2=20170420
YY1=`echo $DATE1 | cut -c1-4`
MM1=`echo $DATE1 | cut -c5-6`
DD1=`echo $DATE1 | cut -c7-8`
YY2=`echo $DATE2 | cut -c1-4`
MM2=`echo $DATE2 | cut -c5-6`
DD2=`echo $DATE2 | cut -c7-8`
Nort=60
West=80
Sout=15
East=150
sed -e "s/DATE1/${DATE1}/g;s/DATE2/${DATE2}/g;s/Nort/${Nort}/g;s/West/${West}/g;s/Sout/${Sout}/g;s/East/${East}/g;" GetERA5-sl.py > GetERA5-${DATE1}-${DATE2}-sl.py
python GetERA5-${DATE1}-${DATE2}-sl.py
sed -e "s/DATE1/${DATE1}/g;s/DATE2/${DATE2}/g;s/Nort/${Nort}/g;s/West/${West}/g;s/Sout/${Sout}/g;s/East/${East}/g;" GetERA5-pl.py > GetERA5-${DATE1}-${DATE2}-pl.py
python GetERA5-${DATE1}-${DATE2}-pl.py
mkdir -p ${DATADIR}/$YY1
mv ERA5-${DATE1}-${DATE2}-sl.grib ERA5-${DATE1}-${DATE2}-pl.grib ${DATADIR}/$YY1/
exit 0
geogrid
Run geogrid.exe as usual.
If you’re not familiar with WRF, please check the online tutorial in detail.
ungrib
Run ungrib.exe by using the Vtable.ERA-interim.pl
table:
$ ln -s ./ungrib/Variable_Tables/Vtable.ERA-interim.pl Vtable
metgrid
Run metgrid.exe as usual.
References
- How to run the WRF model using ERA5 (on model levels) as initial and boundary conditions
- Grib to Netcdf conversion
- Download ERA-Interim data
- UNGRIB: Required Fields
Version control
Version | Action | Time |
---|---|---|
1.0 | Init | 2019-10-03 |
1.1 | Add support of selecting area | 2019-10-04 |
1.2 | Update the method of assigning ’time' | 2020-03-27 |
Say something
Thank you
Your comment has been submitted and will be published once it has been approved.
OOPS!
Your comment has not been submitted. Please go back and try again. Thank You!
If this error persists, please open an issue by clicking here.
Comments (50)
Sam
Tuesday, Mar 24, 2020
Xin Zhang
In reply to Sam
Tuesday, Mar 24, 2020
Hi, Sam!
You don’t have to merge both datasets.
You can just use
./link_grib.csh ERF5*
to link all files.Then
ungrib.exe
will read allGRIBFILE.*
.Xin
Zhenning Li
Thursday, Mar 26, 2020
Xin Zhang
In reply to Zhenning Li
Thursday, Mar 26, 2020
Hi Zhenning,
Thanks!
That’s just an example which downloads 12 hours data.
You can choose any time interval you like, even unequally spaced intervals.
Xin
Xin Zhang
In reply to Zhenning Li
Friday, Mar 27, 2020
Hi Zhenning,
You can use a simpler method to choose the
time
like this:I’ve updated that part in the blog. Thank you for your question ;)
Xin
Zhenning Li
In reply to Zhenning Li
Saturday, May 1, 2021
Thanks! Sorry I just noted you reply. Good suggestion!
Regards, Zhenning
Prerita Agarwal
Tuesday, Apr 7, 2020
Xin Zhang
In reply to Prerita Agarwal
Tuesday, Apr 7, 2020
Hi Prerita,
A1:
The pressure levels are interpolated from model levels. You can check the ERA5 document in detail. Also, the definition of 137 model levels is here and the diagram.
A2: Yes, you can link both kinds of data. That’s easier to do
ungrib.exe
andmetgrid.exe
.Cheers, Xin
Yasmin
Sunday, Apr 12, 2020
Xin Zhang
In reply to Yasmin
Sunday, Apr 12, 2020
Hi Yasmin,
That step is related to the ERA5 model level data. For the pressure level data, you don’t have to calculate data manually again.
Of course, I’ve written another tutorial for the model level data. Feel free to check that ;)
Xin
Yasmin
In reply to Yasmin
Thursday, Apr 16, 2020
Ahhh.. I see Xin, Thank you for the elucidation. Which one do you recommend? Model or Pressure level data?
I am downloading the pressure data + surface data. Hopefully I can run successfully the WRF. Let’s see. Yasmin
Xin Zhang
In reply to Yasmin
Sunday, Apr 19, 2020
Hi Yasmin,
In my opinion, the pressure level data is enough. But, if you want the higher vertical resolution, such as >100 levels, or focus on upper atmosphere, you can try the model data.
Looking forward to your test ;)
Xin
Yasmin
Sunday, Apr 19, 2020
Xin Zhang
In reply to Yasmin
Monday, Apr 20, 2020
Hi Yasmin,
I’ve used the ERA5 pressure level data several times and it always works well. So, I suppose there’s something wrong in your step of
./link_grib.csh
orungrib.exe
. You need to check files (GRIBFILE.AAA
……) and logs (ungrib.log
) related to these two command. If these steps are successful, then you should see theFILE:**
files which cover the simulation time duration.The most possible cause is the
namelist.wps
, you don’t needPRES
. Here’s an example:Xin
Yasmin
Monday, Apr 20, 2020
Xin Zhang
In reply to Yasmin
Tuesday, Apr 21, 2020
Great! Looking forward to your new results ;)
Xin
Guilherme
Tuesday, Apr 21, 2020
Xin Zhang
In reply to Guilherme
Tuesday, Apr 21, 2020
Hi,
Note that the step of
calc_ecmwf_p.exe
is necessary for model level data, not pressure data.If you’re using model level data, you need to create
ecmwf_coeffs
by yourself. Please check my another tutorial.Xin
Stefan Rahimi
Friday, Jun 26, 2020
Xin Zhang
In reply to Stefan Rahimi
Saturday, Jun 27, 2020
Dear Stefan,
The resource is from CDS which contains ERA5 Pressure level data and Single level data.
Since you need 40-year data, you can choose either method: using the above scripts or just clicking the boxes on the CDS web page.
Regards, Xin
bara
Friday, Jun 26, 2020
Xin Zhang
In reply to bara
Saturday, Jun 27, 2020
Hi Bara,
That’s strange …
Could you check whether
RH
andTT
exist in the pressure level grib files you have downloaded?BTW, it;s better to make sure there’s no error in the log files (ungrib.log and metgrid.log).
Xin
Bara
In reply to bara
Saturday, Jun 27, 2020
Xin Zhang
In reply to bara
Sunday, Jun 28, 2020
Hi Bara,
Could you send the log files to my [email](mailto: xinzhang1215@gmail.com)? (If the generated files aren’t big, you can send them too) So, I can check the details …
Xin
Bara
Tuesday, Jun 30, 2020
Xin Zhang
In reply to Bara
Tuesday, Jun 30, 2020
Ha, nice!
I thought that step was optional for pressure level data and never used that before …
Anyway, I’m glad you solved it ;)
Xin
Chi
Friday, Jul 3, 2020
Xin Zhang
In reply to Chi
Friday, Jul 3, 2020
Hi Chi,
This post is for ERA5 dataset.
If you’re using ERA-Interim data, please check my another post.
Xin
Bart Brashers
Sunday, Jul 5, 2020
Xin Zhang
In reply to Bart Brashers
Monday, Jul 6, 2020
Thanks, Bart. Nice question!
I can’t find the
soil height
variable in the ERA5 dataset …Have you found it on the CDS website?
Regards,
Xin
Du Xin-guan
Monday, Jul 6, 2020
Jason
Friday, Aug 7, 2020
Sumitra
Friday, Aug 7, 2020
pyadav
In reply to Sumitra
Monday, Aug 31, 2020
Josué Arellano Palacios
Wednesday, Sep 9, 2020
Xin Zhang
In reply to Josué Arellano Palacios
Wednesday, Sep 9, 2020
Hi Josué,
This is caused by the
restart
option in thenamelist.input
file.If you don’t want restart, you can set it to False. Otherwise, you have to set the suitable
restart_interval
for the restart.You can check the official WRF USER GUIDE in detail.
Regards,
Xin
Josué Arellano Palacios
In reply to Josué Arellano Palacios
Friday, Sep 18, 2020
Thanks for your help, it was very useful! Your tutorial is great!
Best,
Josué
He Ming
Tuesday, Oct 20, 2020
Xin Zhang
In reply to He Ming
Thursday, Oct 22, 2020
Hi, He Ming,
You can check the detailed log (rsl.error.****) related to that specific node (node h2ocn16).
That should contain the information you want.
Anyway, it seems not the problem of ERA5 data, but the setting of WRF.
Xin
Divyansh Chug
Thursday, Oct 22, 2020
Xin Zhang
In reply to Divyansh Chug
Sunday, Oct 25, 2020
You’re welcome, Divyansh Chug.
I’m glad that this can help you ;)
joseph
Friday, Nov 27, 2020
Xin Zhang
In reply to joseph
Friday, Nov 27, 2020
I haven’t used the monthly data before.
But, you can generate the official script on the CDS page and then write your own based on that.
Regards, Xin
Peng
Friday, Dec 25, 2020
Xin Zhang
In reply to Peng
Saturday, Dec 26, 2020
Hi Peng,
You can check the free ERA5 products here.
I suppose the real-time forecast data isn’t freely available.
Regards,
Xin
Peng
In reply to Peng
Saturday, Dec 26, 2020
Thank you very much for your reply.
Kind regards, Peng
peng
Thursday, Dec 31, 2020
Vinayak
Sunday, Apr 11, 2021
Xin Zhang
In reply to Vinayak
Tuesday, Apr 13, 2021
Hi Vinayak,
You can check my other tutorial about ERA-Interim. Hope that can help you.
Xin
Rocio
Tuesday, May 11, 2021