You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 13 Next »

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.

Get input data from the ECMWF Web API
#!/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-08-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-08-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",
})

Compute geopotential on model levels

Example

First download the required data:

python geopotential_on_ml_getdata.py
Outputs:
Now compute the geopotential:
python geopotential_on_ml_compute.py

 

Outputs:
  • No labels