nctoolkit.DataSet.tsum

DataSet.tsum(over='time', align='right', window=None)

tsum: Calculate the temporal sum of all variables.

Parameters:
  • align (str) – This determines whether the output time is at the left, centre or right hand side of the time window. Options are “left”, “centre” and “right”

  • over (str or list) – Time periods to count the sum over. Options are ‘year’, ‘month’, ‘day’. This operates in a similar way to the groupby method in pandas or the tidyverse in R, so you can supply combinations of these to get the sum over each year, month or day.

  • window (int) – This determines the number of time steps to sum over, on a non-rolling basis. This is useful if you need to calculate the sum every 5 days, for example.

Examples

If you want to calculate sum over all time steps. Do the following: >>> ds.tsum() If you want to calculate the sum over each year: >>> ds.tsum(over=”year”) If you want to calculate the sum over each month. This will add up all data in each month across all years not within each year. >>> ds.tsum(over=”month”) If you want to calculate the sum over each day. This will add up all data in each day across all years not within each year. >>> ds.tsum(over=”day”)