Axis Reductions

These functions compute summary statistics over specified axes of a variable. In general multiple axes can be reduced over at the same time. Many of them wrap similar numpy functions, though they are also capable of performing these operations on datasets too large to fit in memory. Most operations have two versions, one which computes the reduction including every element without checking for the presence of NaNs, and one which ignores any element which is a NaN, adjusting the relevant normalization.

Var.mean(*axes, **kwargs)

Computes the mean of this variable. If weights are present on any of the axes, a weighted mean is computed by default.

Parameters
*axesany number of axis identifiers (string, Axis, or int) (optional)

Axes over which the average should be computed. If none are provided, the mean is computed over the whole domain.

weightsboolean or Var (optional)

If provided, a weighted mean is performed. If True (the default), the default weights associated with the variable are used (getweights). If False, or None, no weighting is performed. Finally, custom weights can be provided in the form of a Var; this var must be defined on a subset of the axes being averaged over.

Returns
outVar

Var defined on a subgrid of this variable. If the mean is computed over the whole domain, a python scalar is returned.

See also

nanmean
getweights
Var.nanmean(*axes, **kwargs)

Computes the mean of this variable, ignoring any NaNs in the domain.

Parameters
*axesany number of axis identifiers (string, Axis, or int) (optional)

Axes over which the average should be computed. If none are provided, the mean is computed over the whole domain.

weightsboolean or Var (optional)

If provided, a weighted mean is performed. If True (the default), the default weights associated with the variable are used (getweights). If False, or None, no weighting is performed. Finally, custom weights can be provided in the form of a Var; this var must be defined on a subset of the axes being averaged over.

Returns
outVar

Var defined on a subgrid of this variable. If the mean is computed over the whole domain, a python scalar is returned.

See also

mean
getweights
Var.sum(*axes, **kwargs)

Computes the sum of this variable. NB: Unlike mean, weights are not used by default.

Parameters
*axesany number of axis identifiers (string, Axis, or int) (optional)

Axes over which the sum should be computed. If none are provided, the sum is computed over the whole domain.

weightsboolean or Var (optional)

If provided, a weighted sum is performed. If True, the default weights associated with the variable are used (getweights). If False or None (the default), no weighting is performed. Finally, custom weights can be provided in the form of a Var; this var must be defined on a subset of the axes being summed over.

Returns
outVar

Var defined on a subgrid of this variable. If the sum is computed over the whole domain, a python scalar is returned.

See also

getweights
Var.nansum(*axes, **kwargs)

Computes the sum of this variable, ignoring any NaNs.

Parameters
*axesany number of axis identifiers (string, Axis, or int) (optional)

Axes over which the sum should be computed. If none are provided, the sum is computed over the whole domain.

weightsboolean or Var (optional)

If provided, a weighted sum is performed. If True, the default weights associated with the variable are used (getweights). If False or None (the default), no weighting is performed. Finally, custom weights can be provided in the form of a Var; this var must be defined on a subset of the axes being summed over.

Returns
outVar

Var defined on a subgrid of this variable. If the sum is computed over the whole domain, a python scalar is returned.

See also

getweights
Var.stdev(*axes)

Computes the standard deviation of this variable.

Parameters
*axesany number of axis identifiers (string, Axis, or int) (optional)

Axes over which the standard deviation should be computed. If none are provided, the standard deviation is computed over the whole domain.

Returns
outVar

Var defined on a subgrid of this variable. If the variance is computed over the whole domain, a python scalar is returned.

Var.nanstdev(*axes)

Computes the standard deviation of this variable, ignoring any NaNs present.

Parameters
*axesany number of axis identifiers (string, Axis, or int) (optional)

Axes over which the standard deviation should be computed. If none are provided, the standard deviation is computed over the whole domain.

Returns
outVar

Var defined on a subgrid of this variable. If the variance is computed over the whole domain, a python scalar is returned.

Var.variance(*axes, **kwargs)

Computes the variance of this variable.

Parameters
*axesany number of axis identifiers (string, Axis, or int) (optional)

Axes over which the variance should be computed. If none are provided, the variance is computed over the whole domain.

weightsboolean or Var (optional, default False)

If provided, a weighted variance is calculated. If True, the default weights associated with the variable are used (getweights). If False, or None, no weighting is performed. Finally, custom weights can be provided in the form of a Var; this var must be defined on a subset of the axes being reduced.

Returns
outVar

Var defined on a subgrid of this variable. If the variance is computed over the whole domain, a python scalar is returned.

Var.nanvariance(*axes)

Computes the variance of this variable, ignoring any NaNs.

Parameters
*axesany number of axis identifiers (string, Axis, or int) (optional)

Axes over which the variance should be computed. If none are provided, the variance is computed over the whole domain.

Returns
outVar

Var defined on a subgrid of this variable. If the variance is computed over the whole domain, a python scalar is returned.

Var.min(*axes)

Computes the minimum value of this variable.

Parameters
*axesany number of axis identifiers (string, Axis, or int) (optional)

Axes over which the minimum should be found. If none are provided, the global minimum is found.

Returns
outVar

Var defined on a subgrid of this variable. If the global minimum is requested, a python scalar is returned.

See also

max
nanmax
nanmin
Var.nanmin(*axes)

Computes the minimum value of this variable, ignoring NaNs.

Parameters
*axesany number of axis identifiers (string, Axis, or int) (optional)

Axes over which the minimum should be found. If none are provided, the global minimum is found.

Returns
outVar

Var defined on a subgrid of this variable. If the global minimum is requested, a python scalar is returned.

See also

min
max
nanmax
Var.max(*axes)

Computes the maximum value of this variable.

Parameters
*axesany number of axis identifiers (string, Axis, or int) (optional)

Axes over which the maximum should be found. If none are provided, the global maximum is found.

Returns
outVar

Var defined on a subgrid of this variable. If the global maximum is requested, a python scalar is returned.

See also

min
nanmax
nanmin
Var.nanmax(*axes)

Computes the maximum value of this variable, ignoring NaNs.

Parameters
*axesany number of axis identifiers (string, Axis, or int) (optional)

Axes over which the maximum should be found. If none are provided, the global maximum is found.

Returns
outVar

Var defined on a subgrid of this variable. If the global maximum is requested, a python scalar is returned.

See also

max
min
nanmin
Var.argmin(axis)

Finds the index of the minumum value of this variable along the given axis.

Parameters
axisa single axis identifier (string, Axis, or int) (optional)

Axis over which the index of the minimum should be found.

Returns
outVar

Var defined on all axes of this variable except axis, containing the index of the minimum.

See also

argmax
Var.argmax(axis)

Finds the index of the maximum value of this variable along the given axis.

Parameters
axisa single axis identifier (string, Axis, or int) (optional)

Axis over which the index of the maximum should be found.

Returns
outVar

Var defined on all axes of this variable except axis, containing the index of the maximum.

See also

argmin
See Also:

Var class overview

The N-dimensional array (ndarray) (external Numpy documentation)