nctoolkit.DataSet.vertical_mean

DataSet.vertical_mean(thickness=None, depth_range=None, fixed=None)

vertical_mean: Calculate the depth-averaged mean for each variable.

This is calculated for each time step and grid cell.

Optional parameters

thickness: str or Dataset

This must be supplied when vertical levels vary in space, i.e. fixed=False. One of: a variable, in the dataset, which contains the variable thicknesses; a .nc file which contains the thicknesses; or a Dataset that contains the thicknesses. Note: the .nc file or Dataset must only contain one variable.

depth_range: list

Only use when vertical levels vary in space Set a depth range if desired. Should be of the form [min_depth, max_depth].

fixedbool

Define whether the vertical levels are the same in all spatial locations. Set to True if they are, e.g. you have z-levels. If you have the likes of sigma-coordinates, set this to True.

Examples

If you wanted to vertical mean of every variable in a dataset with consistent vertical levels, you would do this:

>>> ds.vertical_mean(fixed = True)

This method will calculate the vertical mean weighted by the thickness of each cell. Note that if cell thickness cannot be derived it will just average the values in each vertical cell.