Field.cumsum(axis, masked_as_zero=False, coordinate=None, inplace=False)[source]

Return the field cumulatively summed along the given axis.

The cell bounds of the axis are updated to describe the range over which the sums apply, and a new “sum” cell method construct is added to the resulting field construct.

New in version 3.0.0.


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 by f.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 at the same locations as the original data.

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.

Field or None

The field construct with the cumulatively summed dimension, or None if the operation was in-place.


>>> g = f.cumsum('T')
>>> g = f.cumsum('latitude', masked_as_zero=True)
>>> g = f.cumsum('latitude', coordinate='mid_range')
>>> f.cumsum('latitude', inplace=True)