- 积分
- 3601
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-9-8
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 hillside 于 2013-6-11 18:02 编辑
一、http://cran.r-project.org/web/packages/spi/
Package ‘spi’
February 15, 2013
Type Package
Title Compute SPI index
Version 1.1
Date 2011-02-26
Author Josemir Neves
spi Standardized Precipitation Index (SPI)
Description
The SPI function computes the SPI index (McKee et al., 1993) from a predefined time scale (1
month, 3 months, 24 months, etc.) to a period choosen by users.
Usage
spi(nargs, filename, id, fd, title, output, txlab, tylab)
Arguments
nargs number of arguments (minimum = 3)
filename name of datafile
The datafile in ASCII format must have the following layout:
Months 2005 2006 2007 2008 2009 2010
Jan 28.1 5.8 22.9 64.2 70.1 85.9
Feb 41.4 85.1 149.2 31.0 142.1 36.9
Mar 153.2 145.9 101.6 308.8 171.8 57.5
Apr 57.0 212.4 170.3 244.5 278.9 132.9
May 154.9 119.9 57.8 128.8 212.7 55.6
jun 158.6 81.3 160.8 94.0 115.3 63.3
Jul 22.6 27.2 29.4 80.9 82.7 30.9
id initial data
fd final data
title data title
output output type ( 1 - graph, 2 - results matrix )
txlab the X axis title
tylab the Y axis title
Details
Positive SPI values indicate greater than median precipitation and negative values indicate less
than median precipitation. Drought periods are represented by relatively high negative deviations.
Normally, the ’drought’ part of the SPI range is arbitrary split into moderately dry (-1.0 > SPI >
-1.49), severely dry (-1.5 > SPI > -1.99) and extremely dry conditions (SPI < -2.0). A drought event
starts when SPI value reaches -1.0 and ends when SPI becomes positive again (McKee et al., 1993).
This function use the SPI range defined by National Climatic Data Center (NCDC):
exceptionally moist:
二、除了R程序包网站的R包之外,网上有R语言热心人士研究了“Visualizing Drought”问题。作者 joe提供了两个略有差异、专门使用NCEP数据的SPI计算程序R包。
http://www.r-bloggers.com/visualizing-drought/
Visualizing Drought
March 6, 2010
By joe
(This article was first published on Biospherica » R, and kindly contributed to R-bloggers)
The impacts of drought depend on time-scale. On short time-scales, drought means dry soil. On long time-scales, it means dry rivers and empty reservoirs. A region may simultaneously experience dry conditions on one time-scale and wet conditions on another e.g. wet soil but low streamflow or visa versa.
Standardized Precipitation Index (SPI) is a widely used measure of drought which can be defined for any time-scale of interest. For any location, SPI is normally distributed with zero mean and unit standard deviation. Index values > 2 indicate exceptionally wet conditions for that location, values < -2 indicate exceptionally dry conditions for that location, etc. Historical precipitation is the only input needed to compute SPI.
Australia experienced drought between 2002 and 2007. The image below shows SPI computed for a location in the drought-prone Murray-Darling basin of New South Wales. The time-series run from Jan 1948 to Jan 2010 and the index was calculated for time-scales from 1 to 12 months. Precipitation data is from NCEP Reanalysis [1] in a 1.875° × 1.875° grid cell centred at 30°S 145°E.
The drought of 2002 to 2007 shows up very clearly. It was preceeded by a wet period between 2005 and 2001. While 2009 showed an episode of severe drought at short time-scales, SPI at was normal/wet at longer time-scales during 2009. Agricultural yields recovered.
Calculating SPI-M
Empirical rainfall probability distributions are far from normal (gaussian) and often approximate a shifted gamma distribution. The empirical cumulative probability distributions are used to transform the rainfall time-series into time-series of percentile probabilities. A normally distributed precipitation index is found by pretending that these percentile probabilities derive from a standard cumulative normal distribution and inverting to find the index values.
This is simple in R. If the vector data contains rainfall infall data, then:
fit.cdf <- ecdf(data)
cdfs <- sapply(data,fit.cdf)
SPI <- qnorm(cdfs)
Tha rainfall data are M-month moving averages (current and previous months). A separate index is calculated for each calendar month to remove seasonality. The R code used to compute SPI values (based in NCEP Reanalysis or other data sets such as GCPC) is here.
[1] The NCEP/NCAR 40-year reanalysis project, Bull. Amer. Meteor. Soc., 77, 437-470, 1996
Noted Added 11 October 2011: I have uploaded a slightly improved SPI R scripthere. The function getPrecOnTimescale(precipitation,k) takes a vector of monthly precipitation values and returns a k-month average (i.e current month and prior k-1 months). getSPIfromPrec(precip.k) takes k-month precipitation values and returns the corresponding vector of SPI values.
|
|