A family of methods prefixed with t calculates temporal statistics over specified time periods, plus rolling windows, anomalies and cumulative sums.
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":
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_mean, rolling_min, rolling_max, rolling_range and rolling_sum compute a statistic over a moving window of time steps:
ds.rolling_mean(7) # rolling weekly mean, for daily data ds.rolling_sum(7) # rolling weekly sum
annual_anomaly and monthly_anomaly both need a baseline period:
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.
Climatologies fall directly out of tmean. A seasonal climatology:
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:
ds.tmean("Seas")
A climatological monthly mean, or daily mean:
ds.tmean("month") ds.tmean("day")
ds.tcumsum() # over all time periods only; no `over` argument