Return new fields with dimensions collapsed by statistical operations.
In all cases, the presence of missing data in an input field’s data array is accounted for during the collapse.
The following collapse methods are available over any subset of the fields’ axes, where the methods are defined exactly as for CF cell methods:
Method | Description | Options |
---|---|---|
min | Minima over the specified axes | |
max | Maxima over the specified axes | |
mid_range | Means of the minima and maxima over the specified axes | |
sum | Sums over the specified axes | |
mean | Means over the specified axes | Weighted or unweighted |
standard_deviation | Standard deviations over the specified axes | Weighted or unweighted, biased or unbiased |
variance | Variances over the specified axes | Weighted or unweighted, biased or unbiased |
Parameters : |
|
||||||||
---|---|---|---|---|---|---|---|---|---|
Returns : |
|
Examples
>>> g = cf.collapse(f, 'max')
>>> g = cf.collapse(f, 'min', axes=[2, 1])
>>> g = cf.collapse(f, 'sum', axes='dim2')
>>> g = cf.collapse(f, 'mid_range', axes=('latitude', 0, dim2'))
>>. g = cf.collapse(f, 'mean', axes='latitude', weights=None)
>>> g = cf.collapse(f, 'mean', axes='longitude', weights=None)
>>> g = cf.collapse(f, 'mean', axes=['longitude', 'latitude'], weights=None)
>>> g = cf.collapse(f, 'standard_deviation', weights=None)
>>> g = cf.collapse(f, 'variance', weights=None, unbiased=True)
>>> g = cf.collapse(f, 'mean', axes='latitude')
>>> g = cf.collapse(f, 'mean', axes='longitude')
>>> g = cf.collapse(f, 'mean', axes=['longitude', 'latitude'])
>>> g = cf.collapse(f, 'variance')
>>> g = cf.collapse(f, 'standard_deviation', unbiased=True)
>>> g = cf.collapse(f, 'longitude: mean latitude: max')
>>> weights = {'time': None,
... (2, 'dim1'): numpy.arange(45).reshape(5, 9))
>>> g = cf.collapse(f, 'mean', weights=weights)