User Tools

Site Tools


atmos:software:wrf:initialization:era-interim

Using ERA-Interim to Initialize WRF

1. Obtain the data.

The data can be obtained either manually, through the ECMWF web site, or by batch access, using a script written either in Python, Perl, or Java. Regardless of which method is used, a user account must first be created.

Create a user account

  1. Click on “Login” in the upper right corner.
  2. Click on “click here to register”
  3. Fill out the registration form.
  4. An email will be sent to your inbox with a link to activate the account. Click on it.
  5. You will receive another email with your password. There is no way to change it, so keep this email handy.

Accept the license agreement

You also need to accept the license agreement for the ERA-Interim dataset.

  1. “Read” the agreement.
  2. Fill in the blanks at the bottom of the page (if they are not already filled in)
  3. Click “Accept”

With this completed, you now have access to the ERA-Interim dataset.

Download the data

There are three separate GRIB files needed to initialize WRF: the time-invariant file, the surface file, and the pressure level file. These can be downloaded either manually or via a batch process. Manual retrieval is easy to do, but it has the disadvantage of saving the data on the local machine first and is also inconvenient for large data volumes. The batch process takes some time to set up, but once it is configured, it is a wholly automated process.

Download the time-invariant fields

It is easiest to download the time-invariant fields manually through the web portal.

  1. Click on “Invariant”
  2. Select all of the fields and retrieve the data in GRIB format.
  3. Choose the area needed and the grid spacing. (Be careful with selecting the North American dataset; due to a presumed bug on the ECMWF side, the North American option only retrieves data for Latin America. I strongly recommend specifying the lat/lon yourself using the custom option.) Retrieve the GRIB file.
  4. Rename the GRIB file to something convenient (the exact name doesn’t matter) and if needed, transfer it to the remote machine.

Download the surface and pressure level data

Download manually
  1. Retrieve the surface data
    1. Click on “Surface”
    2. Select the fields, dates, and times needed (if in doubt, select all of the fields)
    3. Retrieve the GRIB using the area and grid-spacing needed. (Again, be careful with selecting the North American dataset)
  2. Retrieve the pressure level data
    1. Click on “Pressure levels”
    2. Select the fields, dates, and times needed (if in doubt, select all of the fields)
    3. Retrieve the GRIB using the area and grid-spacing needed. (Again, be careful with selecting the North American dataset)
Download as a batch process

The batch access script can be written in one of three languages supported by ECMWF: Python, Java, or Perl. This documentation will use Java; for other languages, see the ECMWF documentation at https://software.ecmwf.int/wiki/display/WEBAPI/Accessing+ECMWF+data+servers+in+batch/

Prepare the script:

  1. Login to ECMWF and go to https://api.ecmwf.int/v1/key/. Copy the content of the given .ecmwfapirc file and save it as $HOME/.ecmwfapirc . This file is needed for the script to log into the server.
  2. Create a directory to hold the downloaded libraries. (I will refer to it as $LIB_DIR). Add this directory to your CLASSPATH. For example:
    export CLASSPATH=$LIB_DIR:$CLASSPATH
  3. Download the Java JSON package at http://json.org/java/ . Click on one of the source files; it will redirect you to github. Click on JSON-java to redirect you to the main page. Above there is a button labeled “ZIP”. This will download a zip archive of the source files. Unzip them and move the source to $LIB_DIR/org/json/ .
  4. Run
    javac *.java

    to compile the JSON package. If it does not compile, double check that your $CLASSPATH includes $LIB_DIR . Also, check that the source is in the directories properly (the structure is important for Java packages).

  5. Download the ECMWF Java packages from https://software.ecmwf.int/wiki/display/WEBAPI/Accessing+ECMWF+data+servers+in+batch . Place the tarball in $LIB_DIR and extract it. It should extract into the proper directory structure automatically.
  6. cd into $LIB_DIR/org/ecmwf/ and run
    javac *.java

    to compile the ECMWF packages.

A sample script is packaged with the ECMWF packages to assist in retrieving the data. It is located in $LIB_DIR.

Here is an outline for a script:

  1. Import the org.ecmwf.DataServer and org.json.JSONObject packages.
  2. Create an instance of both the DataServer and JSONObject classes.
  3. Use the put method of the JSONObject object to add the fields to the request. For example, if the JSONObject is named json, one field would be:
    json.put(“dataset”, “interim”);
  4. After all of the fields are inserted, send the JSONObject to the DataServer by using the retrieve() method of the DataServer. For example, if the DataServer is named server and the JSONObject is named json, the syntax would be:
    server.retrieve(json);

Pressure level fields and recommended values:

