e-baumer/standard_precip

I don't see where or how SPEI is calculated...

Opened this issue · 2 comments

"standard_precip" could be a good match for a project that I am starting, but looking at the code and examples I can't see where the evaporation data is used or input to calculate SPEI.

How would you use "standard_precip" to calculate SPEI? Is there something that I am missing?

I assumed that it's the same function, but the input should be (Precipiation - Potential Evapotranspiration), as this Python package is based on the R package SPEI (https://cran.r-project.org/web/packages/SPEI/SPEI.pdf), and that's what they describe in their documentation.

Hi! @timcera Here is an example that I hope will help you.

from standard_precip import base_sp
import pandas as pd
import numpy as np

time = pd.time = pd.date_range('1961-1-1', '2018-12-31')
diff = np.random.randn(time.size) # precipitation minus evaporation
df = pd.Series(arr, index=time, name='diff')
df = df.to_frame()
df.loc[:, 'time'] = time
spei = base_sp.BaseStandardIndex().calculate(df, 'time', ['diff'], dist_type='glo', scale=30, freq='D') # calculate 30 daily SPEI 

Usually, if replace precipitation with precipitation minus evaporation, and the result became SPEI.