nctoolkit.DataSet.tvar

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

tvar: Calculate the temporal variance of all variables Useful for: monthly variance, annual/yearly variance, seasonal variance, daily variance, 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, with over acting as the grouping.

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

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

Examples

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

>>> ds.tvar()

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

>>> ds.tvar("year")

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

>>> ds.tvar("month")

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

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

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

>>> ds.tvar( "month")

A daily climatological variance would be the following:

>>> ds.tvar( "day")