sum

sum(fs, missing=False, dim=None, preserve_dims=None)

Computes the point-wise sum of the values in fs.

Parameters
  • fs (Fieldset) – input fieldset

  • missing (bool) – controls what happens when missing values are present in fs. When it is False, a missing value in any of the fields at a given gridpoint will result in a missing value in the corresponding gridpoint in the output. If it is True all the non-missing values across the fields at a given grid point will be used to compute the sum. This parameter is new in Metview version 5.16.0. In earlier versions the computations are carried out as if missing was set to False.

  • dim (str) – restrict the computations to a single dimension of the data - see main text below. New in metview-python version 1.13.0.

  • preserve_dims (list) – may be used in conjunction with parameter dim - see main text below. New in metview-python version 1.13.0.

Return type

Fieldset

The output is a Fieldset with one field only.

With N fields in fs by denoting the i-th value in the k-th field by \(x_{i}^{k}\) the output values can be written as:

\[s_{i} = \sum_{k}^{N} x_{i}^{k}\]

To understand how to perform computations over a single ‘dimension’ of the data, see the documentation for the mean() function.

Note

See also mean().

sum(gpt)

Computes the sum of all the values in the values column of gpt.

Parameters

gpt (Geopoints) – input geopoints

Return type

number

Missing values are bypassed in this calculation. If there are no valid values None is returned.