cf.Field.cumsum¶
-
Field.
cumsum
(axis, masked_as_zero=False, coordinate=None, inplace=False)[source]¶ Return the field cumulatively summed along the given axis.
The cell bounds (if any) of the summed axis are updated, and a “sum” cell method construct is added.
New in version 3.0.0.
See also
Parameters: - axis:
Select the domain axis over which the cumulative sums are to be calculated, defined by that which would be selected by passing the given axis description to a call of the field construct’s
domain_axis
method. For example, for a value of'X'
, the domain axis construct returned byf.domain_axis('X'))
is selected.- masked_as_zero:
bool
, optional If True then set missing data values to zero before calculating the cumulative sum. By default the output data will be masked where any missing values contribute to a cumulative sum.
- coordinate:
str
, optional Set how the cell coordinate values for the summed axis are defined. By default they are unchanged from the original field construct, but if coordinate is set to
'mid_range'
then the each coordinate value is replaced by the mid_range of the updated cell bounds.- inplace:
bool
, optional If True then do the operation in-place and return
None
.
Returns: Examples:
>>> g = f.cumsum('T')
>>> g = f.cumsum('latitude', masked_as_zero=True)
>>> g = f.cumsum('latitude', coordinate='mid_range')
>>> f.cumsum('latitude', inplace=True)