Introduction

Some users are interested on geopotential (z) of the different model levels (ml). This Python script will allow you to compute it. The starting point is the geopotential and the pressure (z and lnsp) on the surface. The output will be written in GRIB format, providing 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))

For this use case, you need to retrieve in GRIB format both temperature (t) and Specific humidity (q) for each model level. Besides, you need both surface geopotential (z) and logarithm of surface pressure (lnsp) for model level = 1. Both files have to be synchronized using the same class, stream, date, time, step and gridType. The script will iterate through the date/time/step parameters, allowing you to get the values for multiple times.

If you are using MARS to retrieve the data, we have prepared a script that will allow you to get the data and then call the Python script automatically. You can set the date, time, step, class, grid resolution, type, area... The script will create and execute the MARS requests to get (t,q,z,lnsp). You can find more information about the script here: compute_geopotential_on_ml.ksh

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 retrieve both files. You can set a different class/stream/type for the input data. The gribType and resolution can also be changed.

python3 compute_geopotential_on_ml.py tq_ml_20151008_00.grib zlnsp_ml_20151008_00.grib
python3 compute_geopotential_on_ml.py tq_ml_20151008_00.grib zlnsp_ml_20151008_00.grib -o my_grib.grib
  • tq_ml_20151008_00.grib

    retrieve, 
      date= 20150801, 
      class = od,
      time= 0, 
      stream = oper,
      levtype= ml, 
      grid= 1.5/1.5,
      type= an,
      param= t/q, 
      levelist= all,
      target="tq_ml_20150801_00.grib"
  • zlnsp_ml_20151008_00.grib

    retrieve,
      date= 20150801, 
      class = od,
      time= 0, 
      stream = oper,
      levtype= ml, 
      grid= 1.5/1.5,
      type= an,
      param=lnsp,
      levelist=1,
      target="zlnsp_ml_20151008_00.grib"
    
    retrieve,
      type= an,
      param=z, 
      levelist=1,
      target="zlnsp_ml_20151008_00.grib"