geodat.nc.wgt_ave

geodat.nc.wgt_ave(var, axis=None, lat_weighted=True)[source]

A more general routine for averaging

The method first reads the axes (x/y/z/t) needed for averaging, finds the indices corresponding these axes, then uses the geodat.stat.wgt_ave to sort the axis and do the weighted average

if the axis is a “Y” axis, weights are computed using the latitude axis in the variable.

if no axis is given, all axes will be averaged over.

Arg:

var (Variable) axis (int/str/an iterable of int or str):

the dimension along which the average is computed
lat_weight (bool, default True): if an area average is involved, whether
a latitudinal weight based on a convergence of meridians is applied. The Y axis is assumed to have unit=degree
Optional args:

axis (str or a list of str or int) - axis to be averaged over weights (scalar or a numpy array)

if axis is a string, e.g. “xy”, the input argument weights will be overwritten

E.g.
  1. wgt_ave(Variable,’xy’) will do the area average
Fork me on GitHub