spatial_sum: Calculate the spatial sum for all variables.

This is performed for each time step.


by_area (boolean) – Set to True if you want to multiply the values by the grid cell area before summing over space. Default is False.


If you want to calculate the spatial sum each variable across space for a dataset, just do the following:

>>> ds.spatial_sum()

By default, this method simply sums up each grid cell value. In some cases this is not suitable. For example, the values in each cell may concentrations or values per square metre etc. In this case multiplying each cell value by the cell area is more suitable. Do the following:

>>> ds.spatial_sum(by_area = True)

Each cell’s value will be multiplied by the area of the cell (in square metres) prior to calculating the spatial sum.