dw.spell: It calculates dry/wet spell duration.

Description Usage Arguments Value Examples

View source: R/dw.spell.R

Description

It calculates dry/wet spell duration.

Usage

1
2
dw.spell(data, valmin = 0.5, origin = "1961-1-1", extract = NULL,
  month = 1:12)

Arguments

data

data frame R object containing daily precipitation time series for several gauges (one gauge time series per column).

valmin

threshold precipitation value [mm] for wet/dry day indicator.

origin

character string "yyyy-mm-dd" indicated the date of the first row of "data".

extract

string charecter referred to the state to be extracted, eg. "dry" or "wet"

month

integer vectors containing the considered months. Default is 1:12 (all the year).

Value

Function returns a list of data frames containing the spell length expressed in days

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
library(RMRAINGEN)


data(trentino)

year_min <- 1961
year_max <- 1990

period <- PRECIPITATION$year>=year_min & PRECIPITATION$year<=year_max
station <- names(PRECIPITATION)[!(names(PRECIPITATION) %in% c("day","month","year"))]
prec_mes <- PRECIPITATION[period,station]

## removing nonworking stations (e.g. time series with NA)
accepted <- array(TRUE,length(names(prec_mes)))
names(accepted) <- names(prec_mes)
for (it in names(prec_mes)) {
		 accepted[it]  <- (length(which(!is.na(prec_mes[,it])))==length(prec_mes[,it]))
}

prec_mes <- prec_mes[,accepted]
## the dateset is reduced!!!
prec_mes <- prec_mes[,1:3]

origin <- paste(year_min,1,1,sep="-")
dw.spell <- dw.spell(prec_mes,origin=origin)
dw.spell.dry <- dw.spell(prec_mes,origin=origin,extract="dry")

hist(dw.spell.dry$T0001$spell_length)

Example output

Loading required package: copula
Loading required package: RGENERATE
Loading required package: RMAWGEN
Loading required package: chron
Loading required package: date
Loading required package: vars
Loading required package: MASS
Loading required package: strucchange
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

Loading required package: sandwich
Loading required package: urca
Loading required package: lmtest

Attaching package: 'vars'

The following object is masked from 'package:copula':

    A

Loading required package: blockmatrix
Loading required package: Matrix

RMRAINGEN documentation built on May 1, 2019, 11:36 p.m.