sbegueria / SPEI

An R package for computing the Standardized Precipitation-Evapotranspiration Index (SPEI), Penman-Monteith and other reference evapotranspiration, SPI, etc.
78 stars 34 forks source link

Calculation of SPEI only returns NA values #76

Open NatalyaDryomys opened 7 months ago

NatalyaDryomys commented 7 months ago

Good day, I am trying to calculate the SPEI Index for my dataset (attached), but spei only returns NA's. What is wrong with my data?

season$PET<-hargreaves(Tmin=season$TMIN, Tmax=season$TMAX, lat = 54.929855) season$CWBAL<-season$PRCP-season$PET season.ts=ts(season, end=c(2023, 12), frequency = 12) spei.res=spei(season.ts[,'CWBAL'], 12) spei.res str(spei.res)

season.csv

gingerlolipop commented 1 month ago

Same issue here. I tried a couple of simulation datasets and found out the SPEI only returns correct values when the number of years is >= 5. When I calculated for 1, 2, or 3 years, SPEI returned all NAs. When I calculated for 4 years, it seemed fine in general, but every year's January and February SPEI are NAs.

In my examples, frequency = 12, scale = 3.