How To Work in SPEI R Package
How To Work in SPEI R Package
discussions, stats, and author profiles for this publication at: https://www.researchgate.net/publication/299971042
CITATIONS READS
0 2,349
2 authors:
Some of the authors of this publication are also working on these related projects:
Software Models for Sustainable Water Management and Increase in Productivity of Irrigated
Cropping Systems for Different Agro-Climatic Conditions View project
All content following this page was uploaded by Sabrija adro on 08 April 2016.
The user has requested enhancement of the downloaded file. All in-text references underlined in blue are added to the original document
and are linked to publications on ResearchGate, letting you access and read them immediately.
HOW TO USE: Package SPEI
For BASIC CALCULATIONS
https://www.r-project.org/
https://cran.r-project.org/web/packages/SPEI/index.html
After installing open R software
In MENU select:
File / Change dir... browse for the folder that contains the data for processing (most commonly it is a
directory of the program: SPEI_1.6)
Than select:
Packages / Load package from the list choose: SPEI and lmomco
In case these packages are not on the list, installation is required:
Packages / Install paclkage(s)
Select CRAN mirror, and then on the list find SPEI and lmomco
1. Computation of evapotranspiration
To compute evapotranspiration by one of available methods (Penman-Monteith ET0 from Allen et al.
(1998), Thornthwaite, Hargreaves), data like in the example dataset wichita are required
(SPEI_1.6/Data).
Necessary data depending on the method of calculation are presented in the table 1
In example files In function
Explanation of the parameter In
as defined as
YEAR - year of data
MONTH or mon - month of data
PRCP PRCP monthly precipitation totals mm
TMAX TMAX monthly mean daily maximum temperature C
TMIN TMIN monthly mean daily minimum temperature C
TMED TMED monthly mean temperature C
AWND AWND monthly mean wind speed km/h*
TSUN tsun monthly mean sun hours h
ACSH CC monthly mean cloud cover %
RH RH monthly mean relative humidity %
U2 U2 monthly mean daily wind speeds at 2 m height m/s
- lat latitude parallels decimal
Z Z elevation m
Rs Rs monthly mean daily incoming solar radiation MJ m2/d
- ed monthly mean actual vapour pressure at 2 m height kPa
- Tdew monthly mean daily dewpoint temperature C
- Ra monthly mean daily external radiation MJ m2/d
*1 km/h = 0.27777 m/s
Data should be prepared as in wichita database. Wichita data in original form are unclear, however, if
you open it in MS Excel and put the data into columns (option: text to columns) and then save it as .txt,
the following form is obtained:
Before entering the data they need to be prepared in the form required for certain computation.
The data for research are necessary to be prepared on the principle of examples from the folder data
(wichita and balance). First row is used to define column title. Form the columns depending on the
available data. Use dots as decimal separators. The best extension to save created file is .txt.
Of course, instead of wichita, use the name of .txt file that you give to your data in all functions.
1.2. Computation of Evapotranspiration (PET or ET0)
Table 2
Explanation Function
PET according to Thornthwaite tho <- thornthwaite(TMED,37.6475)
Grass reference ET Hargreaves et.al har <- hargreaves(TMIN,TMAX,lat=37.6475)
Set of functions for computation of evapotranspiration with all available equations using
dataset wichita would look like this:
data(wichita)
attach(wichita)
names(wichita)
tho <- thornthwaite(TMED,37.6475)
har <- hargreaves(TMIN,TMAX,lat=37.6475)
pen <- penman(TMIN,TMAX,AWND,tsun=TSUN,lat=37.6475,z=402.6,na.rm=TRUE)
pen2 <- penman(TMIN,TMAX,AWND,CC=ACSH,lat=37.6475,z=402.6,na.rm=TRUE)
Plot them together:
plot(cbind(tho,har,pen,pen2))
2. SPEI and SPI Computations
When we want to determine the Standardized Precipitation Evapotranspiration Index (SPEI), data like
in the dataset wichita can be used, but before entering the function for SPEI it is necessary to calculate
the ratio: Precipitation-Evapotranspiration (PRCP-ET0). If the ratio is already calculated then the data
are entered directly, as is the case with the dataset balance.
If we want to calculate SPI data on precipitation (PRCP), dataset as wichita can be used.
Dataset balance contains data on water balance necessary for the calculation of SPIE, ie: Precipitation
- Evapotranspiration.
Data in the original form are not recognizable. However, if you open this dataset in MS Excel and put
the data into columns (option: text to columns) the following form is obtained:
This dataset can at the same time contain data for multiple weather stations. The software will
automatically compute the desired Standardized Precipitation Index (SPI) or SPEI for all columns. The
first row is the name of the cell/s and the data below should be arranged chronologically corresponding
to their time series. The data columns should be separated by one blank space.
If data contain NA cells, the software will not be able to do calculations!
One can make the same dataset for multiple weather stations, which instead of the water balance
(PRCP-ET0) has data on precipitation. The dataset would be than used for the calculation of SPI.
After the formation of the required dataset, it is possible to apply the functions:
- input data
data(wichita)
- show the titles of the first column
names(wichita)
- Calculation and display of average, maximum and minimum values for the entered data, as
shown in picture below:
summary(wichita)
For dataset balance, which, depending on whether you count SPI or SPEI has customized data, use
the same functions:
data(balance)
names(balance)
summary(balance)
2.1. SPEI Computation
Computation of SPEI from basic climatic data (as in the dataset wichita), with the determination of
evapotranspiration via Thornthwaite's equation - only data on the average monthly air temperature
and the geographical location of the area are required:
data(wichita)
wichita$PET <- thornthwaite(wichita$TMED, 37.6475)
spei1 <- spei(wichita$PRCP-wichita$PET,1)
where:
Name of the dataset and Geographic
FUNCTION - column in that dataset position of the
evapotransp which will be used. In research
Define name iration this case it is: TMED location -
depending on the calculation average monthly latitude in
input dataset method temperature degrees
summary(spei1)
spei1$call
spei1$fitted or print(spei1)
spei$coefficients
To plot the calculated data use:
par(mfrow=c(2,1))
plot(spei1)
plot(spei12)
The software uses a complete time period of entered data as a reference period, but it is possible to
set a different reference period. In the function below the chosen reference period is between 1980
and 2000th
Do plot(spei(ts(wichita$PRCP-wichita$PET,freq=12,start=c(1980,1)),12,
ref.start=c(1980,1), ref.end=c(2000,1)))
The used reference period is indicated as contoured part of the chart:
data(balance)
names(balance)
bal_spei12 <-
spei(balance,12)
plot(bal_spei12)
2.2. SPI Computation
data(wichita)
spi1 <- spi(wichita$PRCP,1)
summary(spi1)
spi1$call
spi1$fitted or
print(spi1)
The software uses a complete time period of entered data as a reference period, but it is possible to
set a different reference period. In the function below the chosen reference period is between 1980
and 2000th
plot(spi(ts(wichita$PRCP,freq=12,start=c(1980,1)),12,ref.start=c(1980,1),
ref.end=c(2000,1)))
The used reference period is indicated as contoured part of the chart:
If the data from the dataset such as balance are used, where there are columns of data
(precipitation) for various weather stations, SPI can be computed and plotted with following
set of functions:
data(balance)
names(balance)
bal_spi12 <- spi(balance,12)
plot(bal_spi12)
This document shows only basic functions, FOR MORE INFORMATION PLEASE REFER DIRECTLY TO
ORIGINAL SPEI PACKAGE MANUAL
https://cran.r-project.org/web/packages/SPEI/SPEI.pdf
Good work!
[email protected]
[email protected]
References
Allen, R. G., Pereira, L. S., Raes, D. Smith, M. (1998): Crop Evapotranspiration Guidelines for
Computing Crop Water Requirements, FAO Irrigation and
Drainage Paper, No. 56, Rome.
S.M. Vicente-Serrano, S. Beguera, J.I. Lpez-Moreno. 2010. A Multi-scalar drought index sensitive
to global warming: The Standardized Precipitation Evapotranspiration Index SPEI. Journal
of Climate 23: 1696, DOI: 10.1175/2009JCLI2909.1.
http://sac.csic.es/spei/
S.M. Vicente-Serrano, S. Beguera, J.I. Lpez-Moreno. 2010. A Multi-scalar drought index sensitive
to global warming: The Standardized Precipitation Evapotranspiration Index SPEI. Journal
of Climate 23: 1696, DOI: 10.1175/2009JCLI2909.1. R.G. Allen, L.S. Pereira, D. Raes, M. Smith.
1998. JCrop evapotranspiration - Guidelines for computing crop water requirements - FAO Irrigation
and drainage paper 56. FAO, Rome. ISBN 92-5-104219-5.
http://sac.csic.es/spei/database.html
https://cran.r-project.org/web/packages/SPEI/SPEI.pdf