FieldsValues
dataset“interim” (ERA-Interim)
dateYYYY-MM-DD
levelist (note the typo!)“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” (List of desired pressure levels in mb)
stream“oper” (Operational)
levtype“pl” (Pressure levels)
param“129.128/130.128/131.128/132.128/157.128”
129.128 – Geopotential
130.128 – Temperature
131.128 – U wind component
132.128 – V wind component
157.128 – Relative humidity
step“0” (Just the analysis)
time“00:00:00/06:00:00/12:00:00/18:00:00”
type“an” (Analysis)
areaN/W/S/E boundaries of domain in degrees; ex. 50/-125/20/-65
grid“0.25/0.25” (0.25 degrees by 0.25 degrees)
target“pressurelevels.grib” (Name of output file)


Surface fields and recommended values:

FieldsValues
dataset“interim” (ERA-Interim)
dateYYYY-MM-DD
stream“oper” (Operational)
levtype“sfc” (Surface)
param“165.128/166.128/167.128/168.128/134.128/151.128/235.128/31.128/34.128/33.128/141.128/139.128/170.128/183.128/236.128/39.128/40.128/41.128/42.128”
165.128 – U wind component
166.128 – V wind component
167.128 – Temperature
168.128 – Dew point
134.128 – Surface pressure
151.128 – Sea level pressure
235.128 – Sea surface temperature (SKINTEMP)
31.128 – Sea ice fraction
34.128 – Sea surface temperature (SST)
33.128 – Snow density
141.128 – Snow water equivalent in meters
139.128 – 0-7 cm ground layer temperature
170.128 – 7-28 cm ground layer temperature
183.128 – 28-100 cm ground layer temperature
236.128 – 100-255 cm ground layer temperature
39.128 – 0-7 cm ground layer moisture
40.128 – 7-28 cm ground layer moisture
41.128 – 28-100 cm ground layer moisture
42.128 – 100-255 cm ground layer moisture
step“0” (Just the analysis)
time“00:00:00/06:00:00/12:00:00/18:00:00”
type“an” (Analysis)
areaN/W/S/E boundaries of domain in degrees; ex. 50/-125/20/-65
grid“0.25/0.25” (0.25 degrees by 0.25 degrees)
target“surface.grib” (Name of output file)


Compile the scripts and run:

javac *.java
java surface >& surface.log
java pressurelevels >& pressurelevels.log

2. Run WPS

  1. Set up and run geogrid as normal.
  2. When running ungrib, use the Vtable.ERA-Interim.pl Vtable and link in the surface, pressure level, and time-invariant fields.
  3. Run metgrid as normal.

3. Run WRF

  1. Run real.exe. (Check and set num_metgrid_levels. It will differ from other data sources. Also, real.exe may give an error about max_dz being exceeded. If this is the case, increase e_vert.)
  2. Run wrf.exe.

Sample scripts

PressureLevels.java

import org.ecmwf.DataServer;
import org.json.JSONObject;
 
public class PressureLevels {
 
	public static void main(String[] args) throws Exception {
 
    	    DataServer server = new DataServer(); 
 
	    JSONObject	request = new JSONObject();
 
    	    request.put("dataset" , "interim");
            request.put("date"    , "2011-04-21");
            request.put("levelist", "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");
            request.put("stream"  , "oper");
            request.put("levtype", "pl");
            request.put("param", "129.128/130.128/131.128/132.128/157.128");
            request.put("step", "0");
            request.put("time", "00:00:00/06:00:00/12:00:00/18:00:00");
            request.put("type", "an");
            request.put("area", "50/-125/20/-65");
            request.put("grid", "0.25/0.25");
            request.put("target", "preslevels25.grib");
	    server.retrieve(request);
	}
}

Surface.java

import org.ecmwf.DataServer;
import org.json.JSONObject;
 
public class Surface {
 
	public static void main(String[] args) throws Exception {
 
            DataServer server = new DataServer(); 
 
	    JSONObject request = new JSONObject();
 
	    request.put("dataset" , "interim");
            request.put("date"    , "2011-04-21");
            request.put("stream"  , "oper");
            request.put("levtype", "sfc");
            request.put("param", "165.128/166.128/167.128/168.128/134.128/151.128/235.128/31.128/34.128/33.128/141.128/139.128/170.128/183.128/236.128/39.128/40.128/41.128/42.128");
            request.put("step", "0");
            request.put("time", "00:00:00/06:00:00/12:00:00/18:00:00");
            request.put("type", "an");
            request.put("area", "50/-125/20/-65");
            request.put("grid", "0.25/0.25");
            request.put("target", "surface.grib");
	    server.retrieve(request);
	}
}
atmos/software/wrf/initialization/era-interim.txt · Last modified: 2020/01/29 17:25 by 127.0.0.1