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.
So Mark wrote his own script and kindly provided it to us. The script calculates the geopotential in m^2/s^2 on each model level for a single point location. It then also calculates the height in meters by dividing the geopotential by the gravity of Earth (9.80665 m/s^2).
This is a two step process: first you have to obtain the required input data, then you perform the actual geopotential and height calculation.
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
- In the computation script, paths and other arguments are hardcoded, so you will need to adapt the script to your system
Step1: Get data
The first script downloads ERA-Interim data from ECMWF through the ECMWF Web API:
- Temperature (t) and specific humidity (q), both on each model level, as file 'tq_ml.nc'.
- The log of surface pressure (lnsp) and geopotential (z), both on model level 1, as file 'zlnsp_ml.nc'.
The Python script: EI_geopotential_on_ml_getdata_v1.py
You can change date, type, step, time, grid and area in the script, but make sure you use the same values in both 'execute' 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.
Outputs: A file 'tq_ml.nc' and a file 'zlnsp_ml.nc', both in the current working directory.
Step2: Compute geopotential on model levels
This script was kindly provided by Mark Jackson from Cambridge Environmental Research Consultants Ltd. The script is provided 'as is' and is not supported by ECMWF/Copernicus or by CERC.
The Python script: EI_geopotential_on_ml_compute_v1.py
Outputs: CSV files (one per timestamp) with geopotential and height (relative to terrain) on each model level.
.