nctoolkit.DataSet.tmean#

DataSet.tmean(self, over='time', align='right')#

tmean: Calculate the temporal mean of all variables.

Useful for: monthly mean, annual/yearly mean, seasonal mean, daily mean, daily climatology, monthly climatology, seasonal climatology

Parameters
  • over (str or list) – Time periods to average over. Options are ‘year’, ‘month’, ‘day’. This operates in a similar way to the groupby method in pandas or the tidyverse in R.

  • 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”

Examples

If you want to calculate mean over all time steps. Do the following:

>>> ds.tmean()

If you want to calculate the mean for each year in a dataset, do this:

>>> ds.tmean("year")

If you want to calculate the mean for each month in each year in a dataset, do this:

>>> ds.tmean(["year", "month"])

This method will also let you easily calculate climatologies. So, if you wanted to calculate a monthly climatological mean, you would do this:

>>> ds.tmean( "month")

A daily climatological mean would be the following:

>>> ds.tmean( "day")