Temporal statistics

A family of methods prefixed with t calculates temporal statistics over specified time periods, plus rolling windows, anomalies and cumulative sums.

Core statistics

A family of methods prefixed with t calculates temporal statistics: tmean, tmin, tmax, trange, tpercentile, tmedian, tvariance, tstdev and tcumsum.

By default they average over all available time steps. Use over to average within groups — "day" (day of year), "month", "year", or "season":

python
ds.tmean()                    # mean over all time steps
ds.tmean("year")              # annual mean
ds.tmax(["month", "year"])    # max in each month of each year
ds.tmean("season")            # seasonal climatology

Rolling statistics

rolling_mean, rolling_min, rolling_max, rolling_range and rolling_sum compute a statistic over a moving window of time steps:

python
ds.rolling_mean(7)   # rolling weekly mean, for daily data
ds.rolling_sum(7)    # rolling weekly sum

Anomalies

annual_anomaly and monthly_anomaly both need a baseline period:

python
ds.annual_anomaly(baseline=[1950, 1969])
ds.annual_anomaly(baseline=[1950, 1969], metric="relative")
ds.annual_anomaly(baseline=[1950, 1969], window=10)   # smoothed, rolling
ds.monthly_anomaly(baseline=[1950, 1969])

By default the anomaly is an absolute difference from the baseline mean; metric="relative" gives a relative change instead.

Calculating climatologies

Climatologies fall directly out of tmean. A seasonal climatology:

python
ds.tmean("season")

These methods allow partial matches for the arguments, so you don't need to remember the precise argument each time — the following also calculates a seasonal climatology:

python
ds.tmean("Seas")

A climatological monthly mean, or daily mean:

python
ds.tmean("month")
ds.tmean("day")

Cumulative sums

python
ds.tcumsum()   # over all time periods only; no `over` argument