-
Hi,all! I use SPEI index by xclim. I see xclim offer a example to analysis frequency and the formulate to drought freqency. Is there any way to calculate the frequency for SPEI-6? like:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @CGL5230 ! Your draft has the basic idea. The simplest way I see to make this calculation would be without xclim, with only xarray basics: is_drought = (spi6 < drought_threshold)
drought_freq = 100 * is_drought.resample(time='YS').sum() / spi6.notnull().resample(time='YS').sum()
drought_freq.attrs.update(long_name='Drought frequency', units='%') Instead other counting the number of elements in the timeseries directly like you did, I counted the number of "non-null" (valid) values of SPI6. For usual climate simulation data, this makes almost no difference, but it would be more robust in the case of observations, IMO. Also, I computed the annual drought freq. You could always aggregate to longer periods by averaging. As you can see, this type of frequency calculation is pretty straightforward. The "frequency analysis" tools of xclim tackle the more complex questions of return periods and exceedance values, fitting your data with known distributions. (Like SPI does internally already). An example would be: xclim.generic.return_level(da=spi6, mode='high', t=20, dist='norm', window=1, freq='YS', method='ML') Which would give you the 20-year return level of annual SPI6. However, my knowledge of SPI is weak and I can't say if that is a pertinent statistic to compute or not. |
Beta Was this translation helpful? Give feedback.
Hi @CGL5230 !
Your draft has the basic idea. The simplest way I see to make this calculation would be without xclim, with only xarray basics:
Instead other counting the number of elements in the timeseries directly like you did, I counted the number of "non-null" (valid) values of SPI6. For usual climate simulation data, this makes almost no difference, but it would be more robust in the case of observations, IMO.
Also, I computed the annual drought freq. You could always aggregate t…