Introduction

Some users are interested on the wind u/v components at certain height in meters. This Python script will allow you to compute it. The starting point is the geopotential and pressure (z, lnsp) on the surface and temperature and specific humidity on all the model levels. The output will be written in grib format, providing the u and v components of the wind in m s**-1.

For this use case, you need to retrieve in grib format temperature (t), Specific humidity (q), U component (u), V component (v) for each model level. Besides, you need both surface geopotential (z) and logarithm of surface pressure (lnsp) for model level = 1. All the 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. First, it calculates the geopotential of each model level. Once the requested height is found between two model levels, the program will vertically interpolate the u/v component values.

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,u,v,z,lnsp). You can find more information about the script here compute_wind_speed_height.ksh:

Download

Python programcompute_wind_speed_height.py
Wrapper scriptcompute_wind_speed_height.ksh

Examples

This example will compute the u/v components of the wind at 100m on the 2015-10-21 time 00  step 12 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. In this case the resolution of the sfc u/v parameters archived are N640. This may change in future cycles.

Note that the values have been retrieved in grid=N640 (grid=640, gaussian=reduced)

python compute_wind_speed_height.py tq_ml_20151021_0.grib zlnsp_ml_20151021_0.grib uv_ml_20151021_0.grib -w "100"
python compute_wind_speed_height.py tq_ml_20151021_0.grib zlnsp_ml_20151021_0.grib uv_ml_20151021_0.grib -w "100" -o my_grib.grib