Skip to end of metadata
Go to start of metadata

Metviews has the Average Data data icon (in Python can be invoked via mv.mxs_average()) that can compute a zonal (or meridional) average cross section for GRIB data. However, if our input data contains multiple dates/steps a separate cross section is generated for each date/step. Now, if we want to generate the average cross section for the temporal average of the input data we have to do the temporal averaging by ourselves before passing the data to mv.mxs_average(). This is how it can be done:

import metview as mv
# read GRIB data containing pressure levels and several dates/steps
f ="my.grib")
# define the set of levels
levels = [1000, 925, 850, 700, 500]
# compute the mean on each level and add it to the resulting fieldset (=res)
res = mv.Fieldset()
for lev in levels:
    g =, levelist=lev, levtype="pl")

# res now contains the temporal average on each level. We compute the 
# zonal average vertical cross section with mxs_average().
av = mv.mxs_average(

# plot the resulting average cross section