- DataSet.tmedian(over='time', align='right')#
tmedian: Calculate the temporal median of all variables.
Useful for: monthly median, annual/yearly median, seasonal median, daily median, daily climatology, monthly climatology, seasonal climatology
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”
If you want to calculate median over all time steps. Do the following:
If you want to calculate the median for each year in a dataset, do this:
If you want to calculate the median for each month in a dataset, do this:
If you want to calculate the median for each month in each year in a dataset, do this:
>>> ds.tmedian(["year", "month"])
This method will also let you easily calculate climatologies. So, if you wanted to calculate a monthly climatological median, you would do this:
>>> ds.tmedian( "month")
A daily climatological median would be the following:
>>> ds.tmedian( "day")