Let us suppose we have GRIB data with several vertical levels and dates/steps. In order to compute the temporal mean for each level we need to call the mv.mean() function is a loop. The code below illustrates how it can be done.

import metview as mv

# read GRIB data containing pressure levels and several dates/steps
f = mv.read("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 = mv.read(data=f, levelist=lev, levtype="pl")
	res.append(mv.mean(g))