Introduction
Some users are interested on geopotential (z) of the different model levels (ml). ECMWF provides two tools for this, a MetView macro and a Python script, which are the recommended methods.
One of our customers, Mark Jackson from Cambridge Environmental Research Consultants (CERC), wanted to calculate geopotential and height above the surface for model levels, and this for one particular location. The existing methods did not suit him: Both methods only work on Linux, and they output geopotential for an area of interest rather than a single point location.
The script below does exactly that: it takes temperature and specific humidity (t and q) on model levels as inputs, along with geopotential and the pressure (z and lnsp) on the surface, and it creates as output the geopotential in m^2/s^2 for each model level. It then also calculates the height in meters by dividing the geopotential by the gravity of Earth (9.80665 m/s^2).
Notes:
- All data is in NetCDF format
- The computation script requires Python; the input data script requires Python and the ECMWF WebAPI to access ECMWF public datasets
The script only works correctly for ECMWF ERA-Interim data, do not use it with other datasets
Input data has to be gridded, not spectral
Get input data
To compute geopotential on model levels you need both temperature (t) and specific humidity (q) for each model level. You also need both surface geopotential (z) and logarithm of surface pressure (lnsp) for model level = 1. The script below downloads all this data from ECMWF, generating the output files "tq_ml.nc" and "zlnsp_ml.nc".
You can change date, type, step, time, grid and area in the script, but make sure you use the same values in both blocks so that the two output files are synchronized. Later the calculation of geopotential will iterate through the date/time/step parameters, calculating values for multiple times.
Compute geopotential on model levels
This script was provided by Mark Jackson from Cambridge Environmental Research Consultants Ltd.
Download the script
Example
First download the required data:
python geopotential_on_ml_getdata.py
python geopotential_on_ml_compute.py