Climate Indices Toolbox

Is anyone aware of a toolbox to calculate climate indices from xarray datasets/dataarrays. I’m specifically looking for drought indices (SPI, SPEI, PDSI) and Nino regions indices. But other indices such as NAO, MJO, PDO would be useful as well.

I am aware: xclim (which do not contain the above mentioned indices) and the climate indices package which can be made to work with xarray but do not have the oceanic indices.

One needed feature is the ability to choose the reference period for calculating these indices.

Thanks in advance!


This is an interesting question Deborah, thanks for asking.

Could you say more about why you think this package would be valuable?

I am of the opinion (with is just that, MY opinion, not the last word) that perhaps we do not necessarily want or need such a package. Hopefully the indices are simple enough that they can be computed through a few straightforward lines of xarray code. (For example, I assign the Nino3.4 index as a homework problem.)

Most of the complexity of calculating an index is not in the generic definition of the index itself, but rather dealing with the peculiarities of the input dataset. What sort of grid is it on? How do I perform a regional average appropriate to that grid? Do I need to resample in time? What are the variables named? Do the units need to be converted? etc. etc. etc. It would be very hard to maintain a “package” to handle all of this special logic for each possible dataset out there in the wild. New special cases would probably have to be added for almost every new possible input dataset. So I see this as a case where providing a package is probably not worth the effort in terms of maintenance.

Instead, a better value in terms of effort would probably be obtained by creating a pure documentation site which gives examples of how to calculate each index for a few different datasets. This code could then be copied / modified by users who wish to adapt it to their particular dataset.

Hi Deborah,

You could ask xclim about adding the drought indices (or even contribute them!)

There is an issue about adding ocean “indicators”: Ocean-related indicator · Issue #415 · Ouranosinc/xclim · GitHub


1 Like

I was thinking along the lines of having the few lines of code after pre-processing. Pure documentation would work along with examples for some special cases.

1 Like

Thank you! Will add the ocean ones. And I can contribute SPI/SPEI.