Here i tried to build a function to calculate Standardised Precipitation Index (spi) in sub-monthly level (like weeks) using python. For my project, I calculated spi value for less than 1-month time scale. I hope it will help many people like me to understand the spi calculation. Anyone can change the code to work for their own project.
A sample input file 'Barishal.csv' is provided. Please remember, i have not included null value consideration in my function, so null values will be considered as 0. Output file 'spi.csv' is also provided which is the spi value for Cumulative 01 weeks for the period of 9th July to 23rd July. Please change the time scale as per your requirements
My sole purpose was to show the procedure of spi calculation.