Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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 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).

This is  a two step process: first you get 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

Step1: Get input data

...

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

  • Temperature (t) and specific humidity (q) for each model level

...

  • , as file "tq_ml.nc".
  • Surface geopotential (z) and logarithm of surface pressure (lnsp) for model level = 1

...

  • , as file "zlnsp_ml.nc".

Python script: EI_geopotential_on_ml_getdata_v1.py 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.

Code Block
languagepy
titleGet input data from the ECMWF Web API
collapsetrue
#!/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",
})

Step2: Compute geopotential on model levels

Example

First download get the required data: 

 

Code Block
languagepy
python EI_geopotential_on_ml_getdata_v1.py
Outputs:
Now compute the geopotential:

 

Code Block
python EI_geopotential_on_ml_compute.py

 

Outputs: