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

Compare with Current View Page History

Version 1 Next »

Introduction

Some users are interested on geopotential (z) of the different model levels (ml). This Python script computes the geopotential on model levels, using as inputs NetCDF files containing geopotential and the pressure (z and lnsp) on the surface, and creating as output a NetCDF file containing the geopotential in m^2/s^2 for each level. Note that you can get the height in meters if you divide the geopotential by the gravity of Earth (9.80665 m/s^2).

  • This script is intended only as a workaround for users who can not work with the ECMWF GRIB API. If you can use the GRIB API, use the script available here.
  • The 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

For this use case, 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. Input files have to be synchronized using the same date, date, time, step and gridType. Afterwards the calculation of geopotential will iterate through the date/time/step parameters, allowing you to get the values for multiple times.

First get temperature (t) and  Specific humidity (q), using  the ECMWF Web API:

Get t and q
#!/usr/bin/env python from ecmwfapi import ECMWFDataServer server = ECMWFDataServer() server.retrieve({ "class": "ei", "dataset": "interim", "date": "2015-08-01", "expver": "1", "grid": "0.75/0.75", "levtype": "ml",
"levelist": "all",
"param": "t/q", "step": "0", "stream": "oper", "time": "0", "type": "an",
"format": "netcdf"
 "target": "tq_ml_20150801_00.nc", })

Get surface logarithm of surface pressure (lnsp) for model level = 1:

#!/usr/bin/env python
from ecmwfapi import ECMWFDataServer
server = ECMWFDataServer()
server.retrieve({
    "class": "ei",
    "dataset": "interim",
    "date": "2016-12-01",
    "expver": "1",
    "grid": "0.75/0.75",
    "levelist": "1",
    "levtype": "ml",
    "param": "lnsp",
    "step": "0",
    "stream": "oper",
    "time": "0",
    "type": "an",
    "format": "netcdf"
 "target": "lnsp_ml_20150801_00.nc",
})

Get the geopotential (z):

#!/usr/bin/env python
from ecmwfapi import ECMWFDataServer
server = ECMWFDataServer()
server.retrieve({
    "class": "ei",
    "dataset": "interim",
    "date": "1989-01-01",
    "expver": "1",
    "grid": "0.75/0.75",
    "levtype": "sfc",
    "param": "z",
    "step": "0",
    "stream": "oper",
    "time": "12:00:00",
    "type": "an",
    "format": "netcdf"
 "target": "zlnsp_ml_20150801_00.nc",
})



 

Compute geopotential on model levels

 

Download

Examples

This example will compute the geopotential on the 2015-10-08 time 00 operational analysis model levels (137). Below you can see the MARS user documentation request used to retrive both files. You can set a different class/stream/type for the input data. The gribType and resolution can also be changed.

 

python compute_geopotential_on_ml.py tq_ml_20151008_00.grib zlnsp_ml_20151008_00.grib
python compute_geopotential_on_ml.py tq_ml_20151008_00.grib zlnsp_ml_20151008_00.grib -o my_grib.grib

 

  • tq_ml_20151008_00.grib

     Click here to expand...
  • zlnsp_ml_20151008_00.grib

     Click here to expand...
  • No labels