nctoolkit.DataSet.tpercentile

nctoolkit.DataSet.tpercentile#

DataSet.tpercentile(p=None, over='time', align='right')#

tpercentile: Calculate the temporal percentile of all variables Useful for monthly percentile, annual/yearly percentile, seasonal percentile, daily percentile, daily climatology, monthly climatology, seasonal climatology

Parameters:
  • p (float or int) – Percentile to calculate

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

Examples

If you want to calculate the 20th percentile over all time steps. Do the following:

>>> ds.tpercentile(20)

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

>>> ds.tpercentile(20)

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

>>> ds.tpercentile(p= 20, over = "year")