nctoolkit.DataSet.annual_anomaly

DataSet.annual_anomaly(self, baseline=None, metric='absolute', window=1)

Calculate annual anomalies for each variable based on a baseline period The anomaly is derived by first calculating the climatological annual mean for the given baseline period. Annual means are then calculated for each year and the anomaly is calculated compared with the baseline mean. This will be calculated on a per-file basis in a multi-file dataset.

Parameters
  • baseline (list) – Baseline years. This needs to be the first and last year of the climatological period. Example: a baseline of [1980,1999] will result in anomalies against the 20 year climatology from 1980 to 1999.

  • metric (str) – Set to “absolute” or “relative”, depending on whether you want the absolute or relative anomaly to be calculated.

  • window (int) – A window for the anomaly. By default window = 1, i.e. the annual anomaly is calculated. If, for example, window = 20, the 20 year rolling means will be used to calculate the anomalies.

Examples

If you wanted to calculate an annual anomaly where values are compared with the mean for the years 1950-1969, you would do this:

>>> ds.annual_anomaly(baseline = [1950, 1969])

By default, this results in the absolute difference to be used. If you wanted the anomaly to be calculated relative to the baseline mean, you would do this:

>>> ds.annual_anomaly(baseline = [1950, 1969], metric = "relative")

You might want to smooth out the anomalies, so that you are looking at rolling averages. In that case you can supply a windows. So if you wanted to calculate the anomaly using a rolling average with a 10 year window, you would do this:

>>> ds.annual_anomaly(baseline = [1950, 1969], window = 10)