Step 1: Getting meteorological data from IFS or ERA5 reanalysis
Boundary conditions for WRF can be freely downloaded from ftp://ftp.ecmwf.int/pub/wrf. The output comes from ECMWF's operational HRES forecast and only one day's data is available. For more information please have a look at: ECMWF WRF Test Data. For those who have access to ECMWF MARS (access restricted) they can find the recipe how to retrieve the data for the past.
Alternatively, users can download the freely available ERA5 global reanalysis data from the C3S Climate Data Store (CDS) to drive WRF meteorological component. Please read through How to download ERA5. You also need to have a look at the parameter table in ECMWF WRF Test Data for retrieving relevant data.
import cdsapi
c = cdsapi.Client()
c.retrieve(
'reanalysis-era5-single-levels',
{
'product_type': 'reanalysis',
'format': 'grib',
'grid': '0.75/0.75',
'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_density', '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',
],
'year': '2010',
'month': '01',
'day': [
'01', '02',
],
'time': [
'00:00', '03:00', '06:00',
'09:00', '12:00', '15:00',
'18:00', '21:00',
],
},
'era_sfc_20100101-20100102.grib')
import cdsapi
c = cdsapi.Client()
c.retrieve(
'reanalysis-era5-pressure-levels',
{
'product_type': 'reanalysis',
'format': 'grib',
'grid': '0.75/0.75',
'variable': [
'geopotential', 'relative_humidity', 'temperature',
'u_component_of_wind', 'v_component_of_wind',
],
'pressure_level': [
'100', '250', '500',
'850', '1000',
],
'year': '2010',
'month': '01',
'day': [
'01', '02',
],
'time': [
'00:00', '03:00', '06:00',
'09:00', '12:00', '15:00',
'18:00', '21:00',
],
},
'era5_pl_20100101-20100102.grib')
If your version of the WRF model requires separate input GRIB files for each time step, you can easily split it using ecCodes:
$>grib_copy era_sfc_20100101-20100102.grib era_sfc_[validityDate][validityTime].grib
$>grib_copy era_pl_20100101-20100102.grib era_pl_[validityDate][validityTime].grib
Step 2: Downloading CAMS data from MARS
2.1 Retrieving the data from MARS
We tested with the CAMS reanalysis data for driving the WRF-Chem model. Please have a look at how to download the CAMS Reanalysis data via the ECMWF Web API so that you have a good understanding of the scripts below. Scripts below are using ECMWF's Web API.
#!/usr/bin/env python
from ecmwfapi import ECMWFDataServer
server = ECMWFDataServer()
server.retrieve({
'dataset' : "cams_reanalysis",
'class' : "mc",
'type' : "an",
'stream' : "oper",
'expver' : "eac4",
'levtype' : "ml",
'repres' : "gg",
'levellist' : "7/to/60",
'param' : "T/1.210/2.210/3.210/4.210/5.210/6.210/7.210/8.210/9.210/10.210/11.210",
'date' : "20100101/to/20100102",
'step' : "0",
'time' : "0/to/21/by/3",
'grid' : "0.75/0.75",
'target' : "AER_20100101_20100102_eac4.grib"
})
#!/usr/bin/env python
from ecmwfapi import ECMWFDataServer
server = ECMWFDataServer()
server.retrieve({
'dataset' : "cams_reanalysis",
'class' : "mc",
'type' : "an",
'stream' : "oper",
'expver' : "eac4",
'levtype' : "ml",
'repres' : "gg",
'levellist' : "7/to/60",
'param' : "203.210/123.210/27.217/121.210/13.217/6.217/124.210/122.210",
'date' : "20100101/to/20100102",
'step' : "0",
'time' : "0/to/21/by/3",
'grid' : "0.75/0.75",
'target' : "GRG_20100101_20100102_eac4.grib"
})
#!/usr/bin/env python
from ecmwfapi import ECMWFDataServer
server = ECMWFDataServer()
server.retrieve({
'dataset' : "cams_reanalysis",
'class' : "mc",
'type' : "an",
'stream' : "oper",
'expver' : "eac4",
'levtype' : "ml",
'repres' : "gg",
'levellist' : "7/to/60",
'param' : "52.217/45.217/9.217/42.217/47.217/46.217/10.217/12.217/11.217/16.217/43.217/7.217/15.217",
'date' : "20100101/to/20100102",
'step' : "0",
'time' : "0/to/21/by/3",
'grid' : "0.75/0.75",
'target' : "GRG_voc_20100101_20100102_eac4.grib"
})
#!/usr/bin/env python
from ecmwfapi import ECMWFDataServer
server = ECMWFDataServer()
server.retrieve({
'dataset' : "cams_reanalysis",
'class' : "mc",
'type' : "an",
'stream' : "oper",
'expver' : "eac4",
'levtype' : "ml",
'repres' : "gg",
'levellist' : "7/to/60",
'param' : "3.217",
'date' : "20100101/to/20100102",
'step' : "0",
'time' : "0/to/21/by/3",
'grid' : "0.75/0.75",
'target' : "GRG_h2o2_20100101_20100102_eac4.grib"
})
#!/usr/bin/env python
from ecmwfapi import ECMWFDataServer
server = ECMWFDataServer()
server.retrieve({
'dataset' : "cams_reanalysis",
'class' : "mc",
'type' : "an",
'stream' : "oper",
'expver' : "eac4",
'levtype' : "ml",
'repres' : "gg",
'levellist' : "1",
'param' : "152",
'date' : "20100101/to/20100102",
'step' : "0",
'time' : "0/to/21/by/3",
'grid' : "0.75/0.75",
'target' : "PS_20100101_20100102_eac4.grib"
})
2.2 Converting GRIB to NetCDF
Before running the script below you will need to have these packages installed:
You also need to download the get_tablecol script and table_tm5ver15htap.txt file into the same directory where script is to be run. The next step is to run the script below:
#!/bin/bash
module load netcdf4
module load cdo
module load nco
fd="20100101_20100102_eac4"
box_lab1='EU'
box_s=15.0
box_n=78.0
box_e=81.0
box_w=303.0
box1="${box_w},${box_e},${box_n},${box_s}"
chnames="go3,O3,so2,SO2,no2,NO2,co,CO,hcho,CH2O,no,NO,pan,PAN,hno3,HNO3,ald2,ALD2,c2h4,C2H4,c2h5oh,C2H5OH,c2h6,C2H6,c3h8,C3H8,c5h8,C5H8,ch3coch3,CH3COCH3,ch3oh,CH3OH,ch3ooh,CH3OOH,hcooh,HCOOH,par,PAR,ole,OLE,onit,ONIT,h2o2,H2O2"
chlist='O3/CO/NO/NO2/PAN/HNO3/CH2O/SO2'
tablefile=table_tm5ver15htap.txt
grouplist=("AER" "GRG" "GRG_voc" "PS")
for group in ${grouplist[*]} ; do
cdo -f nc -b 32 -invertlat ${group}_${fd}.grib ${group}_${fd}.nc
#
if [[ $group = 'PS' ]] ; then
# calculate surface pressure
cdo -expr,'ps=exp(lnsp)' PS_${fd}.nc PS1_${fd}.nc
mv PS1_${fd}.nc PS_${fd}.nc
ncatted -O -h -a long_name,ps,c,c,"surface pressure" PS_${fd}.nc dum
mv dum PS_${fd}.nc
ncatted -O -h -a unit,ps,c,c,"Pa" PS_${fd}.nc dum
mv dum PS_${fd}.nc
fi
#
cdo -sellonlatbox,$box1 ${group}_${fd}.nc ${group}_${fd}_${box_lab1}.nc
if [[ $group = 'GRG' || $group = 'GRG_voc' ]] ; then
fll=${group}_${fd}_${box_lab1}.nc
cdo -chname,$chnames $fll dum
mv dum $fll
# put together list of grib codes
for species in `echo $chlist | perl -pe 's{/}{ }g'`
{
grib_no=`get_tablecol -w name=$species $tablefile grib`
longname=`get_tablecol -w name=$species $tablefile long_name`
molmass=`get_tablecol -w name=$species $tablefile molm`
cunit="kg kg**-1"
ncatted -O -h -a units,${species},o,c,"$cunit" $fll
ncatted -O -h -a long_name,${species},o,c,"$longname" $fll
ncatted -O -h -a molar_mass,${species},a,c,"$molmass" $fll
}
fi
#
nccopy -d1 ${group}_${fd}_${box_lab1}.nc ${group}_${fd}_${box_lab1}.nc.tmp
mv ${group}_${fd}_${box_lab1}.nc.tmp ${group}_${fd}_${box_lab1}.nc
done
If the above script runs successfully, you should have the following files created:
AER_20100101_20100102_eac4_EU.nc
GRG_20100101_20100102_eac4_EU.nc
GRG_voc_20100101_20100102_eac4_EU.nc
PS_20100101_20100102_eac4_EU.nc
Step 3: Using mozbc to interpolate CAMS data for WRF
With a set of additional utilities, it is possible to use the mozbc package provided by the Atmospheric Chemistry Observations and Modelling Lab (ACOM) of NCAR to pre-process CAMS data with some minor modifications to the original code. The set of additional utilities has been developed as part of the AQMEII project and kindly provided by A. Lupascu (IASS-Posdam) and C. Knote (NCAR): public_box.tar.gz. The package contains:
Directory ./ECMWF2WRFChem/
|
---|
MACC_BC2MOZART.ncl | ncl script to convert CAMS files containing surface pressure, global reactive gases, and aerosols into a single file ready to be used by modified MOZBC package. |
convert.sh
| Runs the ncl script. |
Directory ./ |
|
---|
mo_mozart_lib.patch | Patch for mo_mozart_lib.f90 program (part of original mozbc package). The file should be copied to mozbc/ and then executed:
$>patch < mo_mozart_lib.patch |
saprc99.inp | Namelist. Defines input and output directories and which variables to interpolate to WRF grid. It is possible to use only those variables already defined in wrfinput_d01, which depends on chemical package and options selected in &chem section of WRF's namelist.input. Here, an example for SAPRC99 chemical mechanism coupled with the MOSAIC aerosol chemistry module with 4 size bins. The users have to provide their own mapping to get the chemical boundary condition for their preferred chemistry option. |
mozart.inp | A namelist example for mozart package. |
Step 4: Running the model
The first step is to run the WRF model but only up to real.exe. Instruction on how run the model are provided in WRF official user guide. Note that you should not execute the wrf.exe because we still do not have a chemical BC interpolated to the WRF grid. This will be created using the utility provided by AQMEII and the mozart package. Before running this step you should check and edit paths in convert.sh and MACC_BC2MOZART.ncl if necessary.
This step converts four NetCDF files (AER_*, GRG_*, GRG_voc_*, and PS_*) into a single AQMEII_*.nc file.
Once it is completed you can run the next step. Unpack, mozbc.tar, go to the mozbc main directory, copy mo_mozart_lib.patch, install, edit path to WRF run directory in the saprc99.inp namelist, and finally run mozbc.
This program will read NetCDF files created in the previous step (AQMEII_*.nc), chemical variables from it will be interpolated on WRF grid and added to wrfinput_d01 and wrfbdy_d01 files. Once this step has completed successfully you are ready to execute wrf.exe.
-
Page:
-
Page:
-
Page:
-
Page:
-
Page: