Skip to content

Documented Cube.mean() and rewrote it to optionally perform weighted means.

Martin Shepherd requested to merge mcs_22jun into master

By default Cube.mean() continues to perform unweighted means. However when the new 'weighting' argument is True, a weighted mean is performed. When the new 'weights' argument is None, a weighting array is automatically constructed from the reciprocal of the data variances. Alternatively the weights argument can be used to specify an explicit array of weights. If a weighted mean is requested, but no weighting array has been provided and the cube has no variances, then an unweighted mean is performed.

A new unit-test function has been written to test all combinations of the weighting and axis arguments of Cube.mean(). This is called test_mean(). The docstring of test_sum() has also been corrected to indicate that it only tests sums. It incorrectly claimed to test means as well as sums.

Merge request reports