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:

Step1: Get data

The first script downloads ERA-Interim data from ECMWF through the ECMWF Web API:

The Python script:

#!/usr/bin/env python
from ecmwfapi import ECMWFDataServer
server = ECMWFDataServer()
server.retrieve({
    "class": "ei",
    "dataset": "interim",
    "expver": "1",
    "levelist": "all",
    "levtype": "ml",
    "param": "t/q",
    "stream": "oper",
    "date": "2015-01-01",    #date: Specify a single date as "2015-08-01" or a period as "2015-08-01/to/2015-08-31".
    "type": "an",        #type: Use an (analysis) unless you have a particular reason to use fc (forecast).
    "time": "00:00:00",        #time: With type=an, time can be any of "00:00:00/06:00:00/12:00:00/18:00:00".  With type=fc, time can be any of "00:00:00/12:00:00",
    "step": "0",        #step: With type=an, step is always "0". With type=fc, step can be any of "3/6/9/12".
    "grid": "0.75/0.75",    #grid: Only regular lat/lon grids are supported.
    "area": "75/-20/10/60",    #area: N/W/S/E, here we have Europe.
    "format": "netcdf",
    "target": "tq_ml.nc",    #target: the name of the output file.
})
server.retrieve({
    "class": "ei",
    "dataset": "interim",
    "expver": "1",
    "levelist": "1",
    "levtype": "ml",
    "param": "z/lnsp",
    "stream": "oper",
    "date": "2015-01-01",
    "type": "an",
    "time": "00:00:00",
    "step": "0",
    "grid": "0.75/0.75",
    "area": "75/-20/10/60",
    "format": "netcdf",
    "target": "zlnsp_ml.nc",
})

Copy the script and save it to your computer.

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.

Run the script.

Outputs: A file 'tq_ml.nc' and a file 'zlnsp_ml.nc', both in the current working directory.

Step2: Compute geopotential on model levels

Related articles

Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.


Related issues